Skip to content

Commit

Permalink
redhat: 支持安装 oracle linux
Browse files Browse the repository at this point in the history
  • Loading branch information
bin456789 committed May 3, 2024
1 parent 1979233 commit 993b165
Show file tree
Hide file tree
Showing 6 changed files with 123 additions and 45 deletions.
3 changes: 2 additions & 1 deletion README.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ One-click reinstallation script
| Alpine | 256 MB | 1 GB |
| Debian / Kali | 256 MB | 1~1.5 GB ^ |
| Ubuntu | 512 MB \* | 2 GB |
| CentOS / Alma / Rocky | 512 MB \* | 5 GB |
| CentOS / Alma / Rocky / Oracle | 512 MB \* | 5 GB |
| Fedora | 512 MB \* | 5 GB |
| openSUSE | 512 MB \* | 5 GB |
| Arch | 512 MB | 5 GB |
Expand Down Expand Up @@ -85,6 +85,7 @@ All features can be used on both Linux and Windows.

```bash
bash reinstall.sh centos 7|8|9 (8|9 for the stream version)
oracle 7|8|9
alma 8|9
rocky 8|9
fedora 38|39|40
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
| Alpine | 256 MB | 1 GB |
| Debian / Kali | 256 MB | 1~1.5 GB ^ |
| Ubuntu | 512 MB \* | 2 GB |
| CentOS / Alma / Rocky | 512 MB \* | 5 GB |
| CentOS / Alma / Rocky / Oracle | 512 MB \* | 5 GB |
| Fedora | 512 MB \* | 5 GB |
| openSUSE | 512 MB \* | 5 GB |
| Arch | 512 MB | 5 GB |
Expand Down Expand Up @@ -85,6 +85,7 @@ certutil -urlcache -f -split https://mirror.ghproxy.com/https://raw.githubuserco

```bash
bash reinstall.sh centos 7|8|9 (8|9 为 stream 版本)
oracle 7|8|9
alma 8|9
rocky 8|9
fedora 38|39|40
Expand Down
7 changes: 5 additions & 2 deletions cloud-init.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,11 @@ chpasswd:
password: 123@@@
type: text
runcmd:
# opensuse tumbleweed 有 /etc/ssh/sshd_config.d/ 文件夹,没有 /etc/ssh/sshd_config,有/usr/etc/ssh/sshd_config
- grep 'Include.*/etc/ssh/sshd_config.d' /etc/ssh/sshd_config && mkdir -p /etc/ssh/sshd_config.d && echo "PermitRootLogin yes" >/etc/ssh/sshd_config.d/01-permitrootlogin.conf || echo "PermitRootLogin yes" >>/etc/ssh/sshd_config
# opensuse tumbleweed 镜像有 /etc/ssh/sshd_config.d/ 文件夹,没有 /etc/ssh/sshd_config,有/usr/etc/ssh/sshd_config
# opensuse tumbleweed cloud-init 直接创建并写入 /etc/ssh/sshd_config,造成默认配置丢失
# 下面这行删除 clout-init 创建的 sshd_config
- test $(wc -l </etc/ssh/sshd_config) -le 1 && cat /etc/ssh/sshd_config >>/etc/ssh/sshd_config.d/50-cloud-init.conf && rm -f /etc/ssh/sshd_config
- echo "PermitRootLogin yes" >/etc/ssh/sshd_config.d/01-permitrootlogin.conf || sed -Ei 's/^#?PermitRootLogin.*/PermitRootLogin yes/' /etc/ssh/sshd_config
- systemctl restart sshd || systemctl restart ssh
- touch /etc/cloud/cloud-init.disabled
# ubuntu 镜像运行 echo -e '\nDone' ,-e 会被显示出来
Expand Down
2 changes: 1 addition & 1 deletion reinstall.bat
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ if not errorlevel 1 (
)

rem pkgs 改动了才重新运行 Cygwin 安装程序
set pkgs="curl,cpio,p7zip,bind-utils,ipcalc,dos2unix,binutils"
set pkgs="curl,cpio,p7zip,bind-utils,ipcalc,dos2unix,binutils,jq"
set tags=%tmp%\cygwin-installed-!pkgs!
if not exist !tags! (
rem win10 arm 支持运行 x86 软件
Expand Down
38 changes: 32 additions & 6 deletions reinstall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ usage_and_exit() {
fi
cat <<EOF
Usage: $reinstall____ centos 7|8|9
oracle 7|8|9
alma 8|9
rocky 8|9
fedora 38|39|40
Expand Down Expand Up @@ -1050,10 +1051,30 @@ setos() {
fi
}

setos_oracle() {
if is_use_cloud_image; then
# ci
install_pkg jq
mirror=https://yum.oracle.com

[ "$basearch" = aarch64 ] &&
template_prefix=ol${releasever}_${basearch}-cloud ||
template_prefix=ol${releasever}
curl -Lo $tmp/oracle.json $mirror/templates/OracleLinux/$template_prefix-template.json
dir=$(jq -r .base_url $tmp/oracle.json)
file=$(jq -r .kvm.image $tmp/oracle.json)
ci_image=$mirror$dir/$file

eval ${step}_img=${ci_image}
else
:
fi
}

eval ${step}_distro=$distro
eval ${step}_releasever=$releasever

if is_distro_like_redhat $distro; then
if is_distro_like_redhat $distro && ! [ "$distro" = oracle ]; then
setos_redhat
else
setos_$distro
Expand All @@ -1067,7 +1088,7 @@ setos() {
}

is_distro_like_redhat() {
[ "$distro" = centos ] || [ "$distro" = alma ] || [ "$distro" = rocky ] || [ "$distro" = fedora ]
[ "$distro" = centos ] || [ "$distro" = alma ] || [ "$distro" = rocky ] || [ "$distro" = fedora ] || [ "$distro" = oracle ]
}

is_distro_like_debian() {
Expand All @@ -1082,6 +1103,7 @@ verify_os_name() {

for os in \
'centos 7|8|9' \
'oracle 7|8|9' \
'alma 8|9' \
'rocky 8|9' \
'fedora 38|39|40' \
Expand Down Expand Up @@ -1200,7 +1222,11 @@ install_pkg() {
}

is_need_epel_repo() {
[ "$pkg" = dpkg ] && { [ "$pkg_mgr" = yum ] || [ "$pkg_mgr" = dnf ]; }
case "$pkg" in
dpkg) [ "$pkg_mgr" = yum ] || [ "$pkg_mgr" = dnf ] ;;
jq) [ "$pkg_mgr" = yum ] ;; # el7/ol7
*) false ;;
esac
}

add_epel_repo() {
Expand Down Expand Up @@ -1292,7 +1318,7 @@ check_ram() {
netboot.xyz) echo 0 ;;
alpine | debian | kali | dd) echo 256 ;;
arch | gentoo | windows) echo 512 ;;
centos | alma | rocky | fedora | ubuntu) echo 1024 ;;
centos | alma | rocky | fedora | oracle | ubuntu) echo 1024 ;;
opensuse) echo -1 ;; # 没有安装模式
esac
)
Expand All @@ -1307,7 +1333,7 @@ check_ram() {

has_cloud_image=$(
case "$distro" in
centos | alma | rocky | fedora | debian | ubuntu | opensuse) echo true ;;
centos | alma | rocky | oracle | fedora | debian | ubuntu | opensuse) echo true ;;
netboot.xyz | alpine | dd | arch | gentoo | kali | windows) echo false ;;
esac
)
Expand Down Expand Up @@ -2510,7 +2536,7 @@ dd | windows | netboot.xyz | debian | kali | alpine | arch | gentoo)
cloud_image=0
fi
;;
centos | alma | rocky | ubuntu | fedora | opensuse)
centos | alma | rocky | oracle | ubuntu | fedora | opensuse)
cloud_image=1
;;
esac
Expand Down
Loading

0 comments on commit 993b165

Please sign in to comment.