diff --git a/init.d/lo.iface b/init.d/lo.iface new file mode 100755 index 0000000..7388ac5 --- /dev/null +++ b/init.d/lo.iface @@ -0,0 +1,37 @@ +#!/usr/bin/env watchman + +cfg_iface="${service_name%%.*}" + +service_type='oneshot' +service_command="ip link set $cfg_iface up" + +wait_for_iface() { + local iface="$1" timer='0' timeout='6' + + until [[ "ip link show $iface up" ]]; do + [[ "$timer" -ge "$timeout" ]] && { return 1; } + timer=$[timer+1] + done +} + +start() { + watchman.msg "Activating the $cfg_iface interface..." + watchman.start + + wait_for_iface || { + echo "Interface $cfg_iface failed to come up!" + return 1 + } +} + +stop() { + watchman.status || { + watchman.err "$service_name is already disabled" + return 1 + } + + watchman.msg "Deactivating the $cfg_iface interface..." + + ip link set "${cfg_iface}" down + watchman.stop +} diff --git a/init.d/network b/init.d/network deleted file mode 100755 index 0b050c6..0000000 --- a/init.d/network +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env watchman - -service_type='oneshot' -service_command='ip' -service_args='link set lo up' - -start() { - watchman.msg "Activating the loopback interface (lo)..." - watchman.start -} - -stop() { - watchman.status || { - watchman.err "$service_name is already disabled" - return 1 - } - watchman.msg "Deactivating the loopback interface (lo)..." - ip link set lo down - watchman.stop -}