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