wok view knock/stuff/etc/init.d/knock @ rev 18897

syslinux/isohybrid.exe add -r support
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sun Feb 14 22:06:06 2016 +0100 (2016-02-14)
parents 1b6281d68d9f
children 7f188676b59c
line source
1 #!/bin/sh
2 # /etc/init.d/knock : Start, stop and restart knockd server on SliTaz, at
3 # boot time or with the command line.
4 #
5 # To start Knock server at boot time, just put knock in the $RUN_DAEMONS
6 # variable of /etc/rcS.conf and configure options with /etc/daemons.conf
7 #
8 . /etc/init.d/rc.functions
9 . /etc/daemons.conf
11 NAME=Knock
12 DESC="Knock server"
13 DAEMON=/usr/sbin/knockd
14 OPTIONS=$KNOCK_OPTIONS
15 PIDFILE=/var/run/knockd.pid
16 IFACE="$(route -n | awk '{ if ($1 == "0.0.0.0" && $3 == $1) print $8}')"
17 [ -n "$OPTIONS" ] || OPTIONS="-d -i ${IFACE:-eth0}"
19 case "$1" in
20 start)
21 if active_pidfile $PIDFILE knockd ; then
22 echo "$NAME already running."
23 exit 1
24 fi
25 echo -n "Starting $DESC: $NAME... "
26 $DAEMON $OPTIONS
27 status
28 ;;
29 stop)
30 if ! active_pidfile $PIDFILE knockd ; 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 knockd ; 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 status
48 ;;
49 *)
50 echo ""
51 echo -e "\033[1mUsage:\033[0m /etc/init.d/`basename $0` [start|stop|restart]"
52 echo ""
53 exit 1
54 ;;
55 esac
57 exit 0