summaryrefslogtreecommitdiff
path: root/pcr/miniupnpd/miniupnpd.init
diff options
context:
space:
mode:
Diffstat (limited to 'pcr/miniupnpd/miniupnpd.init')
-rw-r--r--pcr/miniupnpd/miniupnpd.init51
1 files changed, 51 insertions, 0 deletions
diff --git a/pcr/miniupnpd/miniupnpd.init b/pcr/miniupnpd/miniupnpd.init
new file mode 100644
index 000000000..e09ac3ade
--- /dev/null
+++ b/pcr/miniupnpd/miniupnpd.init
@@ -0,0 +1,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