2014-10-04 15:47:02 +00:00
|
|
|
#!/usr/bin/env watchman
|
|
|
|
|
|
|
|
cfg_iface="${service_name%%.*}"
|
|
|
|
|
|
|
|
service_type='oneshot'
|
2015-01-08 09:25:38 +00:00
|
|
|
service_command='/usr/bin/ip'
|
|
|
|
service_args="link set $cfg_iface up"
|
2014-10-04 15:47:02 +00:00
|
|
|
|
|
|
|
wait_for_iface() {
|
|
|
|
local iface="$1" timer='0' timeout='6'
|
|
|
|
|
|
|
|
until [[ "ip link show $iface up" ]]; do
|
2015-01-19 13:59:09 +00:00
|
|
|
(( timer >= timeout )) && { return 1; }
|
|
|
|
(( timer++ ))
|
2014-10-04 15:47:02 +00:00
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2014-10-07 09:19:40 +00:00
|
|
|
start() {
|
2014-10-04 15:47:02 +00:00
|
|
|
watchman.msg "Activating the $cfg_iface interface..."
|
2014-10-07 09:19:40 +00:00
|
|
|
watchman.start
|
2014-10-04 15:47:02 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
}
|