mirror of
https://gitlab.alpinelinux.org/alpine/aports.git
synced 2025-12-29 05:12:18 +01:00
dont stop the network when switching runlevels, including on shutdown unless user has explcitly asked to do so with "keep_network=no"
74 lines
1.3 KiB
Plaintext
74 lines
1.3 KiB
Plaintext
#!/sbin/openrc-run
|
|
|
|
# note that the spoofprotect, syncoockies and ip_forward options are set in
|
|
# /etc/sysctl.conf
|
|
|
|
ifconf=/etc/network/interfaces
|
|
ifstate=/var/run/ifstate
|
|
|
|
single_iface="${SVCNAME#*.}"
|
|
if [ "$single_iface" = "$SVCNAME" ]; then
|
|
single_iface=
|
|
fi
|
|
|
|
depend() {
|
|
need localmount
|
|
after bootmisc hwdrivers modules
|
|
provide net
|
|
keyword -jail -prefix -vserver
|
|
}
|
|
|
|
# find interfaces we want to start
|
|
find_ifaces() {
|
|
if [ -n "$single_iface" ]; then
|
|
echo $single_iface
|
|
else
|
|
awk '$1 == "auto" {for (i = 2; i <= NF; i = i + 1) printf("%s ", $i)}' $ifconf
|
|
fi
|
|
}
|
|
|
|
# return the list of interfaces we should try stop
|
|
find_running_ifaces() {
|
|
if [ -n "$single_iface" ]; then
|
|
echo $single_iface
|
|
else
|
|
awk -F= '{print $2}' $ifstate
|
|
fi
|
|
}
|
|
|
|
start() {
|
|
local iface= ret=1
|
|
ebegin "Starting networking"
|
|
eindent
|
|
for iface in $(find_ifaces); do
|
|
local r=0
|
|
ebegin "$iface"
|
|
if ! ifup $iface >/dev/null; then
|
|
ifdown $iface >/dev/null 2>&1
|
|
r=1
|
|
fi
|
|
# atleast one interface needs to be started for action
|
|
# to be success
|
|
eend $r && ret=0
|
|
done
|
|
eoutdent
|
|
return $ret
|
|
}
|
|
|
|
stop() {
|
|
local iface=
|
|
# Don't stop the network at shutdown.
|
|
yesno ${keep_network:-YES} && yesno $RC_GOINGDOWN && return 0
|
|
|
|
ebegin "Stopping networking"
|
|
eindent
|
|
for iface in $(find_running_ifaces); do
|
|
ebegin "$iface"
|
|
ifdown -f $iface >/dev/null
|
|
eend $?
|
|
done
|
|
eoutdent
|
|
return 0
|
|
}
|
|
|