diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2022-05-05 16:33:34 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2022-05-05 16:33:34 +0000 |
commit | f3f0fb8c0dfed591c3c03ff7f2d00ebb8b52d4ae (patch) | |
tree | 241cc9d6148fe3d9b131bf7e344027df7eb59a8d /libexec/container/start | |
parent | Adding upstream version 20220430. (diff) | |
download | open-infrastructure-compute-tools-f3f0fb8c0dfed591c3c03ff7f2d00ebb8b52d4ae.tar.xz open-infrastructure-compute-tools-f3f0fb8c0dfed591c3c03ff7f2d00ebb8b52d4ae.zip |
Adding upstream version 20220505.upstream/20220505
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'libexec/container/start')
-rwxr-xr-x | libexec/container/start | 38 |
1 files changed, 34 insertions, 4 deletions
diff --git a/libexec/container/start b/libexec/container/start index da6be24..1b53628 100755 --- a/libexec/container/start +++ b/libexec/container/start @@ -1,6 +1,6 @@ #!/bin/sh -# Copyright (C) 2014-2021 Daniel Baumann <daniel.baumann@open-infrastructure.net> +# Copyright (C) 2014-2022 Daniel Baumann <daniel.baumann@open-infrastructure.net> # # SPDX-License-Identifier: GPL-3.0+ # @@ -191,6 +191,13 @@ case "${HOST_ARCHITECTURE}" in ;; esac +if systemctl status systemd-networkd > /dev/null 2>&1 +then + NETWORK_SUBSYSTEM="systemd-networkd" +else + NETWORK_SUBSYSTEM="ifupdown" +fi + case "${START}" in start) ;; @@ -390,7 +397,22 @@ then if [ -n "${BRIDGE}" ] && [ -n "${INTERFACE}" ] then - mkdir -p /run/systemd/network + case "${NETWORK_SUBSYSTEM}" in + ifupdown) + +cat > "/etc/network/interfaces.d/${INTERFACE}" << EOF +allow-hotplug ${INTERFACE} +iface ${INTERFACE} inet manual + pre-up ip link set ${INTERFACE} up + post-up ip link set ${INTERFACE} master ${BRIDGE} + pre-down ip link set ${INTERFACE} nomaster + post-down ip link set ${INTERFACE} down +EOF + + ;; + + systemd-networkd) + mkdir -p /run/systemd/network cat > "/run/systemd/network/${INTERFACE}.network" << EOF [Match] @@ -398,10 +420,18 @@ Name=${INTERFACE} [Network] Bridge=${BRIDGE} +cat > "/etc/network/interfaces.d/${INTERFACE}" << EOF +allow-hotplug ${INTERFACE} +iface ${INTERFACE} inet manual + pre-up ip link set ${INTERFACE} up + post-up ip link set ${INTERFACE} master ${BRIDGE} + pre-down ip link set ${INTERFACE} nomaster + post-down ip link set ${INTERFACE} down EOF - networkctl reload - + networkctl reload + ;; + esac else echo "Warning bridge definition '${BRIDGE_DEFINITION}' not recognized (expected <bridge>:<interface>): Ignoring" fi |