rtclocaltime revision 1.5
11.2Sschmonz#!/bin/sh 21.2Sschmonz# 31.5Ssketch# $NetBSD: rtclocaltime,v 1.5 2006/10/01 15:17:51 sketch 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.1Smartin rtcoff=$(date '+%z' | awk '{ 201.1Smartin offset = int($1); 211.1Smartin 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.5Ssketch print (-1 * offset); 311.1Smartin }') 321.5Ssketch echo "Setting RTC offset to ${rtcoff}." 331.5Ssketch sysctl -qw kern.rtc_offset=${rtcoff} 341.1Smartin} 351.1Smartin 361.1Smartinload_rc_config $name 371.1Smartinrun_rc_command "$1" 38