File: miniupnpd.init

package info (click to toggle)
miniupnpd 2.3.9-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,040 kB
  • sloc: ansic: 28,571; sh: 2,024; makefile: 164
file content (137 lines) | stat: -rw-r--r-- 2,759 bytes parent folder | download
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#!/bin/sh

### BEGIN INIT INFO
# Provides:		miniupnpd
# Required-Start:	$remote_fs
# Required-Stop:	$remote_fs
# Should-Start:		$local_fs $network $time
# Should-Stop:		$local_fs $network $time
# Default-Start:	2 3 4 5
# Default-Stop:		0 1 6
# Short-Description:	Lightweight UPnP IGD & PCP/NAT-PMP daemon
# Description:		MiniUPnPd is a small daemon which can be installed on a
#			NAT router to provide UPnP IGD & PCP/NAT-PMP port
#			mapping services, enabling clients on the LAN to ask for
#			port maps. It is compatible with peer-to-peer software,
#			messaging applications, and games consoles that connect
#			to online services (including Xbox LIVE and the
#			PlayStation Network).
### END INIT INFO

PATH=/sbin:/usr/sbin:/bin:/usr/bin
DAEMON_NAME="MiniUPnPd"
DAEMON_SERVICE_NAME="Lightweight UPnP IGD & PCP/NAT-PMP daemon"
DAEMON=/usr/sbin/miniupnpd
PIDFILE=/var/run/miniupnpd.pid
CONFFILE=/etc/miniupnpd/miniupnpd.conf
DEFAULT=/etc/default/miniupnpd
SCRIPT_DIR=/etc/miniupnpd

. /lib/lsb/init-functions

if [ -r /lib/init/vars.sh ] ; then
	. /lib/init/vars.sh
fi

read_config () {
	sed -rn '
s|^\s*'"${2}"'='\''([^'\'']+)'\''\s*$|\1|g
t hold
s|^\s*'"${2}"'='\"'([^'\"']+)'\"'\s*$|\1|g
t hold
s|^\s*'"${2}"'=(\S+)\s*$|\1|
t hold
b
: hold
p
	' "${1}"
}

# Make sure the package hasn't been removed but not purged
if ! [ -x ${DAEMON} ] ; then
	exit 0
fi

case "${1}" in
	start)
		if [ "${START_DAEMON}" = 0 ] ; then
			log_daemon_msg "${DAEMON_NAME}: ${DEFAULT} isn't set to START_DAEMON=1: exiting"
			log_end_msg 1

			exit 0
		fi

		log_daemon_msg "Initializing ${DAEMON_SERVICE_NAME} *tables" "${DAEMON_NAME}"
		if ! /usr/libexec/miniupnpd-startstop-helper.sh start ; then
			log_end_msg 1
			exit 2
		fi

		start-stop-daemon -q --start --exec "${DAEMON}" -- ${MiniUPnPd_OTHER_OPTIONS}
		RET="${?}"

		case "${RET}" in
			0|1)
				log_end_msg 0
				;;

			*)
				log_end_msg 1

				exit 1
				;;
		esac
		;;

	stop)
		log_daemon_msg "Stopping ${DAEMON_SERVICE_NAME}" "${DAEMON_NAME}"

		start-stop-daemon -q --stop --oknodo --pidfile ${PIDFILE}
		RET="${?}"

		log_daemon_msg "Deconfiguring ${DAEMON_SERVICE_NAME} *tables" "${DAEMON_NAME}"
		/usr/libexec/miniupnpd-startstop-helper.sh stop

		case "${RET}" in
			0|1)
				log_end_msg 0
				;;

			*)
				log_end_msg 1

				exit 1
				;;
		esac
		;;

	restart|force-reload)
		${0} stop
		case "$?" in
			0|1)
				${0} start
				case "$?" in
					0) log_end_msg 0 ;;
					1) log_end_msg 1 ;; # Old process is still running
					*) log_end_msg 1 ;; # Failed to start
				esac
				;;
			*)
				# Failed to stop
				log_end_msg 1
				;;
		esac
		;;

	status)
		status_of_proc "${DAEMON}" "${DAEMON_NAME}"
		exit ${?}
		;;

	*)
		echo "Usage: ${0} {start|stop|restart|status}"
		exit 1
		;;
esac

exit 0