From 645f7476d3403a45d02faeac5a58dee79dd7922b Mon Sep 17 00:00:00 2001 From: bin456789 Date: Sun, 7 Jul 2024 17:07:21 +0800 Subject: [PATCH] =?UTF-8?q?redhat:=20=E6=94=AF=E6=8C=81=E5=AE=89=E8=A3=85?= =?UTF-8?q?=20rhel?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- reinstall.sh | 39 +++++++++++++++++++++++---------------- trans.sh | 17 +++++++++++------ 2 files changed, 34 insertions(+), 22 deletions(-) diff --git a/reinstall.sh b/reinstall.sh index 6e371b4..1549a18 100644 --- a/reinstall.sh +++ b/reinstall.sh @@ -34,6 +34,7 @@ Usage: $reinstall____ centos 7|9 oracle 7|8|9 alma 8|9 rocky 8|9 + redhat 8|9 --img='http://xxx.qcow2' fedora 39|40 debian 10|11|12 ubuntu 20.04|22.04|24.04 @@ -989,7 +990,7 @@ setos() { eval "${step}_img='$img'" } - setos_redhat() { + setos_centos_alma_rocky_fedora() { if is_use_cloud_image; then # ci if is_in_china; then @@ -1095,14 +1096,22 @@ setos() { fi } + setos_redhat() { + if is_use_cloud_image; then + # ci + eval "${step}_img='$img'" + else + : + fi + } + eval ${step}_distro=$distro eval ${step}_releasever=$releasever - if is_distro_like_redhat && ! [ "$distro" = oracle ]; then - setos_redhat - else - setos_$distro - fi + case "$distro" in + centos | alma | rocky | fedora) setos_centos_alma_rocky_fedora ;; + *) setos_$distro ;; + esac # debian/kali <=256M 必须使用云内核,否则不够内存 if is_distro_like_debian && ! is_in_windows && [ "$ram_size" -le 256 ]; then @@ -1122,7 +1131,7 @@ is_distro_like_redhat() { else _distro=$distro fi - [ "$_distro" = centos ] || [ "$_distro" = alma ] || [ "$_distro" = rocky ] || [ "$_distro" = fedora ] || [ "$_distro" = oracle ] + [ "$_distro" = redhat ] || [ "$_distro" = centos ] || [ "$_distro" = alma ] || [ "$_distro" = rocky ] || [ "$_distro" = fedora ] || [ "$_distro" = oracle ] } is_distro_like_debian() { @@ -1145,6 +1154,7 @@ verify_os_name() { 'oracle 7|8|9' \ 'alma 8|9' \ 'rocky 8|9' \ + 'redhat 8|9' \ 'fedora 39|40' \ 'debian 10|11|12' \ 'ubuntu 20.04|22.04|24.04' \ @@ -1177,11 +1187,8 @@ verify_os_name() { verify_os_args() { case "$distro" in dd) [ -n "$img" ] || error_and_exit "dd need --img" ;; - windows) - if [ -z "$image_name" ]; then - error_and_exit "Install Windows need --image-name." - fi - ;; + redhat) [ -n "$img" ] || error_and_exit "redhat need --img" ;; + windows) [ -n "$image_name" ] || error_and_exit "Install Windows need --image-name." ;; esac } @@ -1277,7 +1284,7 @@ install_pkg() { epel_release="$($pkg_mgr list | grep 'epel-release' | awk '{print $1}' | cut -d. -f1 | head -1)" # 如果已安装 - if rpm -qa | grep -q $epel_release; then + if rpm -q $epel_release; then # 检查是否为最新 if $pkg_mgr check-update $epel_release; then $pkg_mgr reinstall -y $epel_release @@ -1357,7 +1364,7 @@ check_ram() { netboot.xyz) echo 0 ;; alpine | debian | kali | dd) echo 256 ;; arch | gentoo | windows) echo 512 ;; - centos | alma | rocky | fedora | oracle | ubuntu) echo 1024 ;; + redhat | centos | alma | rocky | fedora | oracle | ubuntu) echo 1024 ;; opensuse) echo -1 ;; # 没有安装模式 esac ) @@ -1372,7 +1379,7 @@ check_ram() { has_cloud_image=$( case "$distro" in - centos | alma | rocky | oracle | fedora | debian | ubuntu | opensuse) echo true ;; + redhat | centos | alma | rocky | oracle | fedora | debian | ubuntu | opensuse) echo true ;; netboot.xyz | alpine | dd | arch | gentoo | kali | windows) echo false ;; esac ) @@ -2741,7 +2748,7 @@ dd | windows | netboot.xyz | kali | alpine | arch | gentoo) cloud_image=0 fi ;; -centos | alma | rocky | oracle | ubuntu | fedora | opensuse) +redhat | centos | alma | rocky | oracle | ubuntu | fedora | opensuse) cloud_image=1 ;; esac diff --git a/trans.sh b/trans.sh index 4b99d95..3a182f8 100644 --- a/trans.sh +++ b/trans.sh @@ -1354,7 +1354,8 @@ create_part() { elif is_use_cloud_image; then installer_part_size="$(get_ci_installer_part_size)" # 这几个系统不使用dd,而是复制文件 - if [ "$distro" = centos ] || [ "$distro" = alma ] || [ "$distro" = rocky ] || [ "$distro" = oracle ] || + if [ "$distro" = centos ] || [ "$distro" = alma ] || [ "$distro" = rocky ] || + [ "$distro" = oracle ] || [ "$distro" = redhat ] || [ "$distro" = ubuntu ]; then fs="$(get_os_fs)" if is_efi; then @@ -2029,7 +2030,7 @@ create_swap() { fi } -# gentoo 常规安装用 +# arch gentoo 常规安装用 allow_root_password_login() { os_dir=$1 @@ -2106,13 +2107,13 @@ disconnect_qcow() { get_os_fs() { case "$distro" in ubuntu) echo ext4 ;; - centos | alma | rocky | oracle) echo xfs ;; + centos | alma | rocky | oracle | redhat) echo xfs ;; esac } get_ci_installer_part_size() { case "$distro" in - centos | alma | rocky | oracle) echo 2GiB ;; + centos | alma | rocky | oracle | redhat) echo 2GiB ;; *) echo 1GiB ;; esac } @@ -2262,6 +2263,10 @@ install_qcow_by_copy() { swapon /dev/$xda*3 modify_el_ol() { + # redhat 使用用户提供的 qcow2 镜像,无法提前知道版本号 + # 因此需要从镜像读取版本号 + releasever=$(awk -F: '{ print $5 }' /os/etc/system-release-cpe) + # resolv.conf cp_resolv_conf /os @@ -3482,7 +3487,7 @@ if is_use_cloud_image; then create_part download_qcow case "$distro" in - centos | alma | rocky | oracle) + centos | alma | rocky | oracle | redhat) # 这几个系统云镜像系统盘是8~9g xfs,而我们的目标是能在5g硬盘上运行,因此改成复制系统文件 install_qcow_by_copy ;; @@ -3528,7 +3533,7 @@ else create_part mount_part_for_install_mode case "$distro" in - centos | alma | rocky | fedora | ubuntu) install_redhat_ubuntu ;; + centos | alma | rocky | fedora | ubuntu | redhat) install_redhat_ubuntu ;; windows) install_windows ;; esac ;;