opensuse: 支持 tumbleweed

This commit is contained in:
bin456789 2023-09-10 22:23:04 +08:00
parent 7405a7f242
commit 4159e60438
No known key found for this signature in database
GPG Key ID: EE301B386DE6C11B
4 changed files with 60 additions and 35 deletions

View File

@ -9,6 +9,7 @@
- 支持使用官方 iso 重装到 Windows (不支持 ARM)
- 支持从 Windows 重装到 Linux
- 原系统分区支持 lvm / btrfs
- 自动选择国内外安装源
- 使用 dd 或云镜像时有高贵的进度条,可通过 ssh/vnc/web/串行控制台 查看
- 有很多注释
@ -21,15 +22,15 @@
curl -O https://ghproxy.com/https://raw.githubusercontent.com/bin456789/reinstall/main/reinstall.sh
### 安装 Linux
bash reinstall.sh centos-7/8/9 (centos-8/9 为 stream 版本)
alma-8/9
rocky-8/9
fedora-37/38
ubuntu-20.04/22.04
alpine-3.16/3.17/3.18
debian-10/11/12
opensuse-15.4/15.5 (只支持云镜像)
arch (只支持云镜像)
bash reinstall.sh centos 7|8|9 (8|9 为 stream 版本)
alma 8|9
rocky 8|9
fedora 37|38
debian 10|11|12
ubuntu 20.04|22.04
alpine 3.16|3.17|3.18
opensuse 15.4|15.5|tumbleweed (只支持云镜像)
arch (只支持云镜像)
可选参数: --ci 强制使用云镜像

View File

@ -17,7 +17,8 @@ chpasswd:
type: text
runcmd:
# arch 没有 /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
- grep 'Include.*/etc/ssh/sshd_config.d' /etc/sshd_config && echo "PermitRootLogin yes" >/etc/ssh/sshd_config.d/01-permitrootlogin.conf || echo "PermitRootLogin yes" >>/etc/ssh/sshd_config
- systemctl restart sshd
# ubuntu 镜像运行 echo -e '\nDone' -e 会被显示出来
- echo >/dev/tty0

View File

@ -8,17 +8,17 @@ this_script=$(realpath $0)
usage_and_exit() {
cat <<EOF
Usage: reinstall.sh centos-7/8/9
alma-8/9
rocky-8/9
fedora-37/38
ubuntu-20.04/22.04
alpine-3.16/3.17/3.18
debian-10/11/12
opensuse-15.4/15.5
Usage: reinstall.sh centos 7|8|9
alma 8|9
rocky 8|9
fedora 37|38
debian 10|11|12
ubuntu 20.04|22.04
alpine 3.16|3.17|3.18
opensuse 15.4|15.5|tumbleweed
arch
windows --iso=xxx --image-name=xxx
dd --img=xxx
dd --img=xxx
windows --iso=xxx --image-name=xxx
EOF
exit 1
}
@ -330,27 +330,44 @@ setos() {
setos_opensuse() {
cloud_image=1
if grep -iq Tumbleweed <<<"$releasever"; then
dir=tumbleweed
releasever=Tumbleweed
# aria2 有 mata4 问题
# https://download.opensuse.org/
# 清华源缺少 aarch64 tumbleweed appliances
# https://mirrors.tuna.tsinghua.edu.cn/opensuse/ports/aarch64/tumbleweed/appliances/
# https://mirrors.nju.edu.cn/opensuse/ports/aarch64/tumbleweed/appliances/
if is_in_china; then
mirror=https://mirrors.nju.edu.cn/opensuse
else
if ! grep -q '\.' <<<"$releasever"; then
releasever=$(curl https://download.opensuse.org/download/distribution/leap/?json |
grep -oP "(?<=\"name\":\")$releasever\.[0-9]*" | tail -1)
mirror=https://mirror.fcix.net/opensuse
fi
if grep -iq Tumbleweed <<<"$releasever"; then
# Tumbleweed
releasever=Tumbleweed
if [ "$basearch" = aarch64 ]; then
dir=ports/aarch64/tumbleweed/appliances
else
dir=tumbleweed/appliances
fi
dir=distribution/leap/$releasever
else
# 常规版本
# 如果用户输入的版本号是 15需要查询小版本号
if ! grep -q '\.' <<<"$releasever"; then
releasever=$(curl -L https://download.opensuse.org/download/distribution/openSUSE-stable/appliances/boxes/?json |
grep -oP "(?<=\"name\":\"Leap-)$releasever\.[0-9]*" | head -1)
fi
if [ "$releasever" = 15.4 ]; then
openstack=-OpenStack
fi
dir=distribution/leap/$releasever/appliances
releasever=Leap-$releasever
fi
# cloud image
# 有专门的kvm镜像openSUSE-Leap-15.5-Minimal-VM.x86_64-kvm-and-xen.qcow2但里面没有cloud-init
# TODO: aria2 mata4问题
# TODO: Tumbleweed 网络问题/ssh主文件incloud子目录问题
if grep -q 15\.4 <<<"$releasever"; then
openstack=-OpenStack
fi
eval ${step}_img=https://mirror.fcix.net/opensuse/$dir/appliances/openSUSE-$releasever-Minimal-VM.$basearch$openstack-Cloud.qcow2
# eval ${step}_img=https://download.opensuse.org/$dir/appliances/openSUSE-$releasever-Minimal-VM.$basearch-Cloud.qcow2
eval ${step}_img=$mirror/$dir/openSUSE-$releasever-Minimal-VM.$basearch$openstack-Cloud.qcow2
}
setos_windows() {

View File

@ -714,10 +714,16 @@ modify_dd_os() {
fi
download_cloud_init_config $os_dir
if [ -f $os_dir/etc/redhat-release ]; then
find_and_mount /boot
find_and_mount /boot/efi
disable_selinux_kdump $os_dir
elif grep opensuse-tumbleweed $os_dir/etc/os-release; then
cp -f /etc/resolv.conf $os_dir/etc/resolv.conf
mount_pseudo_fs $os_dir
chroot $os_dir zypper install -y wicked
rm -f $os_dir/etc/resolv.conf
fi
}