Home | History | Annotate | Line # | Download | only in rc.d
rtclocaltime revision 1.5
      1  1.2  schmonz #!/bin/sh
      2  1.2  schmonz #
      3  1.5   sketch # $NetBSD: rtclocaltime,v 1.5 2006/10/01 15:17:51 sketch Exp $
      4  1.2  schmonz #
      5  1.1   martin 
      6  1.1   martin # PROVIDE: rtclocaltime
      7  1.1   martin # REQUIRE: mountcritremote
      8  1.1   martin # BEFORE:  ntpdate ntpd
      9  1.1   martin 
     10  1.3  mycroft $_rc_subr_loaded . /etc/rc.subr
     11  1.1   martin 
     12  1.1   martin name="rtclocaltime"
     13  1.1   martin rcvar=$name
     14  1.1   martin start_cmd="rtclocaltime_start"
     15  1.1   martin stop_cmd=":"
     16  1.1   martin 
     17  1.1   martin rtclocaltime_start()
     18  1.1   martin {
     19  1.1   martin 	rtcoff=$(date '+%z' | awk '{
     20  1.1   martin 		offset = int($1);
     21  1.1   martin 		if (offset < 0) {
     22  1.1   martin 			sign = -1;
     23  1.1   martin 			offset = -offset;
     24  1.1   martin 		} else {
     25  1.1   martin 			sign = 1;
     26  1.1   martin 		}
     27  1.1   martin 		minutes = offset % 100;
     28  1.4    blymn 		hours = int(offset / 100);
     29  1.1   martin 		offset = sign * (hours * 60 + minutes);
     30  1.5   sketch 		print (-1 * offset);
     31  1.1   martin 	}')
     32  1.5   sketch 	echo "Setting RTC offset to ${rtcoff}."
     33  1.5   sketch 	sysctl -qw kern.rtc_offset=${rtcoff}
     34  1.1   martin }
     35  1.1   martin 
     36  1.1   martin load_rc_config $name
     37  1.1   martin run_rc_command "$1"
     38