rtclocaltime revision 1.8
11.2Sschmonz#!/bin/sh 21.2Sschmonz# 31.8Smartin# $NetBSD: rtclocaltime,v 1.8 2009/04/08 13:18:56 martin Exp $ 41.2Sschmonz# 51.1Smartin 61.1Smartin# PROVIDE: rtclocaltime 71.1Smartin# REQUIRE: mountcritremote 81.1Smartin# BEFORE: ntpdate ntpd 91.1Smartin 101.3Smycroft$_rc_subr_loaded . /etc/rc.subr 111.1Smartin 121.1Smartinname="rtclocaltime" 131.1Smartinrcvar=$name 141.1Smartinstart_cmd="rtclocaltime_start" 151.1Smartinstop_cmd=":" 161.1Smartin 171.1Smartinrtclocaltime_start() 181.1Smartin{ 191.8Smartin rtcoff=$(awk 'BEGIN{ 201.8Smartin offset = -int(strftime("%z", systime())); 211.7Sapb if (offset < 0) { 221.1Smartin sign = -1; 231.1Smartin offset = -offset; 241.1Smartin } else { 251.1Smartin sign = 1; 261.1Smartin } 271.1Smartin minutes = offset % 100; 281.4Sblymn hours = int(offset / 100); 291.1Smartin offset = sign * (hours * 60 + minutes); 301.7Sapb print offset; 311.8Smartin exit(0); 321.1Smartin }') 331.5Ssketch echo "Setting RTC offset to ${rtcoff}." 341.5Ssketch sysctl -qw kern.rtc_offset=${rtcoff} 351.1Smartin} 361.1Smartin 371.1Smartinload_rc_config $name 381.1Smartinrun_rc_command "$1" 39