Home | History | Annotate | Line # | Download | only in rc.d
rtclocaltime revision 1.1
      1 #! /bin/sh
      2 
      3 # PROVIDE: rtclocaltime
      4 # REQUIRE: mountcritremote
      5 # BEFORE:  ntpdate ntpd
      6 
      7 . /etc/rc.subr
      8 
      9 name="rtclocaltime"
     10 rcvar=$name
     11 start_cmd="rtclocaltime_start"
     12 stop_cmd=":"
     13 
     14 rtclocaltime_start()
     15 {
     16 	rtcoff=$(date '+%z' | awk '{
     17 		offset = int($1);
     18 		if (offset < 0) {
     19 			sign = -1;
     20 			offset = -offset;
     21 		} else {
     22 			sign = 1;
     23 		}
     24 		minutes = offset % 100;
     25 		hours = offset / 100;
     26 		offset = sign * (hours * 60 + minutes);
     27 		print offset;
     28 	}')
     29 	sysctl -w kern.rtc_offset=$((-1 * $rtcoff))
     30 }
     31 
     32 load_rc_config $name
     33 run_rc_command "$1"
     34