mirror of
https://github.com/bin456789/reinstall.git
synced 2025-12-10 15:37:43 +08:00
core: 优化注释/代码
This commit is contained in:
2
.github/workflows/main.yml
vendored
2
.github/workflows/main.yml
vendored
@ -26,7 +26,7 @@ jobs:
|
|||||||
${{ matrix.command }} ubuntu
|
${{ matrix.command }} ubuntu
|
||||||
${{ matrix.command }} debian 12
|
${{ matrix.command }} debian 12
|
||||||
${{ matrix.command }} alpine
|
${{ matrix.command }} alpine
|
||||||
${{ matrix.command }} dd --img=https://cdn.kernel.org/pub/linux/kernel/v6.x/linux-6.3.8.tar.xz
|
${{ matrix.command }} dd --img=https://download.opensuse.org/tumbleweed/appliances/openSUSE-MicroOS.x86_64-SelfInstall.raw.xz
|
||||||
|
|
||||||
# 测试 cloud image
|
# 测试 cloud image
|
||||||
${{ matrix.command }} centos --ci
|
${{ matrix.command }} centos --ci
|
||||||
|
|||||||
2
.github/workflows/sync_to_gitee.yaml
vendored
2
.github/workflows/sync_to_gitee.yaml
vendored
@ -5,7 +5,7 @@ jobs:
|
|||||||
name: 同步到 Gitee
|
name: 同步到 Gitee
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: Yikun/hub-mirror-action@master
|
- uses: Yikun/hub-mirror-action@v1.3
|
||||||
with:
|
with:
|
||||||
src: github/bin456789
|
src: github/bin456789
|
||||||
dst: gitee/bin456789
|
dst: gitee/bin456789
|
||||||
|
|||||||
99
README.md
99
README.md
@ -1,27 +1,32 @@
|
|||||||
# reinstall
|
# reinstall
|
||||||
|
|
||||||
又一个重装脚本
|
又一个重装脚本
|
||||||
|
|
||||||
## 亮点:
|
## 亮点
|
||||||
|
|
||||||
- 不含第三方链接和自制包,所有资源均实时从各发行版的镜像站点获得
|
- 不含第三方链接和自制包,所有资源均实时从各发行版的镜像站点获得
|
||||||
- 默认使用官方安装程序,不满足安装程序内存要求时,将使用官方云镜像 (Cloud Image)
|
- 默认使用官方安装程序,不满足安装程序内存要求时,将使用官方云镜像 (Cloud Image)
|
||||||
- 使用云镜像安装时,配置要求低至 512M 内存 / 5G 硬盘
|
- 使用云镜像安装时,配置要求低至 512M 内存 + 5G 硬盘
|
||||||
- 支持 BIOS / EFI / ARM
|
- 支持 BIOS / EFI / ARM
|
||||||
- 支持使用官方 iso 重装到 Windows (不支持 ARM)
|
- 支持使用官方 iso 重装到 Windows (不支持 ARM)
|
||||||
- 支持从 Windows 重装到 Linux
|
- 支持从 Windows 重装到 Linux
|
||||||
- 原系统分区支持 lvm / btrfs
|
- 原系统分区支持 lvm / btrfs
|
||||||
- 自动选择国内外安装源
|
- 自动选择国内外安装源
|
||||||
- 使用 dd 或云镜像时有高贵的进度条,可通过 ssh/vnc/web/串行控制台 查看
|
- 使用 dd 或云镜像时有高贵的进度条,可通过 ssh/web/vnc/串行控制台 查看
|
||||||
- 有很多注释
|
- 有很多注释
|
||||||
|
|
||||||
## 使用(当前系统是 Linux):
|
## Linux 下使用
|
||||||
|
|
||||||
|
### 下载
|
||||||
|
|
||||||
### 下载:
|
|
||||||
curl -O https://raw.githubusercontent.com/bin456789/reinstall/main/reinstall.sh
|
curl -O https://raw.githubusercontent.com/bin456789/reinstall/main/reinstall.sh
|
||||||
|
|
||||||
### 下载 (国内):
|
### 下载 (国内)
|
||||||
curl -O https://gitee.com/bin456789/reinstall/raw/main/reinstall.sh
|
|
||||||
|
curl -O https://ghps.cc/https://raw.githubusercontent.com/bin456789/reinstall/main/reinstall.sh
|
||||||
|
|
||||||
|
### 安装 Linux
|
||||||
|
|
||||||
### 安装 Linux:
|
|
||||||
bash reinstall.sh centos 7|8|9 (8|9 为 stream 版本)
|
bash reinstall.sh centos 7|8|9 (8|9 为 stream 版本)
|
||||||
alma 8|9
|
alma 8|9
|
||||||
rocky 8|9
|
rocky 8|9
|
||||||
@ -33,36 +38,41 @@
|
|||||||
arch (只支持云镜像)
|
arch (只支持云镜像)
|
||||||
gentoo (只支持 amd64 云镜像)
|
gentoo (只支持 amd64 云镜像)
|
||||||
|
|
||||||
可选参数: --ci 强制使用云镜像
|
可选参数: --ci 强制使用云镜像
|
||||||
|
|
||||||
|
### 安装 Windows
|
||||||
|
|
||||||
### 安装 Windows:
|
|
||||||
bash reinstall.sh windows \
|
bash reinstall.sh windows \
|
||||||
--iso=https://example.com/en-us_windows_10_enterprise_ltsc_2021_x64_dvd_d289cf96.iso \
|
--iso=https://example.com/en-us_windows_10_enterprise_ltsc_2021_x64_dvd_d289cf96.iso \
|
||||||
--image-name='Windows 10 Enterprise LTSC 2021'
|
--image-name='Windows 10 Enterprise LTSC 2021'
|
||||||
|
|
||||||
### dd(支持 gzip xz 格式):
|
### DD(支持 gzip xz 格式)
|
||||||
|
|
||||||
bash reinstall.sh dd --img=https://example.com/xxx.xz
|
bash reinstall.sh dd --img=https://example.com/xxx.xz
|
||||||
|
|
||||||
## Windows 下使用:
|
## Windows 下使用
|
||||||
|
|
||||||
下载(链接另存为)放到同一目录
|
下载(链接另存为)放到同一目录
|
||||||
|
|
||||||
https://raw.githubusercontent.com/bin456789/reinstall/main/reinstall.bat
|
<https://raw.githubusercontent.com/bin456789/reinstall/main/reinstall.bat>
|
||||||
https://raw.githubusercontent.com/bin456789/reinstall/main/reinstall.sh
|
|
||||||
|
<https://raw.githubusercontent.com/bin456789/reinstall/main/reinstall.sh>
|
||||||
|
|
||||||
管理员权限打开 `cmd` / `powershell` 窗口,先运行 `cmd`(重要),再运行:
|
管理员权限打开 `cmd` / `powershell` 窗口,先运行 `cmd`(重要),再运行:
|
||||||
|
|
||||||
reinstall.bat centos-7 (或其他操作,所有功能均可在 Windows 下使用)
|
reinstall.bat centos-7 (或其他操作,所有功能均可在 Windows 下使用)
|
||||||
|
|
||||||
## Windows iso 安装说明:
|
## Windows iso 安装说明
|
||||||
|
|
||||||
bash reinstall.sh windows \
|
bash reinstall.sh windows \
|
||||||
--iso=https://example.com/en-us_windows_10_enterprise_ltsc_2021_x64_dvd_d289cf96.iso \
|
--iso=https://example.com/en-us_windows_10_enterprise_ltsc_2021_x64_dvd_d289cf96.iso \
|
||||||
--image-name='Windows 10 Enterprise LTSC 2021'
|
--image-name='Windows 10 Enterprise LTSC 2021'
|
||||||
### 参数:
|
|
||||||
`--iso` 官方原版镜像,不需要提前添加 virtio/xen/aws nitro 驱动
|
|
||||||
|
|
||||||
`--image-name` 一个 iso 里会有一个或多个映像,此参数用于指定要安装的映像
|
### 参数
|
||||||
|
|
||||||
不区分大小写,但两边要有引号,例如:
|
`--iso` 官方原版镜像,无需集成 virtio/xen/aws nitro 驱动
|
||||||
|
|
||||||
|
`--image-name` 一个 iso 里会有一个或多个映像,此参数用于指定要安装的映像。不区分大小写,但两边要有引号,例如:
|
||||||
|
|
||||||
'Windows 7 Ultimate'
|
'Windows 7 Ultimate'
|
||||||
'Windows 10 Enterprise LTSC 2021'
|
'Windows 10 Enterprise LTSC 2021'
|
||||||
@ -70,44 +80,51 @@ https://raw.githubusercontent.com/bin456789/reinstall/main/reinstall.sh
|
|||||||
'Windows Server 2022 SERVERDATACENTER'
|
'Windows Server 2022 SERVERDATACENTER'
|
||||||
|
|
||||||
使用 Dism++ 文件菜单 > 打开映像文件,选择要安装的 iso,可以得到映像名称
|
使用 Dism++ 文件菜单 > 打开映像文件,选择要安装的 iso,可以得到映像名称
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
### 其它说明:
|
### 其它说明
|
||||||
|
|
||||||
1. 测试成功的系统有 7 10 11 2022,测试平台为 vultr (bios)、甲骨文 (efi)、aws t2 (xen)、aws t3 (nitro)
|
1. 测试成功的系统有 7 10 11 2022,测试平台为 vultr (bios)、甲骨文 (efi)、aws t2 (xen)、aws t3 (nitro)
|
||||||
2. 支持 32/64 位系统,UEFI 机器只支持 64 位
|
2. 支持 32/64 位系统,UEFI 机器只支持 64 位
|
||||||
3. 不支持 ARM 机器
|
3. 不支持 ARM 机器
|
||||||
4. `zh-cn_windows_10_enterprise_ltsc_2021_x64_dvd_033b7312.iso`
|
4. `zh-cn_windows_10_enterprise_ltsc_2021_x64_dvd_033b7312.iso`
|
||||||
此镜像安装后 `wsappx` 进程会长期占用 CPU
|
此镜像安装后 `wsappx` 进程会长期占用 CPU
|
||||||
|
|
||||||
https://www.google.com/search?q=ltsc+wsappx
|
<https://www.google.com/search?q=ltsc+wsappx>
|
||||||
|
|
||||||
这是镜像原本的问题,需要手动安装 `VCLibs` 库才能解决
|
这是镜像的问题,解决方法是安装 `VCLibs` 库
|
||||||
6. iso 链接可以到 `https://archive.org` 上面找
|
|
||||||
|
|
||||||
## 内存要求:
|
5. iso 链接可以到 `https://archive.org` 上面找
|
||||||
| 系统 | 传统安装 | 云镜像 |
|
|
||||||
| ---- | ---- | ---- |
|
## 内存要求
|
||||||
| Debian | 384M | 512M |
|
|
||||||
| Ubuntu | 1G | 512M |
|
| 系统 | 传统安装 | 云镜像 |
|
||||||
| CentOS / Alma / Rocky / Fedora | 1G | 512M |
|
| ------------------------------ | -------- | ------ |
|
||||||
| Alpine | 512M? | - |
|
| Debian | 384M | 512M |
|
||||||
| openSUSE | 暂不支持 | 512M |
|
| Ubuntu | 1G | 512M |
|
||||||
| Arch | 暂不支持 | 512M |
|
| CentOS / Alma / Rocky / Fedora | 1G | 512M |
|
||||||
| Gentoo | 暂不支持 | 512M |
|
| Alpine | 256M | - |
|
||||||
| Windows | 1G | - |
|
| openSUSE | 暂不支持 | 512M |
|
||||||
|
| Arch | 暂不支持 | 512M |
|
||||||
|
| Gentoo | 暂不支持 | 512M |
|
||||||
|
| Windows | 1G | - |
|
||||||
|
|
||||||
|
## 网络要求
|
||||||
|
|
||||||
## 网络要求:
|
|
||||||
要求有 IPv4、DHCPv4 !!!!!
|
要求有 IPv4、DHCPv4 !!!!!
|
||||||
|
|
||||||
要求有 IPv4、DHCPv4 !!!!!
|
要求有 IPv4、DHCPv4 !!!!!
|
||||||
|
|
||||||
要求有 IPv4、DHCPv4 !!!!!
|
要求有 IPv4、DHCPv4 !!!!!
|
||||||
|
|
||||||
## 默认密码:
|
## 默认密码
|
||||||
| 系统 | 用户名 | 密码 |
|
|
||||||
| ---- | ---- | ---- |
|
| 系统 | 用户名 | 密码 |
|
||||||
| Linux | root | 123@@@ |
|
| ------- | ------------- | ------ |
|
||||||
| Windows| administrator | 123@@@ |
|
| Linux | root | 123@@@ |
|
||||||
|
| Windows | administrator | 123@@@ |
|
||||||
|
|
||||||
|
## TODO
|
||||||
|
|
||||||
## TODO:
|
|
||||||
- 静态 IP / IPV6
|
- 静态 IP / IPV6
|
||||||
|
|||||||
@ -61,12 +61,12 @@ fi
|
|||||||
|
|
||||||
# 设置静态地址
|
# 设置静态地址
|
||||||
if ! is_have_ipv4 && [ -n "$ipv4_addr" ]; then
|
if ! is_have_ipv4 && [ -n "$ipv4_addr" ]; then
|
||||||
ip -4 addr add $ipv4_addr dev eth0
|
ip -4 addr add "$ipv4_addr" dev eth0
|
||||||
ip -4 route add default via $ipv4_gateway
|
ip -4 route add default via "$ipv4_gateway"
|
||||||
fi
|
fi
|
||||||
if ! is_have_ipv6 && [ -n "$ipv6_addr" ]; then
|
if ! is_have_ipv6 && [ -n "$ipv6_addr" ]; then
|
||||||
ip -6 addr add $ipv6_addr dev eth0
|
ip -6 addr add "$ipv6_addr" dev eth0
|
||||||
ip -6 route add default via $ipv6_gateway
|
ip -6 route add default via "$ipv6_gateway"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# 检查 ipv4/ipv6 是否连接联网
|
# 检查 ipv4/ipv6 是否连接联网
|
||||||
@ -127,8 +127,8 @@ fi
|
|||||||
|
|
||||||
# 传参给 trans.start
|
# 传参给 trans.start
|
||||||
$dhcpv4 && echo 1 >/dev/dhcpv4 || echo 0 >/dev/dhcpv4
|
$dhcpv4 && echo 1 >/dev/dhcpv4 || echo 0 >/dev/dhcpv4
|
||||||
echo $mac_addr >/dev/mac_addr
|
echo "$mac_addr" >/dev/mac_addr
|
||||||
echo $ipv4_addr >/dev/ipv4_addr
|
echo "$ipv4_addr" >/dev/ipv4_addr
|
||||||
echo $ipv4_gateway >/dev/ipv4_gateway
|
echo "$ipv4_gateway" >/dev/ipv4_gateway
|
||||||
echo $ipv6_addr >/dev/ipv6_addr
|
echo "$ipv6_addr" >/dev/ipv6_addr
|
||||||
echo $ipv6_gateway >/dev/ipv6_gateway
|
echo "$ipv6_gateway" >/dev/ipv6_gateway
|
||||||
|
|||||||
@ -437,7 +437,6 @@ setos() {
|
|||||||
setos_redhat() {
|
setos_redhat() {
|
||||||
if is_use_cloud_image; then
|
if is_use_cloud_image; then
|
||||||
# ci
|
# ci
|
||||||
[ "$distro" = "centos" ] && [ "$releasever" = "7" ] && stream_suffix="" || stream_suffix="-stream"
|
|
||||||
if is_in_china; then
|
if is_in_china; then
|
||||||
case $distro in
|
case $distro in
|
||||||
"centos") ci_mirror="https://mirror.nju.edu.cn/centos-cloud/centos" ;;
|
"centos") ci_mirror="https://mirror.nju.edu.cn/centos-cloud/centos" ;;
|
||||||
@ -456,8 +455,8 @@ setos() {
|
|||||||
case $distro in
|
case $distro in
|
||||||
"centos")
|
"centos")
|
||||||
case $releasever in
|
case $releasever in
|
||||||
"7") ci_image=$ci_mirror/$releasever$stream_suffix/images/CentOS-7-$basearch-GenericCloud.qcow2 ;;
|
"7") ci_image=$ci_mirror/$releasever/images/CentOS-7-$basearch-GenericCloud.qcow2 ;;
|
||||||
"8" | "9") ci_image=$ci_mirror/$releasever$stream_suffix/$basearch/images/CentOS-Stream-GenericCloud-$releasever-latest.$basearch.qcow2 ;;
|
"8" | "9") ci_image=$ci_mirror/$releasever-stream/$basearch/images/CentOS-Stream-GenericCloud-$releasever-latest.$basearch.qcow2 ;;
|
||||||
esac
|
esac
|
||||||
;;
|
;;
|
||||||
"alma")
|
"alma")
|
||||||
|
|||||||
6
trans.sh
6
trans.sh
@ -188,9 +188,7 @@ extract_env_from_cmdline() {
|
|||||||
value=$(echo $line | cut -d= -f2-)
|
value=$(echo $line | cut -d= -f2-)
|
||||||
eval "$key='$value'"
|
eval "$key='$value'"
|
||||||
fi
|
fi
|
||||||
done <<EOF
|
done < <(xargs -n1 </proc/cmdline | grep "^$prefix" | sed "s/^$prefix\.//")
|
||||||
$(xargs -n1 </proc/cmdline | grep "^$prefix" | sed "s/^$prefix\.//")
|
|
||||||
EOF
|
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -691,7 +689,7 @@ download_cloud_init_config() {
|
|||||||
download $confhome/nocloud.yaml $ci_file
|
download $confhome/nocloud.yaml $ci_file
|
||||||
|
|
||||||
# swapfile
|
# swapfile
|
||||||
# 如果分区表中已经有swap就跳过,例如arch
|
# 如果分区表中已经有swapfile就跳过,例如arch
|
||||||
if ! grep -w swap $os_dir/etc/fstab; then
|
if ! grep -w swap $os_dir/etc/fstab; then
|
||||||
# btrfs
|
# btrfs
|
||||||
if mount | grep 'on /os type btrfs'; then
|
if mount | grep 'on /os type btrfs'; then
|
||||||
|
|||||||
Reference in New Issue
Block a user