2004-04-25 20:52:19 +04:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
2006-10-01 19:17:51 +04:00
|
|
|
# $NetBSD: rtclocaltime,v 1.5 2006/10/01 15:17:51 sketch Exp $
|
2004-04-25 20:52:19 +04:00
|
|
|
#
|
2003-12-27 03:23:22 +03:00
|
|
|
|
|
|
|
# PROVIDE: rtclocaltime
|
|
|
|
# REQUIRE: mountcritremote
|
|
|
|
# BEFORE: ntpdate ntpd
|
|
|
|
|
2004-08-13 22:08:03 +04:00
|
|
|
$_rc_subr_loaded . /etc/rc.subr
|
2003-12-27 03:23:22 +03:00
|
|
|
|
|
|
|
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;
|
2006-04-26 13:57:01 +04:00
|
|
|
hours = int(offset / 100);
|
2003-12-27 03:23:22 +03:00
|
|
|
offset = sign * (hours * 60 + minutes);
|
2006-10-01 19:17:51 +04:00
|
|
|
print (-1 * offset);
|
2003-12-27 03:23:22 +03:00
|
|
|
}')
|
2006-10-01 19:17:51 +04:00
|
|
|
echo "Setting RTC offset to ${rtcoff}."
|
|
|
|
sysctl -qw kern.rtc_offset=${rtcoff}
|
2003-12-27 03:23:22 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
load_rc_config $name
|
|
|
|
run_rc_command "$1"
|