summaryrefslogtreecommitdiff
path: root/social/miniupnpd/miniupnpd.init
blob: e09ac3ade834bcfed6d157288599bea0449c428b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/sh

MINIUPNPD=/usr/sbin/miniupnpd
ARGS='-f /etc/miniupnpd/miniupnpd.conf'
PIDFILE='/var/run/miniupnpd.pid'
IPTABLES_CREATE=/etc/miniupnpd/iptables_init.sh
IPTABLES_REMOVE=/etc/miniupnpd/iptables_removeall.sh

. /etc/rc.d/functions

case "$1" in
  start)
        stat_busy "Starting MiniUPNPd"

        if ! pidof -o %PPID $MINIUPNPD &> /dev/null; then
            rm -f "$PIDFILE"
        fi

        $IPTABLES_CREATE > /dev/null 2>&1

		PID="$(cat "$PIDFILE" 2> /dev/null)"

        if [ -z "$PID" ] && $MINIUPNPD $ARGS; then
            add_daemon miniupnpd
            stat_done
        else
            stat_fail
        fi
        ;;
  stop)
        stat_busy "Stopping MiniUPNPd"
		PID="$(cat "$PIDFILE" 2> /dev/null)"
        if [ -n "$PID" ] && kill "$PID" &> /dev/null; then
            rm -f "$PIDFILE"
            rm_daemon miniupnpd
            stat_done
        else
            stat_fail
        fi
        ;;
  restart)
        "$0" stop
        sleep 1
        "$0" start
        ;;
  *)
        echo "Usage: /etc/rc.d/miniupnpd {start|stop|restart}"
        exit 2
        ;;
esac
exit 0