Skip to content

Commit b5eb71e

Browse files
committed
opensuse: 添加 16.0
1 parent 28e1012 commit b5eb71e

File tree

4 files changed

+67
-46
lines changed

4 files changed

+67
-46
lines changed

README.en.md

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ The system requirements for the target system are as follows:
5656
| <img width="16" height="16" src="https://www.centos.org/assets/icons/favicon.svg" /> CentOS Stream | 9, 10 | 512 MB \* | 5 GB |
5757
| <img width="16" height="16" src="https://fedoraproject.org/favicon.ico" /> Fedora | 41, 42 | 512 MB \* | 5 GB |
5858
| <img width="16" height="16" src="https://www.openeuler.org/favicon.ico" /> openEuler | 20.03 LTS - 24.03 LTS, 25.09 | 512 MB \* | 5 GB |
59-
| <img width="16" height="16" src="https://static.opensuse.org/favicon.ico" /> openSUSE | Leap 15.6, Tumbleweed (Rolling) | 512 MB \* | 5 GB |
59+
| <img width="16" height="16" src="https://static.opensuse.org/favicon.ico" /> openSUSE | Leap 15.6, 16.0, Tumbleweed (Rolling) | 512 MB \* | 5 GB |
6060
| <img width="16" height="16" src="https://nixos.org/favicon.svg" /> NixOS | 25.05 | 512 MB | 5 GB |
6161
| <img width="16" height="16" src="https://archlinux.org/static/favicon.png" /> Arch | Rolling | 512 MB | 5 GB |
6262
| <img width="16" height="16" src="https://www.gentoo.org/assets/img/logo/gentoo-g.png" /> Gentoo | Rolling | 512 MB | 5 GB |
@@ -162,8 +162,8 @@ bash reinstall.sh anolis 7|8|23
162162
fedora 41|42
163163
nixos 25.05
164164
debian 9|10|11|12|13
165-
opensuse 15.6|tumbleweed
166165
alpine 3.19|3.20|3.21|3.22
166+
opensuse 15.6|16.0|tumbleweed
167167
openeuler 20.03|22.03|24.03|25.09
168168
ubuntu 16.04|18.04|20.04|22.04|24.04|25.10 [--minimal]
169169
kali
@@ -547,6 +547,20 @@ Log in to the server using Remote Desktop, open Device Manager, locate the graph
547547
- `--ssh-key /path/to/public_key`
548548
- `--ssh-key C:\path\to\public_key`
549549

550+
## How to Use an Old Version
551+
552+
According to the Law of Bug Conservation, fixing old bugs often introduces new ones.
553+
If you encounter such a situation, you can try using an older version.
554+
555+
Go to <https://github.com/bin456789/reinstall/commits/main> and find the old version’s `commit_id` on the right side.
556+
557+
```bash
558+
commit_id=xxxxxxx
559+
curl -O https://raw.githubusercontent.com/bin456789/reinstall/$commit_id/reinstall.sh || wget -O ${_##*/} $_
560+
sed -i "/^confhome.*main$/s/main/$commit_id/" reinstall.sh
561+
bash reinstall.sh ...
562+
```
563+
550564
## How to Modify the Script for Your Own
551565

552566
1. Fork this repository.

README.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
| <img width="16" height="16" src="https://www.centos.org/assets/icons/favicon.svg" /> CentOS Stream | 9, 10 | 512 MB \* | 5 GB |
5757
| <img width="16" height="16" src="https://fedoraproject.org/favicon.ico" /> Fedora | 41, 42 | 512 MB \* | 5 GB |
5858
| <img width="16" height="16" src="https://www.openeuler.org/favicon.ico" /> openEuler | 20.03 LTS - 24.03 LTS, 25.09 | 512 MB \* | 5 GB |
59-
| <img width="16" height="16" src="https://static.opensuse.org/favicon.ico" /> openSUSE | Leap 15.6, Tumbleweed (滚动) | 512 MB \* | 5 GB |
59+
| <img width="16" height="16" src="https://static.opensuse.org/favicon.ico" /> openSUSE | Leap 15.6, 16.0, Tumbleweed (滚动) | 512 MB \* | 5 GB |
6060
| <img width="16" height="16" src="https://nixos.org/favicon.svg" /> NixOS | 25.05 | 512 MB | 5 GB |
6161
| <img width="16" height="16" src="https://archlinux.org/static/favicon.png" /> Arch | 滚动 | 512 MB | 5 GB |
6262
| <img width="16" height="16" src="https://www.gentoo.org/assets/img/logo/gentoo-g.png" /> Gentoo | 滚动 | 512 MB | 5 GB |
@@ -162,8 +162,8 @@ bash reinstall.sh anolis 7|8|23
162162
fedora 41|42
163163
nixos 25.05
164164
debian 9|10|11|12|13
165-
opensuse 15.6|tumbleweed
166165
alpine 3.19|3.20|3.21|3.22
166+
opensuse 15.6|16.0|tumbleweed
167167
openeuler 20.03|22.03|24.03|25.09
168168
ubuntu 16.04|18.04|20.04|22.04|24.04|25.10 [--minimal]
169169
kali
@@ -547,6 +547,19 @@ Windows Server 2025 SERVERDATACENTER
547547
- `--ssh-key /path/to/public_key`
548548
- `--ssh-key C:\path\to\public_key`
549549

550+
## 如何使用旧版本
551+
552+
根据 Bug 守恒定律,修复旧 Bug 的同时会引入新的 Bug
553+
如果遇到这种情况,可以尝试使用旧版本
554+
<https://github.com/bin456789/reinstall/commits/main> 右侧找到旧版本的 `commit_id`
555+
556+
```bash
557+
commit_id=xxxxxxx
558+
curl -O https://raw.githubusercontent.com/bin456789/reinstall/$commit_id/reinstall.sh || wget -O ${_##*/} $_
559+
sed -i "/^confhome.*main$/s/main/$commit_id/" reinstall.sh
560+
bash reinstall.sh ...
561+
```
562+
550563
## 如何修改脚本自用
551564

552565
1. Fork 本仓库

reinstall.sh

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@ Usage: $reinstall_____ anolis 7|8|23
5454
fedora 41|42
5555
nixos 25.05
5656
debian 9|10|11|12|13
57-
opensuse 15.6|tumbleweed
5857
alpine 3.19|3.20|3.21|3.22
58+
opensuse 15.6|16.0|tumbleweed
5959
openeuler 20.03|22.03|24.03|25.09
60-
ubuntu 16.04|18.04|20.04|22.04|24.04|25.04 [--minimal]
60+
ubuntu 16.04|18.04|20.04|22.04|24.04|25.10 [--minimal]
6161
kali
6262
arch
6363
gentoo
@@ -1436,26 +1436,17 @@ Continue?
14361436
else
14371437
# leap
14381438
dir=distribution/leap/$releasever/appliances
1439-
if [ "$releasever" = 15.6 ]; then
1440-
file=openSUSE-Leap-$releasever-Minimal-VM.$basearch-Cloud.qcow2
1441-
# https://build.opensuse.org/projects/Virtualization:Appliances:Images:openSUSE-Leap-15.6/packages/kiwi-templates-Minimal/files/Minimal.kiwi
1442-
# https://build.opensuse.org/projects/Virtualization:Appliances:Images:openSUSE-Tumbleweed/packages/kiwi-templates-Minimal/files/Minimal.kiwi
1443-
# 有专门的kvm镜像,openSUSE-Leap-15.5-Minimal-VM.x86_64-kvm-and-xen.qcow2,里面没有cloud-init
1444-
# file=openSUSE-Leap-15.5-Minimal-VM.x86_64-kvm-and-xen.qcow2
1445-
else
1446-
# https://src.opensuse.org/openSUSE/Leap/raw/branch/16.0/Leap/Leap.kiwi
1447-
# Default 比 Base 多了以下组件
1448-
# <namedCollection name="salt_minion" />
1449-
# <package name="patterns-base-salt_minion" />
1450-
# <namedCollection name="kvm_host" />
1451-
# <package name="patterns-base-kvm_host" />
1452-
# <package name="lzop" />
1453-
# <package name="wpa_supplicant" arch="x86_64,aarch64" />
1454-
# <package name="k3s-install" />
1455-
1456-
# file=Leap.x86_64-Default.raw.xz
1457-
file=Leap.x86_64-Base.raw.xz
1458-
fi
1439+
case "$releasever" in
1440+
15.6) file=openSUSE-Leap-$releasever-Minimal-VM.$basearch-Cloud.qcow2 ;;
1441+
# 16.0) file=Leap-$releasever-Minimal-VM.$basearch-Cloud.qcow2 ;; # 缺少 openSUSE-repos-Leap 包,导致没有源
1442+
16.0) file=Leap-$releasever-Minimal-VM.$basearch-kvm$(if [ "$basearch" = x86 ]; then echo '-and-xen'; fi).qcow2 ;;
1443+
esac
1444+
1445+
# https://src.opensuse.org/openSUSE/Leap-Images/src/branch/leap-16.0/kiwi-templates-Minimal/Minimal.kiwi
1446+
# https://build.opensuse.org/projects/Virtualization:Appliances:Images:openSUSE-Leap-15.6/packages/kiwi-templates-Minimal/files/Minimal.kiwi
1447+
# https://build.opensuse.org/projects/Virtualization:Appliances:Images:openSUSE-Tumbleweed/packages/kiwi-templates-Minimal/files/Minimal.kiwi
1448+
# 有专门的kvm镜像,openSUSE-Leap-15.5-Minimal-VM.x86_64-kvm-and-xen.qcow2,里面没有cloud-init
1449+
# file=openSUSE-Leap-15.5-Minimal-VM.x86_64-kvm-and-xen.qcow2
14591450
fi
14601451
eval ${step}_img=$mirror/$dir/$file
14611452
}

trans.sh

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3277,6 +3277,9 @@ disable_jeos_firstboot() {
32773277
# 服务不存在时会报错
32783278
chroot $os_dir systemctl disable "$name.service" 2>/dev/null || true
32793279
done
3280+
3281+
# 可选
3282+
# chroot $os_dir zypper remove -y -u jeos-firstboot
32803283
}
32813284

32823285
create_network_manager_config() {
@@ -3544,7 +3547,7 @@ EOF
35443547
fi
35453548

35463549
# opensuse
3547-
# 1. kernel-default-base 缺少 nvme 驱动,换成 kernel-default
3550+
# 1. kernel-default-base 缺少 nvme gve mlx5 mana 驱动,换成 kernel-default
35483551
# 2. 添加微码+固件
35493552
# https://documentation.suse.com/smart/virtualization-cloud/html/minimal-vm/index.html
35503553
if grep -q opensuse $os_dir/etc/os-release; then
@@ -3556,11 +3559,6 @@ EOF
35563559

35573560
disable_jeos_firstboot $os_dir
35583561

3559-
# 16.0 需要安装 openssh
3560-
if ! chroot $os_dir rpm -qi openssh-server; then
3561-
chroot $os_dir zypper install -y openssh-server
3562-
fi
3563-
35643562
# 禁用 selinux
35653563
disable_selinux $os_dir
35663564

@@ -3634,23 +3632,19 @@ EOF
36343632
error_and_exit "Unexpected kernel installed: $installed_kernel"
36353633
fi
36363634

3637-
# 15.6 / tumbleweed 自带的是 kernel-default-base
3638-
# 16.0 自带的是 kernel-default
36393635
# 不能同时装 kernel-default-base 和 kernel-default
3640-
3636+
# 因此需要添加 --force-resolution 自动删除 kernel-default-base
36413637
if ! [ "$installed_kernel" = "$target_kernel" ]; then
3642-
chroot $os_dir zypper remove -y -u $installed_kernel
3643-
36443638
# x86 必须设置一个密码,否则报错,arm 没有这个问题
36453639
# Failed to get root password hash
36463640
# Failed to import /etc/uefi/certs/76B6A6A0.crt
36473641
# warning: %post(kernel-default-5.14.21-150500.55.83.1.x86_64) scriptlet failed, exit status 255
36483642
if grep -q '^root:[:!*]' $os_dir/etc/shadow; then
36493643
echo "root:$(mkpasswd '')" | chroot $os_dir chpasswd -e
3650-
chroot $os_dir zypper install -y $target_kernel
3644+
chroot $os_dir zypper install -y --force-resolution $target_kernel
36513645
chroot $os_dir passwd -d root
36523646
else
3653-
chroot $os_dir zypper install -y $target_kernel
3647+
chroot $os_dir zypper install -y --force-resolution $target_kernel
36543648
fi
36553649
fi
36563650

@@ -3861,23 +3855,22 @@ change_ssh_conf() {
38613855
value=$3
38623856
sub_conf=$4
38633857

3864-
if line="^$key .*" && grep -Exq "$line" $os_dir/etc/ssh/sshd_config; then
3858+
if line="^$key .*" && grep -Exq "$line" $os_dir/etc/ssh/sshd_config 2>/dev/null; then
38653859
# 如果 sshd_config 存在此 key(非注释状态),则替换
38663860
sed -Ei "s/$line/$key $value/" $os_dir/etc/ssh/sshd_config
3867-
elif {
3861+
elif include_line='^Include.*/etc/ssh/sshd_config.d' &&
38683862
# arch 没有 /etc/ssh/sshd_config.d/ 文件夹
38693863
# opensuse tumbleweed 没有 /etc/ssh/sshd_config
38703864
# 有 /etc/ssh/sshd_config.d/ 文件夹
38713865
# 有 /usr/etc/ssh/sshd_config
3872-
grep -q 'Include.*/etc/ssh/sshd_config.d' $os_dir/etc/ssh/sshd_config ||
3873-
grep -q '^Include.*/etc/ssh/sshd_config.d/' $os_dir/usr/etc/ssh/sshd_config
3874-
} 2>/dev/null; then
3866+
{ grep -q "$include_line" $os_dir/etc/ssh/sshd_config ||
3867+
grep -q "$include_line" $os_dir/usr/etc/ssh/sshd_config; } 2>/dev/null; then
38753868
mkdir -p $os_dir/etc/ssh/sshd_config.d/
38763869
echo "$key $value" >"$os_dir/etc/ssh/sshd_config.d/$sub_conf"
38773870
else
38783871
# 如果 sshd_config 存在此 key (无论是否已注释),则替换,包括删除注释
38793872
# 否则追加
3880-
line="^#?$key .*"
3873+
line="^[# ]*$key .*"
38813874
if grep -Exq "$line" $os_dir/etc/ssh/sshd_config; then
38823875
sed -Ei "s/$line/$key $value/" $os_dir/etc/ssh/sshd_config
38833876
else
@@ -3894,7 +3887,17 @@ allow_password_login() {
38943887
allow_root_password_login() {
38953888
os_dir=$1
38963889

3897-
change_ssh_conf "$os_dir" PermitRootLogin yes 01-permitrootlogin.conf
3890+
# opensuse 16/tumbleweed 安装 openssh-server-config-rootlogin
3891+
# 会生成 /usr/etc/ssh/sshd_config.d/50-permit-root-login.conf
3892+
# 但是如果用户删除了此文件,包有更新的话,可能会重新创建这个文件?
3893+
# 因此先不用这个方法
3894+
if false && [ -f $os_dir/etc/os-release ] &&
3895+
grep -iq opensuse $os_dir/etc/os-release &&
3896+
! grep -iq 15.6 $os_dir/etc/os-release; then
3897+
chroot $os_dir zypper install -y openssh-server-config-rootlogin
3898+
else
3899+
change_ssh_conf "$os_dir" PermitRootLogin yes 01-permitrootlogin.conf
3900+
fi
38983901
}
38993902

39003903
change_ssh_port() {

0 commit comments

Comments
 (0)