diff options
author | Patrick J. Volkerding <volkerdi@slackware.com> | 2021-11-12 00:55:01 -0600 |
---|---|---|
committer | Robby Workman <rworkman@slackware.com> | 2021-11-12 01:10:10 -0600 |
commit | 0748efcaa51233bf510ddd0b1e537093aac2c866 (patch) | |
tree | e6bee0e35f39c55a2c2f0f9efc3f4bad3cfe7008 | |
parent | e035b1689c3496d29274951b2b92e39fee3a9bf4 (diff) | |
download | slacknetsetup-0748efcaa51233bf510ddd0b1e537093aac2c866.tar.xz |
rc.inet1: Skip bridge and bond configuration in LXC container
Add LXC detection at the beginning of the script to set container="lxc"
if an LXC container is detected. Later, use this to skip bridge and
bond creation in an LXC container. Patched script works in both LXC
and on bare metal.
Signed-off-by: Robby Workman <rworkman@slackware.com>
-rw-r--r-- | rc.inet1 | 13 |
1 files changed, 10 insertions, 3 deletions
@@ -2,7 +2,14 @@ # /etc/rc.d/rc.inet1 # This script is used to bring up the various network interfaces. # -# @(#)/etc/rc.d/rc.inet1 10.2 Sun Jul 24 12:45:56 PDT 2005 (pjv) +# @(#)/etc/rc.d/rc.inet1 15.0 Wed Nov 10 08:17:22 UTC 2021 (pjv) + +# If we are in an lxc container, set $container to skip parts of the script. +# Thanks to Matteo Bernardini <ponce@slackbuilds.org> and Chris Willing for +# the initial work making this script lxc compatible. +if grep -aq container=lxc /proc/1/environ 2> /dev/null ; then + container="lxc" +fi ############################ # READ NETWORK CONFIG FILE # @@ -254,9 +261,9 @@ if_up() { # bond or bridge, configure the interfaces with IPs of 0.0.0.0 and set the # MAC address with HWADDR. Then, finally, define the bond or bridge. # If the interface is a bond, create it. - [ -n "${BONDNICS[$i]}" ] && bond_create $i + [ -n "${BONDNICS[$i]}" -a -z "$container" ] && bond_create $i # If the interface is a bridge, create it. - [ -n "${BRNICS[$i]}" ] && br_open $i + [ -n "${BRNICS[$i]}" -a -z "$container" ] && br_open $i if [ -e /sys/class/net/${1%%[:.]*} ]; then # interface exists if ! /sbin/ip address show scope global dev ${1} 2>/dev/null | grep -Ewq '(inet|inet6)' || \ ! /sbin/ip link show dev ${1} | grep -wq "state UP"; then # interface not up or not configured |