wok annotate ntp/stuff/ntp @ rev 25035
Up libqcow (20210419)
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Fri May 20 18:11:13 2022 +0000 (2022-05-20) |
parents | e1f16de14d6e |
children |
rev | line source |
---|---|
pascal@1751 | 1 #!/bin/sh |
al@19159 | 2 # /etc/init.d/ntp : Start, stop and restart ntp server on SliTaz, at |
pascal@1751 | 3 # boot time or with the command line. |
pascal@1751 | 4 # |
pascal@1751 | 5 # To start ntp server at boot time, just put ntp in the $RUN_DAEMONS |
pascal@1751 | 6 # variable of /etc/rcS.conf and configure options with /etc/daemons.conf |
pascal@1751 | 7 # |
pascal@1751 | 8 . /etc/init.d/rc.functions |
pascal@1751 | 9 . /etc/daemons.conf |
pascal@1751 | 10 |
pascal@1751 | 11 NAME=ntp |
al@19159 | 12 DESC="$(_ '%s server' NTP)" |
pascal@1751 | 13 DAEMON=/usr/bin/ntpd |
pascal@1751 | 14 OPTIONS=$NTP_OPTIONS |
pascal@1751 | 15 PIDFILE=/var/run/ntpd.pid |
pascal@1751 | 16 [ -n "$OPTIONS" ] || OPTIONS="-p $PIDFILE -c /etc/ntp.conf" |
pascal@1751 | 17 |
pascal@1751 | 18 case "$1" in |
pascal@1751 | 19 start) |
pascal@2400 | 20 if active_pidfile $PIDFILE ntpd ; then |
al@19159 | 21 _ '%s is already running.' $NAME |
pascal@1751 | 22 exit 1 |
pascal@1751 | 23 fi |
al@19159 | 24 action 'Starting %s: %s...' "$DESC" $NAME |
pascal@1751 | 25 $DAEMON $OPTIONS |
pascal@1751 | 26 status |
pascal@14734 | 27 pgrep $DAEMON > $PIDFILE # it seems that -p doesn't work ? |
pascal@1751 | 28 ;; |
pascal@1751 | 29 stop) |
pascal@2400 | 30 if ! active_pidfile $PIDFILE ntpd ; then |
al@19159 | 31 _ '%s is not running.' $NAME |
pascal@1751 | 32 exit 1 |
pascal@1751 | 33 fi |
al@19159 | 34 action 'Stopping %s: %s...' "$DESC" $NAME |
al@19159 | 35 kill $(cat $PIDFILE) |
pascal@1751 | 36 rm $PIDFILE |
pascal@1751 | 37 status |
pascal@1751 | 38 ;; |
pascal@1751 | 39 restart) |
pascal@2400 | 40 if ! active_pidfile $PIDFILE ntpd ; then |
al@19159 | 41 _ '%s is not running.' $NAME |
pascal@1751 | 42 exit 1 |
pascal@1751 | 43 fi |
al@19159 | 44 action 'Restarting %s: %s...' "$DESC" $NAME |
al@19159 | 45 kill $(cat $PIDFILE) |
pascal@1751 | 46 $DAEMON $OPTIONS |
pascal@1751 | 47 status |
pascal@14734 | 48 pgrep $DAEMON > $PIDFILE # it seems that -p doesn't work ? |
pascal@1751 | 49 ;; |
pascal@1751 | 50 *) |
al@19159 | 51 emsg "<n><b>$(_ 'Usage:')</b> $0 [start|stop|restart]" |
al@19159 | 52 newline |
pascal@1751 | 53 exit 1 |
pascal@1751 | 54 ;; |
pascal@1751 | 55 esac |
pascal@1751 | 56 |
pascal@1751 | 57 exit 0 |