core: 优化注释/代码

This commit is contained in:
bin456789 2023-09-21 00:12:35 +08:00
parent 3290e48c06
commit 7b453004dc
No known key found for this signature in database
GPG Key ID: EE301B386DE6C11B
6 changed files with 73 additions and 59 deletions

View File

@ -26,7 +26,7 @@ jobs:
${{ matrix.command }} ubuntu
${{ matrix.command }} debian 12
${{ 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
${{ matrix.command }} centos --ci

View File

@ -5,7 +5,7 @@ jobs:
name: 同步到 Gitee
runs-on: ubuntu-latest
steps:
- uses: Yikun/hub-mirror-action@master
- uses: Yikun/hub-mirror-action@v1.3
with:
src: github/bin456789
dst: gitee/bin456789

View File

@ -1,27 +1,32 @@
# reinstall
又一个重装脚本
## 亮点:
## 亮点
- 不含第三方链接和自制包,所有资源均实时从各发行版的镜像站点获得
- 默认使用官方安装程序,不满足安装程序内存要求时,将使用官方云镜像 (Cloud Image)
- 使用云镜像安装时,配置要求低至 512M 内存 / 5G 硬盘
- 使用云镜像安装时,配置要求低至 512M 内存 + 5G 硬盘
- 支持 BIOS / EFI / ARM
- 支持使用官方 iso 重装到 Windows (不支持 ARM)
- 支持从 Windows 重装到 Linux
- 原系统分区支持 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://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 版本)
alma 8|9
rocky 8|9
@ -33,36 +38,41 @@
arch (只支持云镜像)
gentoo (只支持 amd64 云镜像)
可选参数: --ci 强制使用云镜像
可选参数: --ci 强制使用云镜像
### 安装 Windows
### 安装 Windows
bash reinstall.sh windows \
--iso=https://example.com/en-us_windows_10_enterprise_ltsc_2021_x64_dvd_d289cf96.iso \
--image-name='Windows 10 Enterprise LTSC 2021'
### dd支持 gzip xz 格式):
### DD支持 gzip 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.sh
<https://raw.githubusercontent.com/bin456789/reinstall/main/reinstall.bat>
<https://raw.githubusercontent.com/bin456789/reinstall/main/reinstall.sh>
管理员权限打开 `cmd` / `powershell` 窗口,先运行 `cmd`(重要),再运行:
reinstall.bat centos-7 (或其他操作,所有功能均可在 Windows 下使用)
## Windows iso 安装说明:
## Windows iso 安装说明
bash reinstall.sh windows \
--iso=https://example.com/en-us_windows_10_enterprise_ltsc_2021_x64_dvd_d289cf96.iso \
--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 10 Enterprise LTSC 2021'
@ -70,44 +80,51 @@ https://raw.githubusercontent.com/bin456789/reinstall/main/reinstall.sh
'Windows Server 2022 SERVERDATACENTER'
使用 Dism++ 文件菜单 > 打开映像文件,选择要安装的 iso可以得到映像名称
![image-name](https://github.com/bin456789/reinstall/assets/7548515/5aae0a9b-61e2-4f66-bb98-d470a6beaac2)
### 其它说明:
### 其它说明
1. 测试成功的系统有 7 10 11 2022测试平台为 vultr (bios)、甲骨文 (efi)、aws t2 (xen)、aws t3 (nitro)
2. 支持 32/64 位系统UEFI 机器只支持 64 位
3. 不支持 ARM 机器
4. `zh-cn_windows_10_enterprise_ltsc_2021_x64_dvd_033b7312.iso`
此镜像安装后 `wsappx` 进程会长期占用 CPU
https://www.google.com/search?q=ltsc+wsappx
<https://www.google.com/search?q=ltsc+wsappx>
这是镜像原本的问题,需要手动安装 `VCLibs` 库才能解决
6. iso 链接可以到 `https://archive.org` 上面找
这是镜像的问题,解决方法是安装 `VCLibs`
## 内存要求:
| 系统 | 传统安装 | 云镜像 |
| ---- | ---- | ---- |
| Debian | 384M | 512M |
| Ubuntu | 1G | 512M |
| CentOS / Alma / Rocky / Fedora | 1G | 512M |
| Alpine | 512M? | - |
| openSUSE | 暂不支持 | 512M |
| Arch | 暂不支持 | 512M |
| Gentoo | 暂不支持 | 512M |
| Windows | 1G | - |
5. iso 链接可以到 `https://archive.org` 上面找
## 内存要求
| 系统 | 传统安装 | 云镜像 |
| ------------------------------ | -------- | ------ |
| Debian | 384M | 512M |
| Ubuntu | 1G | 512M |
| CentOS / Alma / Rocky / Fedora | 1G | 512M |
| Alpine | 256M | - |
| openSUSE | 暂不支持 | 512M |
| Arch | 暂不支持 | 512M |
| Gentoo | 暂不支持 | 512M |
| Windows | 1G | - |
## 网络要求
## 网络要求:
要求有 IPv4、DHCPv4 !!!!!
要求有 IPv4、DHCPv4 !!!!!
要求有 IPv4、DHCPv4 !!!!!
## 默认密码:
| 系统 | 用户名 | 密码 |
| ---- | ---- | ---- |
| Linux | root | 123@@@ |
| Windows| administrator | 123@@@ |
## 默认密码
| 系统 | 用户名 | 密码 |
| ------- | ------------- | ------ |
| Linux | root | 123@@@ |
| Windows | administrator | 123@@@ |
## TODO
## TODO:
- 静态 IP / IPV6

View File

@ -61,12 +61,12 @@ fi
# 设置静态地址
if ! is_have_ipv4 && [ -n "$ipv4_addr" ]; then
ip -4 addr add $ipv4_addr dev eth0
ip -4 route add default via $ipv4_gateway
ip -4 addr add "$ipv4_addr" dev eth0
ip -4 route add default via "$ipv4_gateway"
fi
if ! is_have_ipv6 && [ -n "$ipv6_addr" ]; then
ip -6 addr add $ipv6_addr dev eth0
ip -6 route add default via $ipv6_gateway
ip -6 addr add "$ipv6_addr" dev eth0
ip -6 route add default via "$ipv6_gateway"
fi
# 检查 ipv4/ipv6 是否连接联网
@ -127,8 +127,8 @@ fi
# 传参给 trans.start
$dhcpv4 && echo 1 >/dev/dhcpv4 || echo 0 >/dev/dhcpv4
echo $mac_addr >/dev/mac_addr
echo $ipv4_addr >/dev/ipv4_addr
echo $ipv4_gateway >/dev/ipv4_gateway
echo $ipv6_addr >/dev/ipv6_addr
echo $ipv6_gateway >/dev/ipv6_gateway
echo "$mac_addr" >/dev/mac_addr
echo "$ipv4_addr" >/dev/ipv4_addr
echo "$ipv4_gateway" >/dev/ipv4_gateway
echo "$ipv6_addr" >/dev/ipv6_addr
echo "$ipv6_gateway" >/dev/ipv6_gateway

View File

@ -437,7 +437,6 @@ setos() {
setos_redhat() {
if is_use_cloud_image; then
# ci
[ "$distro" = "centos" ] && [ "$releasever" = "7" ] && stream_suffix="" || stream_suffix="-stream"
if is_in_china; then
case $distro in
"centos") ci_mirror="https://mirror.nju.edu.cn/centos-cloud/centos" ;;
@ -456,8 +455,8 @@ setos() {
case $distro in
"centos")
case $releasever in
"7") ci_image=$ci_mirror/$releasever$stream_suffix/images/CentOS-7-$basearch-GenericCloud.qcow2 ;;
"8" | "9") ci_image=$ci_mirror/$releasever$stream_suffix/$basearch/images/CentOS-Stream-GenericCloud-$releasever-latest.$basearch.qcow2 ;;
"7") ci_image=$ci_mirror/$releasever/images/CentOS-7-$basearch-GenericCloud.qcow2 ;;
"8" | "9") ci_image=$ci_mirror/$releasever-stream/$basearch/images/CentOS-Stream-GenericCloud-$releasever-latest.$basearch.qcow2 ;;
esac
;;
"alma")

View File

@ -188,9 +188,7 @@ extract_env_from_cmdline() {
value=$(echo $line | cut -d= -f2-)
eval "$key='$value'"
fi
done <<EOF
$(xargs -n1 </proc/cmdline | grep "^$prefix" | sed "s/^$prefix\.//")
EOF
done < <(xargs -n1 </proc/cmdline | grep "^$prefix" | sed "s/^$prefix\.//")
done
}
@ -691,7 +689,7 @@ download_cloud_init_config() {
download $confhome/nocloud.yaml $ci_file
# swapfile
# 如果分区表中已经有swap就跳过例如arch
# 如果分区表中已经有swapfile就跳过例如arch
if ! grep -w swap $os_dir/etc/fstab; then
# btrfs
if mount | grep 'on /os type btrfs'; then