network -> lo.iface

This commit is contained in:
Jack L. Frost 2014-10-04 19:47:02 +04:00
parent e61bb3c1b2
commit 91965639f3
2 changed files with 37 additions and 20 deletions

37
init.d/lo.iface Executable file
View File

@ -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
}

View File

@ -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
}