NetBSD/etc/rc.d/rtclocaltime

38 lines
668 B
Plaintext
Raw Normal View History

2004-04-25 20:52:19 +04:00
#!/bin/sh
#
# $NetBSD: rtclocaltime,v 1.5 2006/10/01 15:17:51 sketch Exp $
2004-04-25 20:52:19 +04:00
#
# PROVIDE: rtclocaltime
# REQUIRE: mountcritremote
# BEFORE: ntpdate ntpd
$_rc_subr_loaded . /etc/rc.subr
name="rtclocaltime"
rcvar=$name
start_cmd="rtclocaltime_start"
stop_cmd=":"
rtclocaltime_start()
{
rtcoff=$(date '+%z' | awk '{
offset = int($1);
if (offset < 0) {
sign = -1;
offset = -offset;
} else {
sign = 1;
}
minutes = offset % 100;
hours = int(offset / 100);
offset = sign * (hours * 60 + minutes);
print (-1 * offset);
}')
echo "Setting RTC offset to ${rtcoff}."
sysctl -qw kern.rtc_offset=${rtcoff}
}
load_rc_config $name
run_rc_command "$1"