From 97c9bd4a18d415289bceba91c534433561759aa2 Mon Sep 17 00:00:00 2001 From: Vinzenz Feenstra Date: Mon, 31 Aug 2020 14:54:00 +0200 Subject: [PATCH 41/63] [POC] initram networking Adding initial basic networking support for the initram phase. Controlled by the LEAPP_INITRAM_NETWORK environment variable which must be set to either `scripts` or `network-manager` to choose between the legacy or NetworkManager based dracut modules. Recommended to use is the network-manager part at this moment as it will take care of most of things including default routing etc. Signed-off-by: Vinzenz Feenstra --- .../libraries/addupgradebootentry.py | 5 +++-- .../dracut/85sys-upgrade-redhat/module-setup.sh | 9 +++++++++ .../files/generate-initram.sh | 13 +++++++++++++ 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/repos/system_upgrade/common/actors/addupgradebootentry/libraries/addupgradebootentry.py b/repos/system_upgrade/common/actors/addupgradebootentry/libraries/addupgradebootentry.py index 3836a0d1..ca9802bb 100644 --- a/repos/system_upgrade/common/actors/addupgradebootentry/libraries/addupgradebootentry.py +++ b/repos/system_upgrade/common/actors/addupgradebootentry/libraries/addupgradebootentry.py @@ -9,7 +9,8 @@ from leapp.models import BootContent, KernelCmdlineArg, TargetKernelCmdlineArgTa def add_boot_entry(configs=None): debug = 'debug' if os.getenv('LEAPP_DEBUG', '0') == '1' else '' - + enable_network = os.getenv('LEAPP_INITRAM_NETWORK') in ('network-manager', 'scripts') + ip_arg = ' ip=on' if enable_network else '' kernel_dst_path, initram_dst_path = get_boot_file_paths() _remove_old_upgrade_boot_entry(kernel_dst_path, configs=configs) try: @@ -20,7 +21,7 @@ def add_boot_entry(configs=None): '--title', 'RHEL-Upgrade-Initramfs', '--copy-default', '--make-default', - '--args', '{DEBUG} enforcing=0 rd.plymouth=0 plymouth.enable=0'.format(DEBUG=debug) + '--args', '{DEBUG}{NET} enforcing=0 rd.plymouth=0 plymouth.enable=0'.format(DEBUG=debug, NET=ip_arg) ] if configs: for config in configs: diff --git a/repos/system_upgrade/common/actors/commonleappdracutmodules/files/dracut/85sys-upgrade-redhat/module-setup.sh b/repos/system_upgrade/common/actors/commonleappdracutmodules/files/dracut/85sys-upgrade-redhat/module-setup.sh index 18d1d07f..d73060cb 100755 --- a/repos/system_upgrade/common/actors/commonleappdracutmodules/files/dracut/85sys-upgrade-redhat/module-setup.sh +++ b/repos/system_upgrade/common/actors/commonleappdracutmodules/files/dracut/85sys-upgrade-redhat/module-setup.sh @@ -80,6 +80,15 @@ install() { # Q: Would we hack that in way of copy whole initramfs into the root, mount # mount it and set envars + # Install network configuration triggers + if [ -f /etc/leapp-initram-network-manager ]; then + dracut_install /etc/leapp-initram-network-manager + fi + + if [ -f /etc/leapp-initram-network-scripts ]; then + dracut_install /etc/leapp-initram-network-scripts + fi + # install this one to ensure we are able to sync write inst_binary sync # install in-band debugging utilities diff --git a/repos/system_upgrade/common/actors/initramfs/upgradeinitramfsgenerator/files/generate-initram.sh b/repos/system_upgrade/common/actors/initramfs/upgradeinitramfsgenerator/files/generate-initram.sh index b3478280..7748aa78 100755 --- a/repos/system_upgrade/common/actors/initramfs/upgradeinitramfsgenerator/files/generate-initram.sh +++ b/repos/system_upgrade/common/actors/initramfs/upgradeinitramfsgenerator/files/generate-initram.sh @@ -67,6 +67,19 @@ build() { DRACUT_MODULES_ADD=$(echo "--add $LEAPP_ADD_DRACUT_MODULES" | sed 's/,/ --add /g') fi + case $LEAPP_INITRAM_NETWORK in + network-manager) + DRACUT_MODULES_ADD="$DRACUT_MODULES_ADD --add network-manager" + touch /etc/leapp-initram-network-manager + ;; + scripts) + DRACUT_MODULES_ADD="$DRACUT_MODULES_ADD --add network"; + touch /etc/leapp-initram-network-scripts + ;; + *) + ;; + esac + DRACUT_INSTALL="systemd-nspawn" if [[ -n "$LEAPP_DRACUT_INSTALL_FILES" ]]; then DRACUT_INSTALL="$DRACUT_INSTALL $LEAPP_DRACUT_INSTALL_FILES" -- 2.39.0