ssm-services/init.d/lo.iface

32 lines
590 B
Plaintext
Executable File

#!/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.msg "Deactivating the $cfg_iface interface..."
ip link set "${cfg_iface}" down
watchman.stop
}