From 0f66ce4cc6b0006f25a631679349e6605f2c2f25 Mon Sep 17 00:00:00 2001 From: Molly Lau Date: Sun, 1 Oct 2023 06:29:47 +0900 Subject: [PATCH] Update RHELinit.sh --- Linux_reinstall/RedHat/RHELinit.sh | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Linux_reinstall/RedHat/RHELinit.sh b/Linux_reinstall/RedHat/RHELinit.sh index 4762a8b..358ca00 100644 --- a/Linux_reinstall/RedHat/RHELinit.sh +++ b/Linux_reinstall/RedHat/RHELinit.sh @@ -47,6 +47,7 @@ HostName=$(grep "HostName" $confFile | awk '{print $2}') DDURL=$(grep "DDURL" $confFile | awk '{print $2}') DEC_CMD=$(grep "DEC_CMD" $confFile | awk '{print $2}') cloudInitUrl=$(grep "cloudInitUrl" $confFile | awk '{print $2}') +RedHatSeries=$(grep "RedHatSeries" $confFile | awk '{print $2}') # Reset configurations of repositories. true >/etc/apk/repositories @@ -123,9 +124,14 @@ sed -ri 's/^#?PasswordAuthentication.*/PasswordAuthentication yes/g' /mnt/etc/ss sed -ri 's/^#?Port.*/Port '${sshPORT}'/g' /mnt/etc/ssh/sshd_config # Hack cloud init. -utilProgram=$(find /mnt/usr/lib/python* -name "util.py" | grep "cloudinit" | head -n 1) -sed -ri 's/iso9660/osi9876/g' $utilProgram -sed -ri 's#"blkid"#"echo"#g' $utilProgram +# Note: this trick has a great effect on Ubuntu 20.04+, AlmaLinux / Rocky 9+ in almost any cloud platforms but unfortunately it +# is not suitable for Rocky 8 otherwise cloud init will meet a fatal may because of the version of python3.6(others are 3.9). +# More details: https://github.com/leitbogioro/Tools/blob/master/Linux_reinstall/Ubuntu/ubuntuInit.sh +[[ "$RedHatSeries" -ge "9" ]] && { + utilProgram=$(find /mnt/usr/lib/python* -name "util.py" | grep "cloudinit" | head -n 1) + sed -ri 's/iso9660/osi9876/g' $utilProgram + sed -ri 's#"blkid"#"echo"#g' $utilProgram +} # Umount mounted directory and loop device. umount /mnt