OpenPKG CVS Repository http://cvs.openpkg.org/ ____________________________________________________________________________
Server: cvs.openpkg.org Name: Thomas Lotterer Root: /e/openpkg/cvs Email: [EMAIL PROTECTED] Module: openpkg-src Date: 07-Aug-2003 13:35:48 Branch: HEAD Handle: 2003080712354800 Modified files: openpkg-src/ntp rc.ntp Log: fix PR#230 ntpd vs. cron semantics Summary: Revision Changes Path 1.21 +29 -21 openpkg-src/ntp/rc.ntp ____________________________________________________________________________ patch -p0 <<'@@ .' Index: openpkg-src/ntp/rc.ntp ============================================================================ $ cvs diff -u -r1.20 -r1.21 rc.ntp --- openpkg-src/ntp/rc.ntp 7 Aug 2003 08:50:53 -0000 1.20 +++ openpkg-src/ntp/rc.ntp 7 Aug 2003 11:35:48 -0000 1.21 @@ -5,9 +5,7 @@ %config ntp_enable="$openpkg_rc_def" - ntp_ostart="yes" - ntp_daemon="yes" - ntp_hourly="no" + ntp_mode="daemon" ntp_log_prolog="true" ntp_log_epilog="true" ntp_log_numfiles="10" @@ -19,12 +17,17 @@ ntp_signal () { [ -f $ntp_pidfile ] && kill -$1 `cat $ntp_pidfile` } + ntp_once () { + @l_prefix@/bin/ntpdate \ + `grep "^server" @l_prefix@/etc/ntp/ntp.conf |\ + awk '{ printf(" %s", $2); }'` || true + } %status -u @l_susr@ -o ntp_usable="unknown" ntp_active="no" rcService ntp enable yes && \ - rcVarIsYes ntp_daemon && \ + [ ".$ntp_mode" = ".daemon" ] && \ ntp_signal 0 && ntp_active="yes" echo "ntp_enable=\"$ntp_enable\"" echo "ntp_usable=\"$ntp_usable\"" @@ -36,15 +39,16 @@ # on startup, force synchronize local machine # because ntpd does not skip large time offsets - # the "active" short circuit above does not hurt - if rcVarIsYes ntp_ostart; then - @l_prefix@/bin/ntpdate \ - `grep "^server" @l_prefix@/etc/ntp/ntp.conf |\ - awk '{ printf(" %s", $2); }'` - fi + case "$ntp_mode" in + once | \ + daemon | \ + quarterly | hourly | daily | weekly | monthly ) + ntp_once + ;; + esac # run the NTP daemon for continued synchronization - if rcVarIsYes ntp_daemon; then + if [ ".$ntp_mode" = ".daemon" ]; then \ @l_prefix@/bin/ntpd \ -p @l_prefix@/var/ntp/ntpd.pid \ -f @l_prefix@/var/ntp/ntpd.drift \ @@ -54,29 +58,25 @@ %stop -u @l_susr@ rcService ntp enable yes || exit 0 rcService ntp active no && exit 0 - rcVarIsYes ntp_daemon || exit 0 ntp_signal TERM rm -f $ntp_pidfile 2>/dev/null || true %restart -p 200 -u @l_susr@ rcService ntp enable yes || exit 0 rcService ntp active no && exit 0 - rcVarIsYes ntp_daemon || exit 0 rc ntp stop start -%hourly -u @l_susr@ +%quarterly -u @l_susr@ rcService ntp enable yes || exit 0 - rcVarIsYes ntp_hourly || exit 0 + if [ ".$ntp_mode" = ".quarterly" ] && ntp_once - # synchronize local machine every hour - # because ntpd does not skip large time offsets - # and to allow operation without daemon - @l_prefix@/bin/ntpdate \ - `grep "^server" @l_prefix@/etc/ntp/ntp.conf |\ - awk '{ printf(" %s", $2); }'` >/dev/null +%hourly -u @l_susr@ + rcService ntp enable yes || exit 0 + if [ ".$ntp_mode" = ".hourly" ] && ntp_once %daily -u @l_susr@ rcService ntp enable yes || exit 0 + if [ ".$ntp_mode" = ".daily" ] && ntp_once # rotate logfile shtool rotate -f \ @@ -85,4 +85,12 @@ -P "${ntp_log_prolog}" \ -E "${ntp_log_epilog} && rc ntp restart" \ @l_prefix@/var/ntp/ntp.log + +%weekly -u @l_susr@ + rcService ntp enable yes || exit 0 + if [ ".$ntp_mode" = ".weekly" ] && ntp_once + +%monthly -u @l_susr@ + rcService ntp enable yes || exit 0 + if [ ".$ntp_mode" = ".monthly" ] && ntp_once @@ . ______________________________________________________________________ The OpenPKG Project www.openpkg.org CVS Repository Commit List [EMAIL PROTECTED]