wok-tiny view busybox/stuff/daemon @ rev 173

Fix ctorrent-dnh & tfttest
author Pascal Bellard <pascal.bellard@slitaz.org>
date Wed Jul 14 09:04:04 2021 +0000 (2021-07-14)
parents a28c45a86936
children
line source
1 #!/bin/sh
2 # Start, stop and restart a busybox deamon 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="$NAME deamon"
12 DAEMON=$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 echo "$NAME is already running."
20 exit 1
21 fi
22 echo -n "Starting $DESC: $NAME... "
23 $DAEMON $OPTIONS
24 [ -f $PIDFILE ] ||
25 ps | grep $NAME | grep -v etc/init | cut -d ' ' -f1 > $PIDFILE
26 active_pidfile $PIDFILE $NAME
27 status
28 ;;
29 stop)
30 if ! active_pidfile $PIDFILE $NAME ; then
31 echo "$NAME is not running."
32 exit 1
33 fi
34 echo -n "Stopping $DESC: $NAME... "
35 kill `cat $PIDFILE`
36 status
37 ;;
38 restart)
39 if ! active_pidfile $PIDFILE $NAME ; then
40 echo "$NAME is not running."
41 exit 1
42 fi
43 echo -n "Restarting $DESC: $NAME... "
44 kill `cat $PIDFILE`
45 sleep 2
46 $DAEMON $OPTIONS
47 [ -f $PIDFILE ] ||
48 ps | grep $NAME | grep -v etc/init | cut -d ' ' -f1 > $PIDFILE
49 active_pidfile $PIDFILE $NAME
50 status
51 ;;
52 *)
53 echo ""
54 echo -e "\033[1mUsage:\033[0m /etc/init.d/`basename $0` [start|stop|restart]"
55 echo ""
56 exit 1
57 ;;
58 esac
60 exit 0