From 7a5bb68ddda43b0166d7cb7d21e6684f3c710ab4 Mon Sep 17 00:00:00 2001 From: Kiefer Chang Date: Thu, 12 Sep 2024 16:32:52 +0800 Subject: [PATCH] Remove management interface migration script The script was used to migrate the management interface when user upgrades a cluster to v1.1.0. It's not relevant at this point. Signed-off-by: Kiefer Chang (cherry picked from commit f0598c5ec2f40b58e19cbb6b2f4c1ac980d657e8) --- .../dracut.conf.d/02-config-migration.conf | 1 - .../config-migration.service | 1 - .../systemd/system/config-migration.service | 16 -- .../harvester-os/files/usr/sbin/migration.sh | 5 - .../migration/migrate_harv_mgmt_to_mgmt_br.sh | 162 ------------------ 5 files changed, 185 deletions(-) delete mode 100644 package/harvester-os/files/etc/dracut.conf.d/02-config-migration.conf delete mode 120000 package/harvester-os/files/etc/systemd/system/initrd.target.requires/config-migration.service delete mode 100644 package/harvester-os/files/lib/systemd/system/config-migration.service delete mode 100755 package/harvester-os/files/usr/sbin/migration.sh delete mode 100755 package/harvester-os/files/usr/sbin/migration/migrate_harv_mgmt_to_mgmt_br.sh diff --git a/package/harvester-os/files/etc/dracut.conf.d/02-config-migration.conf b/package/harvester-os/files/etc/dracut.conf.d/02-config-migration.conf deleted file mode 100644 index da2aaf2de..000000000 --- a/package/harvester-os/files/etc/dracut.conf.d/02-config-migration.conf +++ /dev/null @@ -1 +0,0 @@ -install_items+=" /lib/systemd/system/config-migration.service /etc/systemd/system/initrd.target.requires/config-migration.service " diff --git a/package/harvester-os/files/etc/systemd/system/initrd.target.requires/config-migration.service b/package/harvester-os/files/etc/systemd/system/initrd.target.requires/config-migration.service deleted file mode 120000 index e42ba8c22..000000000 --- a/package/harvester-os/files/etc/systemd/system/initrd.target.requires/config-migration.service +++ /dev/null @@ -1 +0,0 @@ -/lib/systemd/system/config-migration.service \ No newline at end of file diff --git a/package/harvester-os/files/lib/systemd/system/config-migration.service b/package/harvester-os/files/lib/systemd/system/config-migration.service deleted file mode 100644 index feb4bfdbd..000000000 --- a/package/harvester-os/files/lib/systemd/system/config-migration.service +++ /dev/null @@ -1,16 +0,0 @@ -[Unit] -Description=Migrate Config to New Version -DefaultDependencies=no -After=initrd-fs.target -Requires=initrd-fs.target -Before=initrd.target cos-setup-initramfs.service - -[Service] -RootDirectory=/sysroot -BindPaths=/proc /sys /dev /run /tmp -Type=oneshot -RemainAfterExit=yes -ExecStart=-/usr/sbin/migration.sh - -[Install] -RequiredBy=initrd.target cos-setup-initramfs.service diff --git a/package/harvester-os/files/usr/sbin/migration.sh b/package/harvester-os/files/usr/sbin/migration.sh deleted file mode 100755 index 79962f98d..000000000 --- a/package/harvester-os/files/usr/sbin/migration.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash - -set -e - -/usr/sbin/migration/migrate_harv_mgmt_to_mgmt_br.sh diff --git a/package/harvester-os/files/usr/sbin/migration/migrate_harv_mgmt_to_mgmt_br.sh b/package/harvester-os/files/usr/sbin/migration/migrate_harv_mgmt_to_mgmt_br.sh deleted file mode 100755 index d340fc3a5..000000000 --- a/package/harvester-os/files/usr/sbin/migration/migrate_harv_mgmt_to_mgmt_br.sh +++ /dev/null @@ -1,162 +0,0 @@ -#!/bin/bash - -HARV_CONFIG="${HARV_CONFIG:-/oem/99_custom.yaml}" -HARV_MGMT="harvester-mgmt" -IFCFG= -IFROUTE= - -function detect_mgmt () { - yq -e '.stages.initramfs[0].files[] | select(.path == "/etc/sysconfig/network/ifcfg-'${HARV_MGMT}'") | .content' "$HARV_CONFIG" > /dev/null -} - -function migrate_mgmt_config () { - MODE= - IFCFG=$(yq '.stages.initramfs[0].files[] | select(.path == "/etc/sysconfig/network/ifcfg-'${HARV_MGMT}'") | .content' "$HARV_CONFIG") - IFROUTE=$(yq '.stages.initramfs[0].files[] | select(.path == "/etc/sysconfig/network/ifroute-'${HARV_MGMT}'") | .content' "$HARV_CONFIG") - printf "%s\n" "$IFCFG" - printf "%s\n" "$IFROUTE" - - # check DHCP or static - if printf "%s\n" "$IFCFG" | grep -q "BOOTPROTO='static'"; then - MODE="static" - elif printf "%s\n" "$IFCFG" | grep -q "BOOTPROTO='dhcp'"; then - MODE="dhcp" - else - echo "error detect bootproto mode" - exit 1 - fi - - # start patch - # remove cluster network - yq -i 'del( .stages.initramfs[0].files[] | select(.path == "*21-harvester-clusternetworks.yaml*"))' "$HARV_CONFIG" - - # remove all ifcfg and ifroute - if [ $MODE == "dhcp" ]; then - yq -i 'del( .stages.initramfs[0].commands[] | select(. == "rm -f /etc/sysconfig/network/ifroute-harvester-mgmt"))' "$HARV_CONFIG" - fi - yq -i 'del( .stages.initramfs[0].files[] | select(.path == "*ifcfg*"))' "$HARV_CONFIG" - yq -i 'del( .stages.initramfs[0].files[] | select(.path == "*ifroute*"))' "$HARV_CONFIG" - sed -i "s/iface: $HARV_MGMT/iface: \"\"/g" "$HARV_CONFIG" - - # add file - if [ $MODE == "dhcp" ]; then - yq -i '.stages.initramfs[0].commands += "rm -f /etc/sysconfig/network/ifroute-mgmt-br"' "$HARV_CONFIG" - fi - - cat <