michael@719: #!@l_prefix@/bin/openpkg rc michael@719: ## michael@719: ## rc.ntp -- Run-Commands michael@719: ## michael@719: michael@719: %config michael@719: ntp_enable="$openpkg_rc_def" michael@719: ntp_mode="daemon" michael@719: ntp_daemon_flags="" michael@719: ntp_log_prolog="true" michael@719: ntp_log_epilog="true" michael@719: ntp_log_numfiles="10" michael@719: ntp_log_minsize="1M" michael@719: ntp_log_complevel="9" michael@719: michael@719: %common michael@719: ntp_pidfile=`grep "^pidfile" @l_prefix@/etc/ntp/ntp.conf | awk '{ printf("%s", $2); }'` michael@719: ntp_signal () { michael@719: [ -f $ntp_pidfile ] && kill -$1 `cat $ntp_pidfile` michael@719: } michael@719: ntp_once () { michael@719: [ ".$1" != . ] && sleep $1 michael@719: @l_prefix@/bin/ntpd -q -g michael@719: } michael@719: michael@719: %status -u @l_susr@ -o michael@719: ntp_usable="unknown" michael@719: ntp_active="no" michael@719: rcService ntp enable yes && \ michael@719: [ ".$ntp_mode" = ".daemon" ] && \ michael@719: ntp_signal 0 && ntp_active="yes" michael@719: echo "ntp_enable=\"$ntp_enable\"" michael@719: echo "ntp_usable=\"$ntp_usable\"" michael@719: echo "ntp_active=\"$ntp_active\"" michael@719: michael@719: %start -p 200 -u @l_susr@ michael@719: rcService ntp enable yes || exit 0 michael@719: rcService ntp active yes && exit 0 michael@719: michael@719: # under both periodical and daemon mode, synchronize local machine michael@719: # once manually -- either to fill the gap between startup time and michael@719: # the first run of the cron jobs (periodical mode) or to perform michael@719: # a possible large time offset which ntpd does not perform itself michael@719: # (daemon mode). michael@719: case "$ntp_mode" in michael@719: once | \ michael@719: daemon | \ michael@719: quarterly | hourly | daily | weekly | monthly ) michael@719: ntp_once michael@719: ;; michael@719: esac michael@719: michael@719: # run the NTP daemon for continued synchronization michael@719: if [ ".$ntp_mode" = .daemon ]; then michael@719: @l_prefix@/bin/ntpd ${ntp_daemon_flags} michael@719: fi michael@719: michael@719: %stop -p 800 -u @l_susr@ michael@719: rcService ntp enable yes || exit 0 michael@719: rcService ntp active no && exit 0 michael@719: ntp_signal TERM michael@719: rm -f $ntp_pidfile 2>/dev/null || true michael@719: michael@719: %restart -p 200 -u @l_susr@ michael@719: rcService ntp enable yes || exit 0 michael@719: rcService ntp active no && exit 0 michael@719: rc ntp stop start michael@719: michael@719: %quarterly -p 800 -u @l_susr@ michael@719: rcService ntp enable yes || exit 0 michael@719: [ ".$ntp_mode" = .quarterly ] && ntp_once 30 michael@719: exit 0 michael@719: michael@719: %hourly -p 800 -u @l_susr@ michael@719: rcService ntp enable yes || exit 0 michael@719: [ ".$ntp_mode" = .hourly ] && ntp_once 30 michael@719: exit 0 michael@719: michael@719: %daily -p 800 -u @l_susr@ michael@719: rcService ntp enable yes || exit 0 michael@719: [ ".$ntp_mode" = .daily ] && ntp_once 30 michael@719: shtool rotate -f \ michael@719: -n ${ntp_log_numfiles} -s ${ntp_log_minsize} -d \ michael@719: -z ${ntp_log_complevel} -m 644 -o @l_susr@ -g @l_mgrp@ \ michael@719: -P "${ntp_log_prolog}" \ michael@719: -E "${ntp_log_epilog}; rc ntp restart" \ michael@719: @l_prefix@/var/ntp/ntp.log michael@719: exit 0 michael@719: michael@719: %weekly -p 800 -u @l_susr@ michael@719: rcService ntp enable yes || exit 0 michael@719: [ ".$ntp_mode" = .weekly ] && ntp_once 30 michael@719: exit 0 michael@719: michael@719: %monthly -p 800 -u @l_susr@ michael@719: rcService ntp enable yes || exit 0 michael@719: [ ".$ntp_mode" = .monthly ] && ntp_once 30 michael@719: exit 0 michael@719: