head 1.9; access; symbols netbsd-10-0-RC6:1.9 netbsd-10-0-RC5:1.9 netbsd-10-0-RC4:1.9 netbsd-10-0-RC3:1.9 netbsd-10-0-RC2:1.9 netbsd-10-0-RC1:1.9 netbsd-10:1.9.0.58 netbsd-10-base:1.9 netbsd-9-3-RELEASE:1.9 cjep_sun2x-base1:1.9 cjep_sun2x:1.9.0.56 cjep_sun2x-base:1.9 cjep_staticlib_x-base1:1.9 netbsd-9-2-RELEASE:1.9 cjep_staticlib_x:1.9.0.54 cjep_staticlib_x-base:1.9 netbsd-9-1-RELEASE:1.9 phil-wifi-20200421:1.9 phil-wifi-20200411:1.9 is-mlppp:1.9.0.52 is-mlppp-base:1.9 phil-wifi-20200406:1.9 netbsd-8-2-RELEASE:1.9 netbsd-9-0-RELEASE:1.9 netbsd-9-0-RC2:1.9 netbsd-9-0-RC1:1.9 phil-wifi-20191119:1.9 netbsd-9:1.9.0.50 netbsd-9-base:1.9 phil-wifi-20190609:1.9 netbsd-8-1-RELEASE:1.9 netbsd-8-1-RC1:1.9 pgoyette-compat-merge-20190127:1.9 pgoyette-compat-20190127:1.9 pgoyette-compat-20190118:1.9 pgoyette-compat-1226:1.9 pgoyette-compat-1126:1.9 pgoyette-compat-1020:1.9 pgoyette-compat-0930:1.9 pgoyette-compat-0906:1.9 netbsd-7-2-RELEASE:1.9 pgoyette-compat-0728:1.9 netbsd-8-0-RELEASE:1.9 phil-wifi:1.9.0.48 phil-wifi-base:1.9 pgoyette-compat-0625:1.9 netbsd-8-0-RC2:1.9 pgoyette-compat-0521:1.9 pgoyette-compat-0502:1.9 pgoyette-compat-0422:1.9 netbsd-8-0-RC1:1.9 pgoyette-compat-0415:1.9 pgoyette-compat-0407:1.9 pgoyette-compat-0330:1.9 pgoyette-compat-0322:1.9 pgoyette-compat-0315:1.9 netbsd-7-1-2-RELEASE:1.9 pgoyette-compat:1.9.0.46 pgoyette-compat-base:1.9 netbsd-7-1-1-RELEASE:1.9 matt-nb8-mediatek:1.9.0.44 matt-nb8-mediatek-base:1.9 perseant-stdc-iso10646:1.9.0.42 perseant-stdc-iso10646-base:1.9 netbsd-8:1.9.0.40 netbsd-8-base:1.9 prg-localcount2-base3:1.9 prg-localcount2-base2:1.9 prg-localcount2-base1:1.9 prg-localcount2:1.9.0.38 prg-localcount2-base:1.9 pgoyette-localcount-20170426:1.9 bouyer-socketcan-base1:1.9 pgoyette-localcount-20170320:1.9 netbsd-7-1:1.9.0.36 netbsd-7-1-RELEASE:1.9 netbsd-7-1-RC2:1.9 netbsd-7-nhusb-base-20170116:1.9 bouyer-socketcan:1.9.0.34 bouyer-socketcan-base:1.9 pgoyette-localcount-20170107:1.9 netbsd-7-1-RC1:1.9 pgoyette-localcount-20161104:1.9 netbsd-7-0-2-RELEASE:1.9 localcount-20160914:1.9 netbsd-7-nhusb:1.9.0.32 netbsd-7-nhusb-base:1.9 pgoyette-localcount-20160806:1.9 pgoyette-localcount-20160726:1.9 pgoyette-localcount:1.9.0.30 pgoyette-localcount-base:1.9 netbsd-7-0-1-RELEASE:1.9 netbsd-7-0:1.9.0.28 netbsd-7-0-RELEASE:1.9 netbsd-7-0-RC3:1.9 netbsd-7-0-RC2:1.9 netbsd-7-0-RC1:1.9 netbsd-5-2-3-RELEASE:1.7 netbsd-5-1-5-RELEASE:1.7 netbsd-6-0-6-RELEASE:1.9 netbsd-6-1-5-RELEASE:1.9 netbsd-7:1.9.0.26 netbsd-7-base:1.9 yamt-pagecache-base9:1.9 yamt-pagecache-tag8:1.9 netbsd-6-1-4-RELEASE:1.9 netbsd-6-0-5-RELEASE:1.9 tls-earlyentropy:1.9.0.24 tls-earlyentropy-base:1.9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15:1.9 riastradh-drm2-base3:1.9 netbsd-6-1-3-RELEASE:1.9 netbsd-6-0-4-RELEASE:1.9 netbsd-5-2-2-RELEASE:1.7 netbsd-5-1-4-RELEASE:1.7 netbsd-6-1-2-RELEASE:1.9 netbsd-6-0-3-RELEASE:1.9 netbsd-5-2-1-RELEASE:1.7 netbsd-5-1-3-RELEASE:1.7 netbsd-6-1-1-RELEASE:1.9 riastradh-drm2-base2:1.9 riastradh-drm2-base1:1.9 riastradh-drm2:1.9.0.16 riastradh-drm2-base:1.9 netbsd-6-1:1.9.0.22 netbsd-6-0-2-RELEASE:1.9 netbsd-6-1-RELEASE:1.9 khorben-n900:1.9.0.20 netbsd-6-1-RC4:1.9 netbsd-6-1-RC3:1.9 agc-symver:1.9.0.18 agc-symver-base:1.9 netbsd-6-1-RC2:1.9 netbsd-6-1-RC1:1.9 yamt-pagecache-base8:1.9 netbsd-5-2:1.7.0.28 netbsd-6-0-1-RELEASE:1.9 yamt-pagecache-base7:1.9 netbsd-5-2-RELEASE:1.7 netbsd-5-2-RC1:1.7 matt-nb6-plus-nbase:1.9 yamt-pagecache-base6:1.9 netbsd-6-0:1.9.0.14 netbsd-6-0-RELEASE:1.9 netbsd-6-0-RC2:1.9 tls-maxphys:1.9.0.12 tls-maxphys-base:1.9 matt-nb6-plus:1.9.0.10 matt-nb6-plus-base:1.9 netbsd-6-0-RC1:1.9 yamt-pagecache-base5:1.9 yamt-pagecache-base4:1.9 netbsd-6:1.9.0.8 netbsd-6-base:1.9 netbsd-5-1-2-RELEASE:1.7 netbsd-5-1-1-RELEASE:1.7 yamt-pagecache-base3:1.9 yamt-pagecache-base2:1.9 yamt-pagecache:1.9.0.6 yamt-pagecache-base:1.9 cherry-xenmp:1.9.0.4 cherry-xenmp-base:1.9 bouyer-quota2-nbase:1.9 bouyer-quota2:1.9.0.2 bouyer-quota2-base:1.9 matt-mips64-premerge-20101231:1.9 matt-nb5-mips64-premerge-20101231:1.7 matt-nb5-pq3:1.7.0.26 matt-nb5-pq3-base:1.7 netbsd-5-1:1.7.0.24 netbsd-5-1-RELEASE:1.7 netbsd-5-1-RC4:1.7 matt-nb5-mips64-k15:1.7 netbsd-5-1-RC3:1.7 netbsd-5-1-RC2:1.7 netbsd-5-1-RC1:1.7 netbsd-5-0-2-RELEASE:1.7 matt-nb5-mips64-premerge-20091211:1.7 matt-premerge-20091211:1.9 matt-nb5-mips64-u2-k2-k4-k7-k8-k9:1.7 matt-nb4-mips64-k7-u2a-k9b:1.7 matt-nb5-mips64-u1-k1-k5:1.7 matt-nb5-mips64:1.7.0.22 netbsd-5-0-1-RELEASE:1.7 jym-xensuspend-nbase:1.9 netbsd-5-0:1.7.0.20 netbsd-5-0-RELEASE:1.7 netbsd-5-0-RC4:1.7 netbsd-5-0-RC3:1.7 netbsd-5-0-RC2:1.7 jym-xensuspend:1.7.0.18 jym-xensuspend-base:1.9 netbsd-5-0-RC1:1.7 mjf-devfs2-base2:1.7 netbsd-5:1.7.0.16 netbsd-5-base:1.7 matt-mips64-base2:1.7 matt-mips64:1.5.0.10 netbsd-4-0-1-RELEASE:1.5 wrstuden-revivesa-base-3:1.7 wrstuden-revivesa-base-2:1.7 wrstuden-fixsa-newbase:1.5 wrstuden-revivesa-base-1:1.7 yamt-pf42-base4:1.7 yamt-pf42-base3:1.7 hpcarm-cleanup-nbase:1.7 yamt-pf42-baseX:1.7 yamt-pf42-base2:1.7 wrstuden-revivesa:1.7.0.14 wrstuden-revivesa-base:1.7 yamt-pf42:1.7.0.12 yamt-pf42-base:1.7 mjf-devfs2:1.7.0.10 mjf-devfs2-base:1.7 keiichi-mipv6:1.7.0.8 keiichi-mipv6-base:1.7 mjf-devfs:1.7.0.6 mjf-devfs-base:1.7 matt-armv6-nbase:1.7 matt-armv6-prevmlocking:1.7 wrstuden-fixsa-base-1:1.5 netbsd-4-0:1.5.0.8 netbsd-4-0-RELEASE:1.5 cube-autoconf:1.7.0.4 cube-autoconf-base:1.7 netbsd-4-0-RC5:1.5 netbsd-4-0-RC4:1.5 netbsd-4-0-RC3:1.5 netbsd-4-0-RC2:1.5 netbsd-4-0-RC1:1.5 matt-armv6:1.7.0.2 matt-armv6-base:1.7 matt-mips64-base:1.5 hpcarm-cleanup:1.5.0.6 hpcarm-cleanup-base:1.7 netbsd-3-1-1-RELEASE:1.3 netbsd-3-0-3-RELEASE:1.3 wrstuden-fixsa:1.5.0.4 wrstuden-fixsa-base:1.5 abandoned-netbsd-4-base:1.4 abandoned-netbsd-4:1.4.0.2 netbsd-3-1:1.3.0.6 netbsd-3-1-RELEASE:1.3 netbsd-3-0-2-RELEASE:1.3 netbsd-3-1-RC4:1.3 netbsd-3-1-RC3:1.3 netbsd-3-1-RC2:1.3 netbsd-3-1-RC1:1.3 netbsd-4:1.5.0.2 netbsd-4-base:1.5 netbsd-3-0-1-RELEASE:1.3 netbsd-3-0:1.3.0.4 netbsd-3-0-RELEASE:1.3 netbsd-3-0-RC6:1.3 netbsd-3-0-RC5:1.3 netbsd-3-0-RC4:1.3 netbsd-3-0-RC3:1.3 netbsd-3-0-RC2:1.3 netbsd-3-0-RC1:1.3 netbsd-2-0-3-RELEASE:1.1 netbsd-2-1:1.1.0.6 netbsd-2-1-RELEASE:1.1 netbsd-2-1-RC6:1.1 netbsd-2-1-RC5:1.1 netbsd-2-1-RC4:1.1 netbsd-2-1-RC3:1.1 netbsd-2-1-RC2:1.1 netbsd-2-1-RC1:1.1 netbsd-2-0-2-RELEASE:1.1 netbsd-3:1.3.0.2 netbsd-3-base:1.3 netbsd-2-0-1-RELEASE:1.1 netbsd-2:1.1.0.4 netbsd-2-base:1.1 netbsd-2-0-RELEASE:1.1 netbsd-2-0-RC5:1.1 netbsd-2-0-RC4:1.1 netbsd-2-0-RC3:1.1 netbsd-2-0-RC2:1.1 netbsd-2-0-RC1:1.1 netbsd-2-0:1.1.0.2 netbsd-2-0-base:1.1; locks; strict; comment @# @; 1.9 date 2009.04.08.13.29.59; author martin; state Exp; branches; next 1.8; 1.8 date 2009.04.08.13.18.56; author martin; state Exp; branches; next 1.7; 1.7 date 2007.08.25.07.07.39; author apb; state Exp; branches 1.7.18.1; next 1.6; 1.6 date 2007.08.24.17.02.32; author martin; state Exp; branches; next 1.5; 1.5 date 2006.10.01.15.17.51; author sketch; state Exp; branches; next 1.4; 1.4 date 2006.04.26.09.57.01; author blymn; state Exp; branches; next 1.3; 1.3 date 2004.08.13.18.08.03; author mycroft; state Exp; branches; next 1.2; 1.2 date 2004.04.25.16.52.19; author schmonz; state Exp; branches; next 1.1; 1.1 date 2003.12.27.00.23.22; author martin; state Exp; branches; next ; 1.7.18.1 date 2009.05.13.19.18.03; author jym; state Exp; branches; next ; desc @@ 1.9 log @systime() is not needed here - as the man page clearly points out. Noticed by pooka. @ text @#!/bin/sh # # $NetBSD: rtclocaltime,v 1.8 2009/04/08 13:18:56 martin Exp $ # # 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=$(awk 'BEGIN{ offset = -int(strftime("%z")); if (offset < 0) { sign = -1; offset = -offset; } else { sign = 1; } minutes = offset % 100; hours = int(offset / 100); offset = sign * (hours * 60 + minutes); print offset; exit(0); }') echo "Setting RTC offset to ${rtcoff}." sysctl -qw kern.rtc_offset=${rtcoff} } load_rc_config $name run_rc_command "$1" @ 1.8 log @Awk has strftime() and systime(), so no need to pipe the output of date into the script - just do it internally. @ text @d3 1 a3 1 # $NetBSD: rtclocaltime,v 1.7 2007/08/25 07:07:39 apb Exp $ d20 1 a20 1 offset = -int(strftime("%z", systime())); @ 1.7 log @Back out previous (which worked but made the code harder to understand), and implement a different method of avoiding a "-0" result. @ text @d3 1 a3 1 # $NetBSD: rtclocaltime,v 1.6 2007/08/24 17:02:32 martin Exp $ d19 2 a20 2 rtcoff=$(date '+%z' | awk '{ offset = -int($1); d31 1 @ 1.7.18.1 log @Sync with HEAD. Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html @ text @d3 1 a3 1 # $NetBSD: rtclocaltime,v 1.9 2009/04/08 13:29:59 martin Exp $ d19 2 a20 2 rtcoff=$(awk 'BEGIN{ offset = -int(strftime("%z")); a30 1 exit(0); @ 1.6 log @Cosmetics: print 0 instead of -0. From Zafer Aydogan in PR bin/36831. @ text @d3 1 a3 1 # $NetBSD: rtclocaltime,v 1.5 2006/10/01 15:17:51 sketch Exp $ d20 2 a21 2 offset = int($1); if (offset <= 0) { d30 1 a30 1 print (-1 * offset); @ 1.5 log @Tidy output so it matches other rc scripts. @ text @d3 1 a3 1 # $NetBSD: rtclocaltime,v 1.4 2006/04/26 09:57:01 blymn Exp $ d21 1 a21 1 if (offset < 0) { @ 1.4 log @Fix rtc offset calculation for timezones that are not integral hours. @ text @d3 1 a3 1 # $NetBSD: rtclocaltime,v 1.3 2004/08/13 18:08:03 mycroft Exp $ d30 1 a30 1 print offset; d32 2 a33 1 sysctl -w kern.rtc_offset=$((-1 * $rtcoff)) @ 1.3 log @Add an _rc_subr_loaded variable, set to ":" by rc.subr. Scripts can use this for a speedup by doing: $_rc_subr_loaded . /etc/rc.subr @ text @d3 1 a3 1 # $NetBSD: rtclocaltime,v 1.2 2004/04/25 16:52:19 schmonz Exp $ d28 1 a28 1 hours = offset / 100; @ 1.2 log @Add RCS Id. @ text @d3 1 a3 1 # $NetBSD$ d10 1 a10 1 . /etc/rc.subr @ 1.1 log @Add a new /etc/rc.conf option: rtclocaltime=YES adapts the RTC offset at boot automatically, so a machine dual booting another OS that uses the RTC at localtime and NetBSD agree on the current time even if daylight saving started/ended (without recompiling a kernel twice per year). Awk code by Matt Thomas. @ text @d1 4 a4 1 #! /bin/sh @