ssm-services/init.d/lo.iface
2015-09-04 16:47:37 +03:00

33 lines
610 B
Plaintext
Executable File

#!/usr/bin/env watchman
cfg_iface="${service_name%%.*}"
service_type='oneshot'
service_command='/usr/bin/ip'
service_args=( link set "$cfg_iface" up)
wait_for_iface() {
local iface="$1" timer='0' timeout='6'
until [[ "$(ip link show $iface up)" ]]; do
(( timer >= timeout )) && { return 1; }
(( timer++ ))
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.msg "Deactivating the $cfg_iface interface..."
ip link set "${cfg_iface}" down
watchman.stop
}