diff options
Diffstat (limited to 'net-misc/minissdpd/files/minissdpd.initd-r1')
-rw-r--r-- | net-misc/minissdpd/files/minissdpd.initd-r1 | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/net-misc/minissdpd/files/minissdpd.initd-r1 b/net-misc/minissdpd/files/minissdpd.initd-r1 new file mode 100644 index 000000000000..e29d21ef4357 --- /dev/null +++ b/net-misc/minissdpd/files/minissdpd.initd-r1 @@ -0,0 +1,61 @@ +#!/sbin/runscript + +MINISSDPD="/usr/sbin/minissdpd" +PIDFILE="/var/run/minissdpd.pid" + +ROUTE="/sbin/route" +IFCONFIG="/sbin/ifconfig" + +depend() { + need net + before miniupnpd +} + +checkconfig() { + if [ "x$MINISSDPD" != "x" ]; then + interfaces=$($IFCONFIG | grep "Link encap" | awk '{ print $1 }') + for interface in $MINISSDPD; 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" = "x" ]; then + # We assume that the default interface has an IP address + interface=$($ROUTE | grep default | awk -- '{ print $8 }') + IP="$($IFCONFIG $interface | grep 'inet addr' | sed 's/.\+inet addr:\([0-9.]\+\).\+/\1/')" + ARGS="-i $IP " + else + ARGS="" + for interface in $MINISSDPD; do + # An interface may not have an IP address, so don't listen if it doesn't + IP="$($IFCONFIG $interface | grep 'inet addr' | sed 's/.\+inet addr:\([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 $? +} |