1#!/bin/sh 2# 3# $NetBSD: rtclocaltime,v 1.8 2009/04/08 13:18:56 martin 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=$(awk 'BEGIN{ 20 offset = -int(strftime("%z")); 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 offset; 31 exit(0); 32 }') 33 echo "Setting RTC offset to ${rtcoff}." 34 sysctl -qw kern.rtc_offset=${rtcoff} 35} 36 37load_rc_config $name 38run_rc_command "$1" 39