mirror of
https://github.com/bin456789/reinstall.git
synced 2025-12-10 15:37:43 +08:00
Compare commits
17 Commits
0592789fbf
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| e60a8d0de2 | |||
| 2a561f0d8c | |||
| 586eb5dee1 | |||
| c94f334663 | |||
| bd5e118570 | |||
| 78ba0690f9 | |||
| 9e0968eabd | |||
| 3263ea3875 | |||
| 7c19559d86 | |||
| 8b838f8871 | |||
| 5bf00edeed | |||
| 85637edc5b | |||
| baa430eb10 | |||
| 66f3173c7b | |||
| af84ac0b3c | |||
| 57a88a6bd9 | |||
| 24a4446a02 |
12
README.en.md
12
README.en.md
@ -46,7 +46,7 @@ The system requirements for the target system are as follows:
|
|||||||
|
|
||||||
| System | Version | Memory | Disk |
|
| System | Version | Memory | Disk |
|
||||||
| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------- | --------- | ---------------- |
|
| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------- | --------- | ---------------- |
|
||||||
| <img width="16" height="16" src="https://www.alpinelinux.org/alpine-logo.ico" /> Alpine | 3.19, 3.20, 3.21, 3.22 | 256 MB | 1 GB |
|
| <img width="16" height="16" src="https://www.alpinelinux.org/alpine-logo.ico" /> Alpine | 3.20, 3.21, 3.22, 3.23 | 256 MB | 1 GB |
|
||||||
| <img width="16" height="16" src="https://www.debian.org/favicon.ico" /> Debian | 9, 10, 11, 12, 13 | 256 MB | 1 ~ 1.5 GB ^ |
|
| <img width="16" height="16" src="https://www.debian.org/favicon.ico" /> Debian | 9, 10, 11, 12, 13 | 256 MB | 1 ~ 1.5 GB ^ |
|
||||||
| <img width="16" height="16" src="https://github.com/bin456789/reinstall/assets/7548515/f74b3d5b-085f-4df3-bcc9-8a9bd80bb16d" /> Kali | Rolling | 256 MB | 1 ~ 1.5 GB ^ |
|
| <img width="16" height="16" src="https://github.com/bin456789/reinstall/assets/7548515/f74b3d5b-085f-4df3-bcc9-8a9bd80bb16d" /> Kali | Rolling | 256 MB | 1 ~ 1.5 GB ^ |
|
||||||
| <img width="16" height="16" src="https://documentation.ubuntu.com/server/_static/favicon.png" /> Ubuntu | 16.04 LTS - 24.04 LTS, 25.10 | 512 MB \* | 2 GB |
|
| <img width="16" height="16" src="https://documentation.ubuntu.com/server/_static/favicon.png" /> Ubuntu | 16.04 LTS - 24.04 LTS, 25.10 | 512 MB \* | 2 GB |
|
||||||
@ -57,11 +57,11 @@ The system requirements for the target system are as follows:
|
|||||||
| <img width="16" height="16" src="https://fedoraproject.org/favicon.ico" /> Fedora | 42, 43 | 512 MB \* | 5 GB |
|
| <img width="16" height="16" src="https://fedoraproject.org/favicon.ico" /> Fedora | 42, 43 | 512 MB \* | 5 GB |
|
||||||
| <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 |
|
| <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 |
|
||||||
| <img width="16" height="16" src="https://static.opensuse.org/favicon.ico" /> openSUSE | Leap 15.6, 16.0, Tumbleweed (Rolling) | 512 MB \* | 5 GB |
|
| <img width="16" height="16" src="https://static.opensuse.org/favicon.ico" /> openSUSE | Leap 15.6, 16.0, Tumbleweed (Rolling) | 512 MB \* | 5 GB |
|
||||||
| <img width="16" height="16" src="https://nixos.org/favicon.svg" /> NixOS | 25.05 | 512 MB | 5 GB |
|
| <img width="16" height="16" src="https://nixos.org/favicon.svg" /> NixOS | 25.11 | 512 MB | 5 GB |
|
||||||
| <img width="16" height="16" src="https://archlinux.org/static/favicon.png" /> Arch | Rolling | 512 MB | 5 GB |
|
| <img width="16" height="16" src="https://archlinux.org/static/favicon.png" /> Arch | Rolling | 512 MB | 5 GB |
|
||||||
| <img width="16" height="16" src="https://www.gentoo.org/assets/img/logo/gentoo-g.png" /> Gentoo | Rolling | 512 MB | 5 GB |
|
| <img width="16" height="16" src="https://www.gentoo.org/assets/img/logo/gentoo-g.png" /> Gentoo | Rolling | 512 MB | 5 GB |
|
||||||
| <img width="16" height="16" src="https://aosc.io/distros/aosc-os.svg" /> AOSC OS | Rolling | 512 MB | 5 GB |
|
| <img width="16" height="16" src="https://aosc.io/distros/aosc-os.svg" /> AOSC OS | Rolling | 512 MB | 5 GB |
|
||||||
| <img width="16" height="16" src="https://www.fnnas.com/favicon.ico" /> fnOS | Beta | 512 MB | 8 GB |
|
| <img width="16" height="16" src="https://www.fnnas.com/favicon.ico" /> fnOS | 1 | 512 MB | 8 GB |
|
||||||
| <img width="16" height="16" src="https://blogs.windows.com/wp-content/uploads/prod/2022/09/cropped-Windows11IconTransparent512-32x32.png" /> Windows (DD) | Any | 512 MB | Depends on image |
|
| <img width="16" height="16" src="https://blogs.windows.com/wp-content/uploads/prod/2022/09/cropped-Windows11IconTransparent512-32x32.png" /> Windows (DD) | Any | 512 MB | Depends on image |
|
||||||
| <img width="16" height="16" src="https://blogs.windows.com/wp-content/uploads/prod/2022/09/cropped-Windows11IconTransparent512-32x32.png" /> Windows (ISO) | Vista, 7, 8.x (Server 2008 - 2012 R2) | 512 MB | 25 GB |
|
| <img width="16" height="16" src="https://blogs.windows.com/wp-content/uploads/prod/2022/09/cropped-Windows11IconTransparent512-32x32.png" /> Windows (ISO) | Vista, 7, 8.x (Server 2008 - 2012 R2) | 512 MB | 25 GB |
|
||||||
| <img width="16" height="16" src="https://blogs.windows.com/wp-content/uploads/prod/2022/09/cropped-Windows11IconTransparent512-32x32.png" /> Windows (ISO) | 10, 11 (Server 2016 - 2025) | 1 GB | 25 GB |
|
| <img width="16" height="16" src="https://blogs.windows.com/wp-content/uploads/prod/2022/09/cropped-Windows11IconTransparent512-32x32.png" /> Windows (ISO) | 10, 11 (Server 2016 - 2025) | 1 GB | 25 GB |
|
||||||
@ -159,10 +159,11 @@ bash reinstall.sh anolis 7|8|23
|
|||||||
almalinux 8|9|10
|
almalinux 8|9|10
|
||||||
opencloudos 8|9|23
|
opencloudos 8|9|23
|
||||||
centos 9|10
|
centos 9|10
|
||||||
|
fnos 1
|
||||||
|
nixos 25.11
|
||||||
fedora 42|43
|
fedora 42|43
|
||||||
nixos 25.05
|
|
||||||
debian 9|10|11|12|13
|
debian 9|10|11|12|13
|
||||||
alpine 3.19|3.20|3.21|3.22
|
alpine 3.20|3.21|3.22|3.23
|
||||||
opensuse 15.6|16.0|tumbleweed
|
opensuse 15.6|16.0|tumbleweed
|
||||||
openeuler 20.03|22.03|24.03|25.09
|
openeuler 20.03|22.03|24.03|25.09
|
||||||
ubuntu 16.04|18.04|20.04|22.04|24.04|25.10 [--minimal]
|
ubuntu 16.04|18.04|20.04|22.04|24.04|25.10 [--minimal]
|
||||||
@ -170,7 +171,6 @@ bash reinstall.sh anolis 7|8|23
|
|||||||
arch
|
arch
|
||||||
gentoo
|
gentoo
|
||||||
aosc
|
aosc
|
||||||
fnos
|
|
||||||
redhat --img="http://access.cdn.redhat.com/xxx.qcow2"
|
redhat --img="http://access.cdn.redhat.com/xxx.qcow2"
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
12
README.md
12
README.md
@ -46,7 +46,7 @@
|
|||||||
|
|
||||||
| 系统 | 版本 | 内存 | 硬盘 |
|
| 系统 | 版本 | 内存 | 硬盘 |
|
||||||
| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------- | --------- | ------------ |
|
| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------- | --------- | ------------ |
|
||||||
| <img width="16" height="16" src="https://www.alpinelinux.org/alpine-logo.ico" /> Alpine | 3.19, 3.20, 3.21, 3.22 | 256 MB | 1 GB |
|
| <img width="16" height="16" src="https://www.alpinelinux.org/alpine-logo.ico" /> Alpine | 3.20, 3.21, 3.22, 3.23 | 256 MB | 1 GB |
|
||||||
| <img width="16" height="16" src="https://www.debian.org/favicon.ico" /> Debian | 9, 10, 11, 12, 13 | 256 MB | 1 ~ 1.5 GB ^ |
|
| <img width="16" height="16" src="https://www.debian.org/favicon.ico" /> Debian | 9, 10, 11, 12, 13 | 256 MB | 1 ~ 1.5 GB ^ |
|
||||||
| <img width="16" height="16" src="https://github.com/bin456789/reinstall/assets/7548515/f74b3d5b-085f-4df3-bcc9-8a9bd80bb16d" /> Kali | 滚动 | 256 MB | 1 ~ 1.5 GB ^ |
|
| <img width="16" height="16" src="https://github.com/bin456789/reinstall/assets/7548515/f74b3d5b-085f-4df3-bcc9-8a9bd80bb16d" /> Kali | 滚动 | 256 MB | 1 ~ 1.5 GB ^ |
|
||||||
| <img width="16" height="16" src="https://documentation.ubuntu.com/server/_static/favicon.png" /> Ubuntu | 16.04 LTS - 24.04 LTS, 25.10 | 512 MB \* | 2 GB |
|
| <img width="16" height="16" src="https://documentation.ubuntu.com/server/_static/favicon.png" /> Ubuntu | 16.04 LTS - 24.04 LTS, 25.10 | 512 MB \* | 2 GB |
|
||||||
@ -57,11 +57,11 @@
|
|||||||
| <img width="16" height="16" src="https://fedoraproject.org/favicon.ico" /> Fedora | 42, 43 | 512 MB \* | 5 GB |
|
| <img width="16" height="16" src="https://fedoraproject.org/favicon.ico" /> Fedora | 42, 43 | 512 MB \* | 5 GB |
|
||||||
| <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 |
|
| <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 |
|
||||||
| <img width="16" height="16" src="https://static.opensuse.org/favicon.ico" /> openSUSE | Leap 15.6, 16.0, Tumbleweed (滚动) | 512 MB \* | 5 GB |
|
| <img width="16" height="16" src="https://static.opensuse.org/favicon.ico" /> openSUSE | Leap 15.6, 16.0, Tumbleweed (滚动) | 512 MB \* | 5 GB |
|
||||||
| <img width="16" height="16" src="https://nixos.org/favicon.svg" /> NixOS | 25.05 | 512 MB | 5 GB |
|
| <img width="16" height="16" src="https://nixos.org/favicon.svg" /> NixOS | 25.11 | 512 MB | 5 GB |
|
||||||
| <img width="16" height="16" src="https://archlinux.org/static/favicon.png" /> Arch | 滚动 | 512 MB | 5 GB |
|
| <img width="16" height="16" src="https://archlinux.org/static/favicon.png" /> Arch | 滚动 | 512 MB | 5 GB |
|
||||||
| <img width="16" height="16" src="https://www.gentoo.org/assets/img/logo/gentoo-g.png" /> Gentoo | 滚动 | 512 MB | 5 GB |
|
| <img width="16" height="16" src="https://www.gentoo.org/assets/img/logo/gentoo-g.png" /> Gentoo | 滚动 | 512 MB | 5 GB |
|
||||||
| <img width="16" height="16" src="https://aosc.io/distros/aosc-os.svg" /> 安同 OS | 滚动 | 512 MB | 5 GB |
|
| <img width="16" height="16" src="https://aosc.io/distros/aosc-os.svg" /> 安同 OS | 滚动 | 512 MB | 5 GB |
|
||||||
| <img width="16" height="16" src="https://www.fnnas.com/favicon.ico" /> 飞牛 fnOS | 公测 | 512 MB | 8 GB |
|
| <img width="16" height="16" src="https://www.fnnas.com/favicon.ico" /> 飞牛 fnOS | 1 | 512 MB | 8 GB |
|
||||||
| <img width="16" height="16" src="https://blogs.windows.com/wp-content/uploads/prod/2022/09/cropped-Windows11IconTransparent512-32x32.png" /> Windows (DD) | 任何 | 512 MB | 取决于镜像 |
|
| <img width="16" height="16" src="https://blogs.windows.com/wp-content/uploads/prod/2022/09/cropped-Windows11IconTransparent512-32x32.png" /> Windows (DD) | 任何 | 512 MB | 取决于镜像 |
|
||||||
| <img width="16" height="16" src="https://blogs.windows.com/wp-content/uploads/prod/2022/09/cropped-Windows11IconTransparent512-32x32.png" /> Windows (ISO) | Vista, 7, 8.x (Server 2008 - 2012 R2) | 512 MB | 25 GB |
|
| <img width="16" height="16" src="https://blogs.windows.com/wp-content/uploads/prod/2022/09/cropped-Windows11IconTransparent512-32x32.png" /> Windows (ISO) | Vista, 7, 8.x (Server 2008 - 2012 R2) | 512 MB | 25 GB |
|
||||||
| <img width="16" height="16" src="https://blogs.windows.com/wp-content/uploads/prod/2022/09/cropped-Windows11IconTransparent512-32x32.png" /> Windows (ISO) | 10, 11 (Server 2016 - 2025) | 1 GB | 25 GB |
|
| <img width="16" height="16" src="https://blogs.windows.com/wp-content/uploads/prod/2022/09/cropped-Windows11IconTransparent512-32x32.png" /> Windows (ISO) | 10, 11 (Server 2016 - 2025) | 1 GB | 25 GB |
|
||||||
@ -159,10 +159,11 @@ bash reinstall.sh anolis 7|8|23
|
|||||||
almalinux 8|9|10
|
almalinux 8|9|10
|
||||||
opencloudos 8|9|23
|
opencloudos 8|9|23
|
||||||
centos 9|10
|
centos 9|10
|
||||||
|
fnos 1
|
||||||
|
nixos 25.11
|
||||||
fedora 42|43
|
fedora 42|43
|
||||||
nixos 25.05
|
|
||||||
debian 9|10|11|12|13
|
debian 9|10|11|12|13
|
||||||
alpine 3.19|3.20|3.21|3.22
|
alpine 3.20|3.21|3.22|3.23
|
||||||
opensuse 15.6|16.0|tumbleweed
|
opensuse 15.6|16.0|tumbleweed
|
||||||
openeuler 20.03|22.03|24.03|25.09
|
openeuler 20.03|22.03|24.03|25.09
|
||||||
ubuntu 16.04|18.04|20.04|22.04|24.04|25.10 [--minimal]
|
ubuntu 16.04|18.04|20.04|22.04|24.04|25.10 [--minimal]
|
||||||
@ -170,7 +171,6 @@ bash reinstall.sh anolis 7|8|23
|
|||||||
arch
|
arch
|
||||||
gentoo
|
gentoo
|
||||||
aosc
|
aosc
|
||||||
fnos
|
|
||||||
redhat --img="http://access.cdn.redhat.com/xxx.qcow2"
|
redhat --img="http://access.cdn.redhat.com/xxx.qcow2"
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@ -48,21 +48,40 @@ retry() {
|
|||||||
# 用 systemd-analyze plot >a.svg 发现 sys-subsystem-net-devices-enp3s0.device 也是出现在 NetworkManager 之后
|
# 用 systemd-analyze plot >a.svg 发现 sys-subsystem-net-devices-enp3s0.device 也是出现在 NetworkManager 之后
|
||||||
# 因此需要等待网卡出现
|
# 因此需要等待网卡出现
|
||||||
get_ethx_by_mac() {
|
get_ethx_by_mac() {
|
||||||
mac=$(echo "$1" | to_lower)
|
retry 10 _get_ethx_by_mac "$@"
|
||||||
retry 10 _get_ethx_by_mac "$mac"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_get_ethx_by_mac() {
|
_get_ethx_by_mac() {
|
||||||
|
mac=$(echo "$1" | to_lower)
|
||||||
|
|
||||||
|
flag=$2
|
||||||
|
if [ -z "$flag" ]; then
|
||||||
|
flag=master
|
||||||
|
fi
|
||||||
|
|
||||||
if true; then
|
if true; then
|
||||||
|
if [ "$flag" = master ]; then
|
||||||
|
# master
|
||||||
# 过滤 azure vf (带 master ethx)
|
# 过滤 azure vf (带 master ethx)
|
||||||
ip -o link | grep -i "$mac" | grep -v master | awk '{print $2}' | cut -d: -f1 | grep .
|
ip -o link | grep -i "$mac" | grep -v master | awk '{print $2}' | cut -d: -f1 | grep .
|
||||||
return
|
else
|
||||||
|
# slave
|
||||||
|
# 带 master ethx
|
||||||
|
ip -o link | grep -i "$mac" | grep -w master | awk '{print $2}' | cut -d: -f1 | grep .
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
for i in $(cd /sys/class/net && echo *); do
|
for i in $(cd /sys/class/net && echo *); do
|
||||||
if [ "$(cat "/sys/class/net/$i/address")" = "$mac" ]; then
|
if [ "$(cat "/sys/class/net/$i/address")" = "$mac" ]; then
|
||||||
|
if [ $(($(cat "/sys/class/net/$i/flags") & 0x800)) -ne 0 ]; then
|
||||||
|
fact_flag=slave
|
||||||
|
else
|
||||||
|
fact_flag=master
|
||||||
|
fi
|
||||||
|
if [ "$flag" = "$fact_flag" ]; then
|
||||||
echo "$i"
|
echo "$i"
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
@ -138,6 +157,23 @@ fix_network_manager() {
|
|||||||
|
|
||||||
# 更改文件名
|
# 更改文件名
|
||||||
mv "$file" "$proper_file"
|
mv "$file" "$proper_file"
|
||||||
|
|
||||||
|
# NM 不会自动忽略 Azure 的 slave 网卡,需手动设置
|
||||||
|
# azure 文档中的方法不够通用,只适合 azure
|
||||||
|
# https://learn.microsoft.com/zh-cn/azure/virtual-network/accelerated-networking-overview
|
||||||
|
|
||||||
|
# 我们采用红帽的方法
|
||||||
|
# https://docs.redhat.com/en/documentation/red_hat_enterprise_linux/8/html/configuring_and_managing_networking/configuring-networkmanager-to-ignore-certain-devices_configuring-and-managing-networking
|
||||||
|
if slave_ethx=$(get_ethx_by_mac "$mac" slave); then
|
||||||
|
cat >"/etc/NetworkManager/conf.d/99-$slave_ethx-unmanaged.conf" <<EOF
|
||||||
|
[device-$slave_ethx-unmanaged]
|
||||||
|
match-device=interface-name:$slave_ethx
|
||||||
|
managed=0
|
||||||
|
EOF
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 也可以设置 unmanaged-devices, 但是官方文档不推荐
|
||||||
|
# https://networkmanager.pages.freedesktop.org/NetworkManager/NetworkManager/NetworkManager.conf.html#:~:text=may%20be%20a-,better%20choice,-.
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
61
reinstall.sh
61
reinstall.sh
@ -22,6 +22,22 @@ export LC_ALL=C
|
|||||||
# 不要漏了最后的 $PATH,否则会找不到 windows 系统程序例如 diskpart
|
# 不要漏了最后的 $PATH,否则会找不到 windows 系统程序例如 diskpart
|
||||||
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$PATH
|
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$PATH
|
||||||
|
|
||||||
|
# 如果不是 bash 的话,继续执行会有语法错误,因此在这里判断是否 bash
|
||||||
|
if [ -z "$BASH" ]; then
|
||||||
|
if [ -f /etc/alpine-release ]; then
|
||||||
|
if ! apk add bash; then
|
||||||
|
echo "Error while install bash." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
if command -v bash >/dev/null; then
|
||||||
|
exec bash "$0" "$@"
|
||||||
|
else
|
||||||
|
echo "Please run this script with bash." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
# 记录日志,过滤含有 password 的行
|
# 记录日志,过滤含有 password 的行
|
||||||
exec > >(tee >(grep -iv password >>/reinstall.log)) 2>&1
|
exec > >(tee >(grep -iv password >>/reinstall.log)) 2>&1
|
||||||
THIS_SCRIPT=$(readlink -f "$0")
|
THIS_SCRIPT=$(readlink -f "$0")
|
||||||
@ -35,11 +51,6 @@ trap_err() {
|
|||||||
sed -n "$line_no"p "$THIS_SCRIPT"
|
sed -n "$line_no"p "$THIS_SCRIPT"
|
||||||
}
|
}
|
||||||
|
|
||||||
if ! { [ -n "$BASH" ] && [ -n "$BASH_VERSION" ]; }; then
|
|
||||||
echo "Please run this script with bash." >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
usage_and_exit() {
|
usage_and_exit() {
|
||||||
if is_in_windows; then
|
if is_in_windows; then
|
||||||
reinstall_____='.\reinstall.bat'
|
reinstall_____='.\reinstall.bat'
|
||||||
@ -53,10 +64,11 @@ Usage: $reinstall_____ anolis 7|8|23
|
|||||||
oracle 8|9|10
|
oracle 8|9|10
|
||||||
almalinux 8|9|10
|
almalinux 8|9|10
|
||||||
centos 9|10
|
centos 9|10
|
||||||
|
fnos 1
|
||||||
|
nixos 25.11
|
||||||
fedora 42|43
|
fedora 42|43
|
||||||
nixos 25.05
|
|
||||||
debian 9|10|11|12|13
|
debian 9|10|11|12|13
|
||||||
alpine 3.19|3.20|3.21|3.22
|
alpine 3.20|3.21|3.22|3.23
|
||||||
opensuse 15.6|16.0|tumbleweed
|
opensuse 15.6|16.0|tumbleweed
|
||||||
openeuler 20.03|22.03|24.03|25.09
|
openeuler 20.03|22.03|24.03|25.09
|
||||||
ubuntu 16.04|18.04|20.04|22.04|24.04|25.10 [--minimal]
|
ubuntu 16.04|18.04|20.04|22.04|24.04|25.10 [--minimal]
|
||||||
@ -64,7 +76,6 @@ Usage: $reinstall_____ anolis 7|8|23
|
|||||||
arch
|
arch
|
||||||
gentoo
|
gentoo
|
||||||
aosc
|
aosc
|
||||||
fnos
|
|
||||||
redhat --img="http://access.cdn.redhat.com/xxx.qcow2"
|
redhat --img="http://access.cdn.redhat.com/xxx.qcow2"
|
||||||
dd --img="http://xxx.com/yyy.zzz" (raw image stores in raw/vhd/tar/gz/xz/zst)
|
dd --img="http://xxx.com/yyy.zzz" (raw image stores in raw/vhd/tar/gz/xz/zst)
|
||||||
windows --image-name="windows xxx yyy" --lang=xx-yy
|
windows --image-name="windows xxx yyy" --lang=xx-yy
|
||||||
@ -859,7 +870,7 @@ is_have_arm_version() {
|
|||||||
|
|
||||||
find_windows_iso() {
|
find_windows_iso() {
|
||||||
parse_windows_image_name || error_and_exit "--image-name wrong: $image_name"
|
parse_windows_image_name || error_and_exit "--image-name wrong: $image_name"
|
||||||
if ! [ "$version" = 8.1 ] && [ -z "$edition" ]; then
|
if ! { [ "$version" = 8 ] || [ "$version" = 8.1 ]; } && [ -z "$edition" ]; then
|
||||||
error_and_exit "Edition is not set."
|
error_and_exit "Edition is not set."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -908,7 +919,8 @@ get_windows_iso_link() {
|
|||||||
x86) echo _ ;;
|
x86) echo _ ;;
|
||||||
esac
|
esac
|
||||||
;;
|
;;
|
||||||
homebasic | homepremium | business | ultimate) echo _ ;;
|
homebasic | homepremium | ultimate) echo _ ;;
|
||||||
|
business | enterprise) echo "$edition" ;;
|
||||||
esac
|
esac
|
||||||
;;
|
;;
|
||||||
7)
|
7)
|
||||||
@ -927,10 +939,9 @@ get_windows_iso_link() {
|
|||||||
professional | enterprise | ultimate) echo "$edition" ;;
|
professional | enterprise | ultimate) echo "$edition" ;;
|
||||||
esac
|
esac
|
||||||
;;
|
;;
|
||||||
# massgrave 不提供 windows 8 下载
|
8 | 8.1)
|
||||||
8.1)
|
|
||||||
case "$edition" in
|
case "$edition" in
|
||||||
'') echo _ ;; # windows 8.1 core
|
'') echo _ ;; # windows 8.x core
|
||||||
pro | enterprise) echo "$edition" ;;
|
pro | enterprise) echo "$edition" ;;
|
||||||
esac
|
esac
|
||||||
;;
|
;;
|
||||||
@ -1025,7 +1036,7 @@ get_windows_iso_link() {
|
|||||||
echo server
|
echo server
|
||||||
else
|
else
|
||||||
case "$version" in
|
case "$version" in
|
||||||
vista | 7 | 8.1 | 10 | 11)
|
vista | 7 | 8 | 8.1 | 10 | 11)
|
||||||
echo "$version"
|
echo "$version"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
@ -1487,8 +1498,8 @@ Continue?
|
|||||||
dir=distribution/leap/$releasever/appliances
|
dir=distribution/leap/$releasever/appliances
|
||||||
case "$releasever" in
|
case "$releasever" in
|
||||||
15.6) file=openSUSE-Leap-$releasever-Minimal-VM.$basearch-Cloud.qcow2 ;;
|
15.6) file=openSUSE-Leap-$releasever-Minimal-VM.$basearch-Cloud.qcow2 ;;
|
||||||
# 16.0) file=Leap-$releasever-Minimal-VM.$basearch-Cloud.qcow2 ;; # 缺少 openSUSE-repos-Leap 包,导致没有源
|
16.0) file=Leap-$releasever-Minimal-VM.$basearch-Cloud.qcow2 ;;
|
||||||
16.0) file=Leap-$releasever-Minimal-VM.$basearch-kvm$(if [ "$basearch" = x86_64 ]; then echo '-and-xen'; fi).qcow2 ;;
|
# 16.0) file=Leap-$releasever-Minimal-VM.$basearch-kvm$(if [ "$basearch" = x86_64 ]; then echo '-and-xen'; fi).qcow2 ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# https://src.opensuse.org/openSUSE/Leap-Images/src/branch/leap-16.0/kiwi-templates-Minimal/Minimal.kiwi
|
# https://src.opensuse.org/openSUSE/Leap-Images/src/branch/leap-16.0/kiwi-templates-Minimal/Minimal.kiwi
|
||||||
@ -1907,11 +1918,12 @@ verify_os_name() {
|
|||||||
'almalinux 8|9|10' \
|
'almalinux 8|9|10' \
|
||||||
'rocky 8|9|10' \
|
'rocky 8|9|10' \
|
||||||
'oracle 8|9|10' \
|
'oracle 8|9|10' \
|
||||||
|
'fnos 1' \
|
||||||
'fedora 42|43' \
|
'fedora 42|43' \
|
||||||
'nixos 25.05' \
|
'nixos 25.11' \
|
||||||
'debian 9|10|11|12|13' \
|
'debian 9|10|11|12|13' \
|
||||||
'opensuse 15.6|16.0|tumbleweed' \
|
'opensuse 15.6|16.0|tumbleweed' \
|
||||||
'alpine 3.19|3.20|3.21|3.22' \
|
'alpine 3.20|3.21|3.22|3.23' \
|
||||||
'openeuler 20.03|22.03|24.03|25.09' \
|
'openeuler 20.03|22.03|24.03|25.09' \
|
||||||
'ubuntu 16.04|18.04|20.04|22.04|24.04|25.10' \
|
'ubuntu 16.04|18.04|20.04|22.04|24.04|25.10' \
|
||||||
'redhat' \
|
'redhat' \
|
||||||
@ -1919,7 +1931,6 @@ verify_os_name() {
|
|||||||
'arch' \
|
'arch' \
|
||||||
'gentoo' \
|
'gentoo' \
|
||||||
'aosc' \
|
'aosc' \
|
||||||
'fnos' \
|
|
||||||
'windows' \
|
'windows' \
|
||||||
'dd' \
|
'dd' \
|
||||||
'netboot.xyz'; do
|
'netboot.xyz'; do
|
||||||
@ -2343,10 +2354,6 @@ prompt_password() {
|
|||||||
warn false "Leave blank to use a random password."
|
warn false "Leave blank to use a random password."
|
||||||
warn false "不填写则使用随机密码"
|
warn false "不填写则使用随机密码"
|
||||||
while true; do
|
while true; do
|
||||||
# 特殊字符列表
|
|
||||||
# https://learn.microsoft.com/previous-versions/windows/it-pro/windows-server-2012-r2-and-2012/hh994562(v=ws.11)
|
|
||||||
chars=\''A-Za-z0-9~!@#$%^&*_=+`|(){}[]:;"<>,.?/-'
|
|
||||||
random_password=$(tr -dc "$chars" </dev/random | head -c16)
|
|
||||||
IFS= read -r -p "Password: " password
|
IFS= read -r -p "Password: " password
|
||||||
if [ -n "$password" ]; then
|
if [ -n "$password" ]; then
|
||||||
IFS= read -r -p "Retype password: " password_confirm
|
IFS= read -r -p "Retype password: " password_confirm
|
||||||
@ -2356,7 +2363,11 @@ prompt_password() {
|
|||||||
error "Passwords don't match. Try again."
|
error "Passwords don't match. Try again."
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
password=$random_password
|
# 特殊字符列表
|
||||||
|
# https://learn.microsoft.com/previous-versions/windows/it-pro/windows-server-2012-r2-and-2012/hh994562(v=ws.11)
|
||||||
|
# 有的机器运行 centos 7 ,用 /dev/random 产生 16 位密码,开启了 rngd 也要 5 秒,关闭了 rngd 则长期阻塞
|
||||||
|
chars=\''A-Za-z0-9~!@#$%^&*_=+`|(){}[]:;"<>,.?/-'
|
||||||
|
password=$(tr -dc "$chars" </dev/urandom | head -c16)
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
@ -4004,7 +4015,7 @@ EOF
|
|||||||
|
|
||||||
# https://manpages.debian.org/testing/openssh-server/authorized_keys.5.en.html#AUTHORIZED_KEYS_FILE_FORMAT
|
# https://manpages.debian.org/testing/openssh-server/authorized_keys.5.en.html#AUTHORIZED_KEYS_FILE_FORMAT
|
||||||
is_valid_ssh_key() {
|
is_valid_ssh_key() {
|
||||||
grep -qE '^(ecdsa-sha2-nistp(256|384|512)|ssh-(ed25519|rsa)) ' <<<"$1"
|
grep -qE '^(ecdsa-sha2-nistp(256|384|521)|ssh-(ed25519|rsa)) ' <<<"$1"
|
||||||
}
|
}
|
||||||
|
|
||||||
[ -n "$2" ] || ssh_key_error_and_exit "Need value for $1"
|
[ -n "$2" ] || ssh_key_error_and_exit "Need value for $1"
|
||||||
|
|||||||
61
trans.sh
61
trans.sh
@ -1630,9 +1630,9 @@ install_nixos() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# 备用方案
|
# 备用方案
|
||||||
# 1. 从 https://mirror.nju.edu.cn/nix-channels/nixos-25.05/nixexprs.tar.xz 获取
|
# 1. 从 https://mirror.nju.edu.cn/nix-channels/nixos-25.11/nixexprs.tar.xz 获取
|
||||||
# https://github.com/NixOS/nixpkgs/blob/nixos-25.05/pkgs/tools/package-management/nix/default.nix
|
# https://github.com/NixOS/nixpkgs/blob/nixos-25.11/pkgs/tools/package-management/nix/default.nix
|
||||||
# https://github.com/NixOS/nixpkgs/blob/nixos-25.05/nixos/modules/installer/tools/nix-fallback-paths.nix
|
# https://github.com/NixOS/nixpkgs/blob/nixos-25.11/nixos/modules/installer/tools/nix-fallback-paths.nix
|
||||||
# 2. 安装最新版 nix,添加 nixos channel 后获取
|
# 2. 安装最新版 nix,添加 nixos channel 后获取
|
||||||
# nix eval -f '<nixpkgs>' --raw 'nixVersions.stable.version' --extra-experimental-features nix-command
|
# nix eval -f '<nixpkgs>' --raw 'nixVersions.stable.version' --extra-experimental-features nix-command
|
||||||
|
|
||||||
@ -1868,8 +1868,11 @@ add_frpc_systemd_service_if_need() {
|
|||||||
# 下载 frpc
|
# 下载 frpc
|
||||||
# 注意下载的 frpc owner 不是 root:root
|
# 注意下载的 frpc owner 不是 root:root
|
||||||
frpc_url=$(get_frpc_url linux)
|
frpc_url=$(get_frpc_url linux)
|
||||||
|
basename=$(echo "$frpc_url" | awk -F/ '{print $NF}' | sed 's/\.tar\.gz//')
|
||||||
download "$frpc_url" "$os_dir/frpc.tar.gz"
|
download "$frpc_url" "$os_dir/frpc.tar.gz"
|
||||||
tar xzf "$os_dir/frpc.tar.gz" "*/frpc" -O >"$os_dir/usr/local/bin/frpc"
|
# busybox tar 不支持 wildcard
|
||||||
|
# tar: */frpc: not found in archive
|
||||||
|
tar xzf "$os_dir/frpc.tar.gz" "$basename/frpc" -O >"$os_dir/usr/local/bin/frpc"
|
||||||
rm -f "$os_dir/frpc.tar.gz"
|
rm -f "$os_dir/frpc.tar.gz"
|
||||||
chmod a+x "$os_dir/usr/local/bin/frpc"
|
chmod a+x "$os_dir/usr/local/bin/frpc"
|
||||||
|
|
||||||
@ -2753,14 +2756,6 @@ mount_pseudo_fs() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
get_yq_name() {
|
|
||||||
if grep -q '3\.1[6789]' /etc/alpine-release; then
|
|
||||||
echo yq
|
|
||||||
else
|
|
||||||
echo yq-go
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
create_cloud_init_network_config() {
|
create_cloud_init_network_config() {
|
||||||
ci_file=$1
|
ci_file=$1
|
||||||
recognize_static6=${2:-true}
|
recognize_static6=${2:-true}
|
||||||
@ -2772,7 +2767,7 @@ create_cloud_init_network_config() {
|
|||||||
mkdir -p "$(dirname "$ci_file")"
|
mkdir -p "$(dirname "$ci_file")"
|
||||||
touch "$ci_file"
|
touch "$ci_file"
|
||||||
|
|
||||||
apk add "$(get_yq_name)"
|
apk add yq-go
|
||||||
|
|
||||||
need_set_dns4=false
|
need_set_dns4=false
|
||||||
need_set_dns6=false
|
need_set_dns6=false
|
||||||
@ -2886,7 +2881,7 @@ create_cloud_init_network_config() {
|
|||||||
yq -i "del(.network.config[$config_id] | select(has(\"address\") | not))" $ci_file
|
yq -i "del(.network.config[$config_id] | select(has(\"address\") | not))" $ci_file
|
||||||
fi
|
fi
|
||||||
|
|
||||||
apk del "$(get_yq_name)"
|
apk del yq-go
|
||||||
|
|
||||||
# 查看文件
|
# 查看文件
|
||||||
info "Cloud-init network config"
|
info "Cloud-init network config"
|
||||||
@ -3249,7 +3244,7 @@ remove_cloud_init() {
|
|||||||
# disable 会出现一堆提示信息,也无法 disable
|
# disable 会出现一堆提示信息,也无法 disable
|
||||||
for unit in $(
|
for unit in $(
|
||||||
chroot $os_dir systemctl list-unit-files |
|
chroot $os_dir systemctl list-unit-files |
|
||||||
grep -E '^(cloud-init-.*|cloud-config|cloud-final)\.(service|socket)' | grep enabled | awk '{print $1}'
|
grep -E '^(cloud-init|cloud-init-.*|cloud-config|cloud-final)\.(service|socket)' | grep enabled | awk '{print $1}'
|
||||||
); do
|
); do
|
||||||
# 服务不存在时会报错
|
# 服务不存在时会报错
|
||||||
if chroot $os_dir systemctl -q is-enabled "$unit"; then
|
if chroot $os_dir systemctl -q is-enabled "$unit"; then
|
||||||
@ -3266,7 +3261,7 @@ remove_cloud_init() {
|
|||||||
;;
|
;;
|
||||||
zypper)
|
zypper)
|
||||||
# 加上 -u 才会删除依赖
|
# 加上 -u 才会删除依赖
|
||||||
chroot $os_dir zypper remove -y -u cloud-init
|
chroot $os_dir zypper remove -y -u cloud-init cloud-init-config-suse
|
||||||
;;
|
;;
|
||||||
apt-get)
|
apt-get)
|
||||||
# ubuntu 25.04 开始有 cloud-init-base
|
# ubuntu 25.04 开始有 cloud-init-base
|
||||||
@ -3655,24 +3650,35 @@ EOF
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# rpm -qi 不支持通配符
|
# rpm -qi 不支持通配符
|
||||||
installed_kernel=$(chroot $os_dir rpm -qa 'kernel-*' --qf '%{NAME}\n' | grep -v firmware)
|
origin_kernel=$(chroot $os_dir rpm -qa 'kernel-*' --qf '%{NAME}\n' | grep -v firmware)
|
||||||
if ! [ "$(echo "$installed_kernel" | wc -l)" -eq 1 ]; then
|
if ! [ "$(echo "$origin_kernel" | wc -l)" -eq 1 ]; then
|
||||||
error_and_exit "Unexpected kernel installed: $installed_kernel"
|
error_and_exit "Unexpected kernel installed: $origin_kernel"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# 不能同时装 kernel-default-base 和 kernel-default
|
# 16.0 能同时装 kernel-default-base 和 kernel-default
|
||||||
|
# tw 不能同时装 kernel-default-base 和 kernel-default
|
||||||
# 因此需要添加 --force-resolution 自动删除 kernel-default-base
|
# 因此需要添加 --force-resolution 自动删除 kernel-default-base
|
||||||
if ! [ "$installed_kernel" = "$target_kernel" ]; then
|
if ! [ "$origin_kernel" = "$target_kernel" ]; then
|
||||||
# x86 必须设置一个密码,否则报错,arm 没有这个问题
|
# x86 必须设置一个密码,否则报错,arm 没有这个问题
|
||||||
# Failed to get root password hash
|
# Failed to get root password hash
|
||||||
# Failed to import /etc/uefi/certs/76B6A6A0.crt
|
# Failed to import /etc/uefi/certs/76B6A6A0.crt
|
||||||
# warning: %post(kernel-default-5.14.21-150500.55.83.1.x86_64) scriptlet failed, exit status 255
|
# warning: %post(kernel-default-5.14.21-150500.55.83.1.x86_64) scriptlet failed, exit status 255
|
||||||
|
need_password_workaround=false
|
||||||
if grep -q '^root:[:!*]' $os_dir/etc/shadow; then
|
if grep -q '^root:[:!*]' $os_dir/etc/shadow; then
|
||||||
|
need_password_workaround=true
|
||||||
|
fi
|
||||||
|
|
||||||
|
if $need_password_workaround; then
|
||||||
echo "root:$(mkpasswd '')" | chroot $os_dir chpasswd -e
|
echo "root:$(mkpasswd '')" | chroot $os_dir chpasswd -e
|
||||||
|
fi
|
||||||
|
# 安装新内核
|
||||||
chroot $os_dir zypper install -y --force-resolution $target_kernel
|
chroot $os_dir zypper install -y --force-resolution $target_kernel
|
||||||
|
# 删除旧内核
|
||||||
|
if chroot $os_dir rpm -q $origin_kernel; then
|
||||||
|
chroot $os_dir zypper remove -y --force-resolution $origin_kernel
|
||||||
|
fi
|
||||||
|
if $need_password_workaround; then
|
||||||
chroot $os_dir passwd -d root
|
chroot $os_dir passwd -d root
|
||||||
else
|
|
||||||
chroot $os_dir zypper install -y --force-resolution $target_kernel
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -6612,12 +6618,17 @@ EOF
|
|||||||
done
|
done
|
||||||
|
|
||||||
if ! $is_gen11 && [ "$build_ver" -ge 19041 ]; then
|
if ! $is_gen11 && [ "$build_ver" -ge 19041 ]; then
|
||||||
url=https://downloadmirror.intel.com/865363/SetupRST.exe # RST v20
|
# RST v20
|
||||||
|
local page=https://www.intel.com/content/www/us/en/download/849936.html
|
||||||
elif [ "$build_ver" -ge 15063 ]; then
|
elif [ "$build_ver" -ge 15063 ]; then
|
||||||
url=https://downloadmirror.intel.com/849934/SetupRST.exe # RST v19
|
# RST v19
|
||||||
|
local page=https://www.intel.com/content/www/us/en/download/849933.html
|
||||||
else
|
else
|
||||||
error_and_exit "can't find suitable vmd driver"
|
error_and_exit "can't find suitable vmd driver"
|
||||||
fi
|
fi
|
||||||
|
local url
|
||||||
|
url=$(wget -U curl/7.54.1 "$page" -O- |
|
||||||
|
grep -Eio -m1 "\"https://.+/SetupRST\.exe\"" | tr -d '"' | grep .)
|
||||||
|
|
||||||
# 注意 intel 禁止了 aria2 下载
|
# 注意 intel 禁止了 aria2 下载
|
||||||
download $url $drv/SetupRST.exe
|
download $url $drv/SetupRST.exe
|
||||||
|
|||||||
Reference in New Issue
Block a user