summaryrefslogtreecommitdiff
path: root/recipes-core/busybox/files/ifplugd.init
diff options
context:
space:
mode:
Diffstat (limited to 'recipes-core/busybox/files/ifplugd.init')
-rwxr-xr-xrecipes-core/busybox/files/ifplugd.init62
1 files changed, 62 insertions, 0 deletions
diff --git a/recipes-core/busybox/files/ifplugd.init b/recipes-core/busybox/files/ifplugd.init
new file mode 100755
index 0000000..97d6970
--- /dev/null
+++ b/recipes-core/busybox/files/ifplugd.init
@@ -0,0 +1,62 @@
+#! /bin/bash
+#
+# ifplugd init.d script
+[[ -x /usr/sbin/ifplugd ]] || exit 0
+[[ -r /etc/default/ifplugd ]] && . /etc/default/ifplugd
+
+
+#Functions to do individual actions
+startdaemon(){
+ # Start the application
+ echo -n "Starting ifplugd: "
+ CONFS=($(find /etc/ifplugd -name '*.conf'))
+ ((i=0))
+ logger -p daemon.info "Found ${#CONFS[@]} Configurations"
+ while ((i < ${#CONFS[@]})) ; do
+ unset ARGS INTERFACE
+ . ${CONFS[$i]}
+ logger -p daemon.info "Starting Interface ${INTERFACE}"
+ ((i++))
+ /usr/sbin/start-stop-daemon -Svp /run/ifplugd.${INTERFACE}.pid -a /usr/sbin/ifplugd -- ${ARGS}
+ done
+ if ((${#CONFS[@]} == 0)) ; then
+ /usr/sbin/start-stop-daemon -n ifplugd -Sv -x /usr/sbin/ifplugd -- ${ARGS}
+ fi
+ echo "done"
+}
+stopdaemon(){
+ echo -n "Stopping ifplugd: "
+ PIDS=($(find /run -name 'ifplugd.*.pid'))
+ ((i=0))
+ while ((i < ${#PIDS[@]})) ; do
+ PF=${PIDS[$i]}
+ [[ $PF =~ /ifplugd\.([^.]*)\.pid ]]
+ IF=${BASH_REMATCH[1]}
+ logger -p user.info "Shutting down interface $IF"
+ /usr/sbin/start-stop-daemon -n ifplugd -Kqp $PF
+ ((i++))
+ done
+ echo "done"
+}
+
+case "$1" in
+ start)
+ [[ ${ENABLED} == "yes" ]] || exit 0
+ startdaemon
+ ;;
+ stop)
+ stopdaemon
+ ;;
+ restart|force-reload)
+ stopdaemon
+ sleep 2
+ startdaemon
+ ;;
+ *)
+ echo "Usage: /etc/init.d/ifplugd { start | stop | restart | force-reload }" >&2
+ exit 1
+ ;;
+esac
+
+exit 0
+