ntp/rc.ntp

Mon, 28 Jan 2013 17:37:18 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Mon, 28 Jan 2013 17:37:18 +0100
changeset 758
a2c6460cfb16
permissions
-rw-r--r--

Correct socket error reporting improvement with IPv6 portable code,
after helpful recommendation by Saúl Ibarra Corretgé on OSips devlist.

     1 #!@l_prefix@/bin/openpkg rc
     2 ##
     3 ##  rc.ntp -- Run-Commands
     4 ##
     6 %config
     7     ntp_enable="$openpkg_rc_def"
     8     ntp_mode="daemon"
     9     ntp_daemon_flags=""
    10     ntp_log_prolog="true"
    11     ntp_log_epilog="true"
    12     ntp_log_numfiles="10"
    13     ntp_log_minsize="1M"
    14     ntp_log_complevel="9"
    16 %common
    17     ntp_pidfile=`grep "^pidfile" @l_prefix@/etc/ntp/ntp.conf | awk '{ printf("%s", $2); }'`
    18     ntp_signal () {
    19         [ -f $ntp_pidfile ] && kill -$1 `cat $ntp_pidfile`
    20     }
    21     ntp_once () {
    22         [ ".$1" != . ] && sleep $1
    23         @l_prefix@/bin/ntpd -q -g
    24     }
    26 %status -u @l_susr@ -o
    27     ntp_usable="unknown"
    28     ntp_active="no"
    29     rcService ntp enable yes && \
    30     [ ".$ntp_mode" = ".daemon" ] && \
    31         ntp_signal 0 && ntp_active="yes"
    32     echo "ntp_enable=\"$ntp_enable\""
    33     echo "ntp_usable=\"$ntp_usable\""
    34     echo "ntp_active=\"$ntp_active\""
    36 %start -p 200 -u @l_susr@
    37     rcService ntp enable yes || exit 0
    38     rcService ntp active yes && exit 0
    40     #   under both periodical and daemon mode, synchronize local machine
    41     #   once manually -- either to fill the gap between startup time and
    42     #   the first run of the cron jobs (periodical mode) or to perform
    43     #   a possible large time offset which ntpd does not perform itself
    44     #   (daemon mode).
    45     case "$ntp_mode" in
    46         once | \
    47         daemon | \
    48         quarterly | hourly | daily | weekly | monthly )
    49             ntp_once
    50             ;;
    51     esac
    53     #   run the NTP daemon for continued synchronization
    54     if [ ".$ntp_mode" = .daemon ]; then
    55         @l_prefix@/bin/ntpd ${ntp_daemon_flags}
    56     fi
    58 %stop -p 800 -u @l_susr@
    59     rcService ntp enable yes || exit 0
    60     rcService ntp active no  && exit 0
    61     ntp_signal TERM
    62     rm -f $ntp_pidfile 2>/dev/null || true
    64 %restart -p 200 -u @l_susr@
    65     rcService ntp enable yes || exit 0
    66     rcService ntp active no  && exit 0
    67     rc ntp stop start
    69 %quarterly -p 800 -u @l_susr@
    70     rcService ntp enable yes || exit 0
    71     [ ".$ntp_mode" = .quarterly ] && ntp_once 30
    72     exit 0
    74 %hourly -p 800 -u @l_susr@
    75     rcService ntp enable yes || exit 0
    76     [ ".$ntp_mode" = .hourly ] && ntp_once 30
    77     exit 0
    79 %daily -p 800 -u @l_susr@
    80     rcService ntp enable yes || exit 0
    81     [ ".$ntp_mode" = .daily ] && ntp_once 30
    82     shtool rotate -f \
    83         -n ${ntp_log_numfiles} -s ${ntp_log_minsize} -d \
    84         -z ${ntp_log_complevel} -m 644 -o @l_susr@ -g @l_mgrp@ \
    85         -P "${ntp_log_prolog}" \
    86         -E "${ntp_log_epilog}; rc ntp restart" \
    87         @l_prefix@/var/ntp/ntp.log
    88     exit 0
    90 %weekly -p 800 -u @l_susr@
    91     rcService ntp enable yes || exit 0
    92     [ ".$ntp_mode" = .weekly ] && ntp_once 30
    93     exit 0
    95 %monthly -p 800 -u @l_susr@
    96     rcService ntp enable yes || exit 0
    97     [ ".$ntp_mode" = .monthly ] && ntp_once 30
    98     exit 0

mercurial