wok view at/stuff/atd @ 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 7f188676b59c
children
line source
1 #!/bin/sh
2 # Start, stop and restart a atd daemon on SliTaz, at boot time or
3 # with the command line.
4 #
5 # To start daemon at boot time, just put the right name in the $RUN_DAEMONS
6 # variable of /etc/rcS.conf and configure options with /etc/daemons.conf.
7 #
8 . /etc/init.d/rc.functions
10 NAME=$(basename $0)
11 DESC="$(_ '%s daemon' $NAME)"
12 DAEMON=$(which $NAME)
13 eval $(grep -i ^${NAME}_OPTIONS /etc/daemons.conf | sed 's/.*_OPT/OPT/')
14 PIDFILE=/var/run/$NAME.pid
16 case "$1" in
17 start)
18 if active_pidfile $PIDFILE $NAME ; then
19 _ '%s is already running.' $NAME
20 exit 1
21 fi
22 action 'Starting %s: %s...' "$DESC" $NAME
23 $DAEMON $OPTIONS
24 [ -f $PIDFILE ] || pidof $NAME | awk '{print $1}' > $PIDFILE
25 active_pidfile $PIDFILE $NAME
26 status
27 ;;
28 stop)
29 if ! active_pidfile $PIDFILE $NAME ; then
30 _ '%s is not running.' $NAME
31 exit 1
32 fi
33 action 'Stopping %s: %s...' "$DESC" $NAME
34 kill $(cat $PIDFILE)
35 status
36 ;;
37 restart)
38 if ! active_pidfile $PIDFILE $NAME ; then
39 _ '%s is not running.' $NAME
40 exit 1
41 fi
42 action 'Restarting %s: %s...' "$DESC" $NAME
43 kill $(cat $PIDFILE)
44 sleep 2
45 $DAEMON $OPTIONS
46 [ -f $PIDFILE ] || pidof $NAME | awk '{print $1}' > $PIDFILE
47 active_pidfile $PIDFILE $NAME
48 status
49 ;;
50 *)
51 emsg "<n><b>$(_ 'Usage:')</b> $0 [start|stop|restart]"
52 newline
53 exit 1
54 ;;
55 esac
57 exit 0