Skip to content
This repository has been archived by the owner on Jan 16, 2024. It is now read-only.

M #: Ensure proper network restart for alpine 3.16+ #296

Merged
merged 1 commit into from
May 23, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 17 additions & 13 deletions src/etc/one-context.d/loc-10-network.d/netcfg-interfaces
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,7 @@ stop_network()
alpine)
service networking stop || true

# took from find_ifaces in the networking service
_ifaces=$(\
awk '$1 == "auto" {
for (i = 2; i <= NF; i = i + 1) printf("%s ", $i)
}' /etc/network/interfaces)

for _iface in $_ifaces; do
for _iface in $(get_interfaces); do
if [ "${_iface}" != 'lo' ]; then
/sbin/ip link set dev "${_iface}" down || true
/sbin/ip addr flush dev "${_iface}" || true
Expand All @@ -64,9 +58,7 @@ stop_network()
return 0
fi

_ifaces=$(/sbin/ifquery --list -a)

for _iface in $_ifaces; do
for _iface in $(get_interfaces); do
if [ "${_iface}" != 'lo' ] ; then
/sbin/ifdown "${_iface}"
/sbin/ip link set dev "${_iface}" down || true
Expand All @@ -85,16 +77,23 @@ start_network()
case "${os_id}" in
alpine)
service networking start

# alpine 3.16+ might fail to set the interface configuration of an interface that was removed
# from /etc/network/interfaces. This results in the interface having a definition
# in the configuration file, but no actual interface configuration.

for _iface in $(get_interfaces); do
ip link show "$_iface" | grep -q 'state DOWN' && service networking restart && break
done

;;
debian|ubuntu|devuan)
if [ -f "/usr/sbin/ifreload" ] ; then
/usr/sbin/ifreload -a
return 0
fi

_ifaces=$(/sbin/ifquery --list -a)

for _iface in $_ifaces; do
for _iface in $(get_interfaces); do
/sbin/ifup "${_iface}"
done
;;
Expand Down Expand Up @@ -424,3 +423,8 @@ EOT
;;
esac
}

# took from find_ifaces in the networking service
get_interfaces() {
/sbin/ifquery --list -a
}