redhat: 支持安装 rhel

This commit is contained in:
bin456789 2024-07-07 17:07:21 +08:00
parent 724cc5b4b9
commit 645f7476d3
No known key found for this signature in database
GPG Key ID: EE301B386DE6C11B
2 changed files with 34 additions and 22 deletions

View File

@ -34,6 +34,7 @@ Usage: $reinstall____ centos 7|9
oracle 7|8|9 oracle 7|8|9
alma 8|9 alma 8|9
rocky 8|9 rocky 8|9
redhat 8|9 --img='http://xxx.qcow2'
fedora 39|40 fedora 39|40
debian 10|11|12 debian 10|11|12
ubuntu 20.04|22.04|24.04 ubuntu 20.04|22.04|24.04
@ -989,7 +990,7 @@ setos() {
eval "${step}_img='$img'" eval "${step}_img='$img'"
} }
setos_redhat() { setos_centos_alma_rocky_fedora() {
if is_use_cloud_image; then if is_use_cloud_image; then
# ci # ci
if is_in_china; then if is_in_china; then
@ -1095,14 +1096,22 @@ setos() {
fi fi
} }
setos_redhat() {
if is_use_cloud_image; then
# ci
eval "${step}_img='$img'"
else
:
fi
}
eval ${step}_distro=$distro eval ${step}_distro=$distro
eval ${step}_releasever=$releasever eval ${step}_releasever=$releasever
if is_distro_like_redhat && ! [ "$distro" = oracle ]; then case "$distro" in
setos_redhat centos | alma | rocky | fedora) setos_centos_alma_rocky_fedora ;;
else *) setos_$distro ;;
setos_$distro esac
fi
# debian/kali <=256M 必须使用云内核,否则不够内存 # debian/kali <=256M 必须使用云内核,否则不够内存
if is_distro_like_debian && ! is_in_windows && [ "$ram_size" -le 256 ]; then if is_distro_like_debian && ! is_in_windows && [ "$ram_size" -le 256 ]; then
@ -1122,7 +1131,7 @@ is_distro_like_redhat() {
else else
_distro=$distro _distro=$distro
fi 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() { is_distro_like_debian() {
@ -1145,6 +1154,7 @@ verify_os_name() {
'oracle 7|8|9' \ 'oracle 7|8|9' \
'alma 8|9' \ 'alma 8|9' \
'rocky 8|9' \ 'rocky 8|9' \
'redhat 8|9' \
'fedora 39|40' \ 'fedora 39|40' \
'debian 10|11|12' \ 'debian 10|11|12' \
'ubuntu 20.04|22.04|24.04' \ 'ubuntu 20.04|22.04|24.04' \
@ -1177,11 +1187,8 @@ verify_os_name() {
verify_os_args() { verify_os_args() {
case "$distro" in case "$distro" in
dd) [ -n "$img" ] || error_and_exit "dd need --img" ;; dd) [ -n "$img" ] || error_and_exit "dd need --img" ;;
windows) redhat) [ -n "$img" ] || error_and_exit "redhat need --img" ;;
if [ -z "$image_name" ]; then windows) [ -n "$image_name" ] || error_and_exit "Install Windows need --image-name." ;;
error_and_exit "Install Windows need --image-name."
fi
;;
esac esac
} }
@ -1277,7 +1284,7 @@ install_pkg() {
epel_release="$($pkg_mgr list | grep 'epel-release' | awk '{print $1}' | cut -d. -f1 | head -1)" 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 if $pkg_mgr check-update $epel_release; then
$pkg_mgr reinstall -y $epel_release $pkg_mgr reinstall -y $epel_release
@ -1357,7 +1364,7 @@ check_ram() {
netboot.xyz) echo 0 ;; netboot.xyz) echo 0 ;;
alpine | debian | kali | dd) echo 256 ;; alpine | debian | kali | dd) echo 256 ;;
arch | gentoo | windows) echo 512 ;; 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 ;; # 没有安装模式 opensuse) echo -1 ;; # 没有安装模式
esac esac
) )
@ -1372,7 +1379,7 @@ check_ram() {
has_cloud_image=$( has_cloud_image=$(
case "$distro" in 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 ;; netboot.xyz | alpine | dd | arch | gentoo | kali | windows) echo false ;;
esac esac
) )
@ -2741,7 +2748,7 @@ dd | windows | netboot.xyz | kali | alpine | arch | gentoo)
cloud_image=0 cloud_image=0
fi fi
;; ;;
centos | alma | rocky | oracle | ubuntu | fedora | opensuse) redhat | centos | alma | rocky | oracle | ubuntu | fedora | opensuse)
cloud_image=1 cloud_image=1
;; ;;
esac esac

View File

@ -1354,7 +1354,8 @@ create_part() {
elif is_use_cloud_image; then elif is_use_cloud_image; then
installer_part_size="$(get_ci_installer_part_size)" installer_part_size="$(get_ci_installer_part_size)"
# 这几个系统不使用dd而是复制文件 # 这几个系统不使用dd而是复制文件
if [ "$distro" = centos ] || [ "$distro" = alma ] || [ "$distro" = rocky ] || [ "$distro" = oracle ] || if [ "$distro" = centos ] || [ "$distro" = alma ] || [ "$distro" = rocky ] ||
[ "$distro" = oracle ] || [ "$distro" = redhat ] ||
[ "$distro" = ubuntu ]; then [ "$distro" = ubuntu ]; then
fs="$(get_os_fs)" fs="$(get_os_fs)"
if is_efi; then if is_efi; then
@ -2029,7 +2030,7 @@ create_swap() {
fi fi
} }
# gentoo 常规安装用 # arch gentoo 常规安装用
allow_root_password_login() { allow_root_password_login() {
os_dir=$1 os_dir=$1
@ -2106,13 +2107,13 @@ disconnect_qcow() {
get_os_fs() { get_os_fs() {
case "$distro" in case "$distro" in
ubuntu) echo ext4 ;; ubuntu) echo ext4 ;;
centos | alma | rocky | oracle) echo xfs ;; centos | alma | rocky | oracle | redhat) echo xfs ;;
esac esac
} }
get_ci_installer_part_size() { get_ci_installer_part_size() {
case "$distro" in case "$distro" in
centos | alma | rocky | oracle) echo 2GiB ;; centos | alma | rocky | oracle | redhat) echo 2GiB ;;
*) echo 1GiB ;; *) echo 1GiB ;;
esac esac
} }
@ -2262,6 +2263,10 @@ install_qcow_by_copy() {
swapon /dev/$xda*3 swapon /dev/$xda*3
modify_el_ol() { modify_el_ol() {
# redhat 使用用户提供的 qcow2 镜像,无法提前知道版本号
# 因此需要从镜像读取版本号
releasever=$(awk -F: '{ print $5 }' /os/etc/system-release-cpe)
# resolv.conf # resolv.conf
cp_resolv_conf /os cp_resolv_conf /os
@ -3482,7 +3487,7 @@ if is_use_cloud_image; then
create_part create_part
download_qcow download_qcow
case "$distro" in case "$distro" in
centos | alma | rocky | oracle) centos | alma | rocky | oracle | redhat)
# 这几个系统云镜像系统盘是8~9g xfs而我们的目标是能在5g硬盘上运行因此改成复制系统文件 # 这几个系统云镜像系统盘是8~9g xfs而我们的目标是能在5g硬盘上运行因此改成复制系统文件
install_qcow_by_copy install_qcow_by_copy
;; ;;
@ -3528,7 +3533,7 @@ else
create_part create_part
mount_part_for_install_mode mount_part_for_install_mode
case "$distro" in case "$distro" in
centos | alma | rocky | fedora | ubuntu) install_redhat_ubuntu ;; centos | alma | rocky | fedora | ubuntu | redhat) install_redhat_ubuntu ;;
windows) install_windows ;; windows) install_windows ;;
esac esac
;; ;;