#!/bin/sh /etc/rc.common
# Copyright (C) 2008-2010 OpenWrt.org

START=10

TS_LIBDIR=/lib/time_setting

start() {
	$TS_LIBDIR/set_time
	build_time=`cat /tmp/firmware-info.json |awk '/software-version/{print $4}'`
	all_in_one=$(uci -c /etc/profile.d get profile.@global[0].all_in_one)

	if [ "$all_in_one" = "1" ]; then
		return 0
	fi
	if [ ! -z "$build_time" ] && [ ${#build_time} -eq 8 ]; then
		ori_time=${build_time:0:4}-${build_time:4:2}-${build_time:6}" 00:00:00"
		date -s "$ori_time"
		[ $? -eq 1 ] && date -s "2020-01-01 01:01:01" 
	else
		date -s "2020-01-01 01:01:01"
	fi  
}

stop() {
	echo "do nothing"
}

restart() {
	$TS_LIBDIR/set_time
}

reload() {
	$TS_LIBDIR/set_time
}
