blob: d09ed2c5a98532810cdf8492fb3683f0b3f91b87 (
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
52
53
54
55
56
57
58
59
60
61
|
#!/sbin/runscript
MINISSDPD="/usr/sbin/minissdpd"
PIDFILE="/var/run/minissdpd.pid"
ROUTE="/bin/route"
IFCONFIG="/bin/ifconfig"
depend() {
need net
before miniupnpd
}
checkconfig() {
if [ "x$MINISSDPD_IFACE" != "x" ]; then
interfaces=$($IFCONFIG | grep "Link encap" | awk '{ print $1 }')
for interface in $MINISSDPD_IFACE; do
hit=0
for available in $interfaces; do
if [ "$interface" = "$available" ]; then
hit=1
fi
done
if [ $hit = 0 ]; then
ewarn "Interface $interface not available"
return 1
fi
done
fi
return 0
}
start() {
ebegin "Starting minissdpd"
checkconfig || return 1
if [ "x$MINISSDPD_IFACE" = "x" ]; then
# We assume that the default interface has an IP address
interface=$($ROUTE | grep default | awk -- '{ print $8 }')
IP="$($IFCONFIG $interface | grep 'inet' | sed 's/^.*inet \([0-9.]\+\).\+/\1/')"
ARGS="-i $IP "
else
ARGS=""
for interface in $MINISSDPD_IFACE; do
# An interface may not have an IP address, so don't listen if it doesn't
IP="$($IFCONFIG $interface | grep 'inet' | sed 's/^.*inet \([0-9.]\+\).\+/\1/')"
if [ "x$IP" != "x" ]; then
ARGS+="-i $IP "
fi
done
fi
start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $MINISSDPD -- $ARGS
eend $?
}
stop() {
ebegin "Stopping minissdpd"
start-stop-daemon --stop --pidfile "${PIDFILE}"
eend $?
}
|