From 0e231e7aa07c2773b1ba783f79bd4d26cd97114c Mon Sep 17 00:00:00 2001 From: bin456789 Date: Tue, 20 Aug 2024 23:52:55 +0800 Subject: [PATCH] =?UTF-8?q?docs:=20=E6=9B=B4=E6=96=B0=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/ISSUE_TEMPLATE/bug_report.md | 8 +- .github/ISSUE_TEMPLATE/feature_request.md | 2 +- README.en.md | 127 ++++++++++------------ README.md | 121 +++++++++------------ reinstall.sh | 20 ++-- 5 files changed, 128 insertions(+), 150 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index dbe4121..8660461 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -1,5 +1,5 @@ --- -name: Bug report +name: Bug report (问题反馈) about: Create a report to help us improve title: '' labels: '' @@ -8,7 +8,9 @@ assignees: '' --- 原来的系统: - 要安装的系统: - 遇到的问题:截图或者登录 SSH 获取日志 /reinstall.log + +Original system: +System to be installed: +Issues encountered: Screenshot or log in via SSH to get the logs from /reinstall.log diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md index e46a4c0..5a4e605 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -1,5 +1,5 @@ --- -name: Feature request +name: Feature request (功能请求) about: Suggest an idea for this project title: '' labels: '' diff --git a/README.en.md b/README.en.md index d23bf44..821459a 100644 --- a/README.en.md +++ b/README.en.md @@ -2,22 +2,22 @@ # reinstall -[![Codacy](https://img.shields.io/codacy/grade/dc679a17751448628fe6d8ac35e26eed?logo=Codacy&label=Codacy)](https://app.codacy.com/gh/bin456789/reinstall/dashboard) -[![CodeFactor](https://img.shields.io/codefactor/grade/github/bin456789/reinstall?logo=CodeFactor&logoColor=white&label=CodeFactor)](https://www.codefactor.io/repository/github/bin456789/reinstall) -[![Lines of Code](https://aschey.tech/tokei/github/bin456789/reinstall?category=code&label=Lines%20of%20Code)](https://github.com/aschey/vercel-tokei) - +[![Codacy](https://img.shields.io/codacy/grade/dc679a17751448628fe6d8ac35e26eed?logo=Codacy&label=Codacy&style=flat-square)](https://app.codacy.com/gh/bin456789/reinstall/dashboard) +[![CodeFactor](https://img.shields.io/codefactor/grade/github/bin456789/reinstall?logo=CodeFactor&logoColor=white&label=CodeFactor&style=flat-square)](https://www.codefactor.io/repository/github/bin456789/reinstall) +[![Lines of Code](https://aschey.tech/tokei/github/bin456789/reinstall?category=code&label=Lines%20of%20Code&style=flat-square)](https://github.com/aschey/vercel-tokei) -Reinstall server with one-click [中文](README.md) +One-Click Script to Reinstall System [中文](README.md) ## Highlights -- Support installation of 17 common Linux distributions. -- Support for installing Windows using the official original ISO. The script can automatically search for the ISO and drivers. -- Support reinstallation in any direction, meaning `Linux to Linux`, `Linux to Win`, `Win to Win`, `Win to Linux`. -- Specifically tailored for low-spec machines, addressing insufficient memory that prevents network installation. -- Automatically detect dynamic and static IPv4 / IPv6, eliminating the need to fill in IP / subnet mask / gateway. -- Support ARM, BIOS, EFI boot, with original system supporting LVM, BTRFS. -- No homemade packages included, all resources obtained in real-time from source sites. +- Supports installation of 17 common Linux distributions +- Supports installation of official Windows ISO, automatically finds ISO links, and integrates virtual machine drivers +- Supports installation in any direction, i.e., `Linux to Linux`, `Linux to Windows`, `Windows to Windows`, `Windows to Linux` +- No need to input IP parameters; automatically recognizes dynamic and static IPs, supports `/32`, `/128`, `gateway outside subnet`, `pure IPv6`, `dual NIC` and other special network configurations +- Specially optimized for low-spec servers, requires less memory than the official netboot +- Uses partition table ID to identify hard drives throughout the process, ensuring no wrong disk is written +- Supports BIOS and EFI boot, and ARM architecture +- No homemades image included, all resources are obtained in real-time from source sites - Includes many comments. ## System Requirements @@ -52,17 +52,6 @@ Reinstall server with one-click [中文](README.md) > > Please use instead. -## System Accounts - -| System | Username | Password | -| ---------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------- | -------------- | -| Linux | root | 123@@@ | -| Windows (ISO) | administrator | 123@@@ | -| Windows (DD) | Image username | Image password | - -> [!TIP] -> If remote login to Windows fails, try using the username `.\administrator`. - ## Download (Current system is Linux) For server outside China: @@ -121,36 +110,25 @@ certutil -urlcache -f -split https://jihulab.com/bin456789/reinstall/-/raw/main/ ## Usage -> [!TIP] -> All features can be used on both Linux and Windows. -> -> on Linux, execute `bash reinstall.sh` -> -> on Windows, execute `reinstall.bat` +**All features** can be used on both Linux and Windows. + +- on Linux, execute `bash reinstall.sh` +- on Windows, execute `reinstall.bat` ### Feature 1: Install Linux - If no version number is entered, the latest version will be installed. - Does not include a boot partition (except for Fedora), nor a swap partition, maximizing disk space utilization. -- When installing on a virtual machine, it will automatically select a official limmed-down kernel. -- During the initial login, you may receive a password error prompt; just wait a moment and it should be resolved. - -> [!TIP] -> When installing Debian / Kali, x86 architectures can monitor the installation progress through VNC in the background, while ARM architectures can use the serial console. -> -> When installing other systems, can monitor the progress through various methods (SSH, HTTP 80 port, VNC in the background, serial console). - -> [!IMPORTANT] -> To install Red Hat, you need to provide the `qcow2` image link obtained from the following website. -> -> See +- On virtual machines, the appropriate official slimmed-down kernel will be automatically installed. +- To install Red Hat, you need to provide the `qcow2` image link obtained from . +- Username `root`, password `123@@@`. It may take a few minutes for the password to take effect on the first boot. ```bash bash reinstall.sh centos 9 anolis 7|8 alma 8|9 rocky 8|9 - redhat 8|9 --img='http://xxx.qcow2' + redhat 8|9 --img='http://xxx.com/xxx.qcow2' opencloudos 8|9 oracle 7|8|9 fedora 39|40 @@ -165,21 +143,29 @@ bash reinstall.sh centos 9 gentoo ``` +> [!TIP] +> When installing Debian / Kali, x86 architectures can monitor the installation progress through VNC in the background, while ARM architectures can use the serial console. +> +> When installing other systems, can monitor the progress through various methods (SSH, HTTP 80 port, VNC in the background, serial console). +> Even if errors occur during the installation process, you can still install Alpine via SSH. + ### Feature 2: DD -- Supports gzip, xz formats. -- A machine with a static IP running DD Windows will automatically configure the IP, which may take a few minutes to complete after the first boot. - -> [!TIP] -> Can monitor the progress through various methods (SSH, HTTP 80 port, VNC in the background, serial console). +- Supports `gzip` and `xz` formatted images +- When using DD with a Windows image, the script will automatically expand the system partition. For static IP machines, the IP will be configured automatically, and it may take a few minutes to take effect on first boot ```bash bash reinstall.sh dd --img https://example.com/xxx.xz ``` +> [!TIP] +> Can monitor the progress through various methods (SSH, HTTP 80 port, VNC in the background, serial console). +> Even if errors occur during the installation process, you can still install Alpine via SSH. + ### Feature 3: Reboot to Alpine Rescue System (Live OS) -- Can be connected via SSH to perform manual DD, modify partitions, manually install Arch / Gentoo, etc. +- You can use SSH to manually perform DD operations, modify partitions, and manually install Alpine, Arch, Gentoo, and other systems. +- Username `root`, password `123@@@` - If the disk content is not modified, rebooting again will return to the original system. ```bash @@ -199,15 +185,13 @@ bash reinstall.sh netboot.xyz ### Feature 5: Install Windows ISO -- Can automatically searching for most iso links. Need to set the language using `--lang`, default is `en-us`. -- Machines with static IP addresses will have their IPs automatically configured after installation. -- Can bypass Windows 11 installation restrictions. +- Username `administrator`, password `123@@@` +- If remote login fails, try using the username `.\administrator`. +- The machine with a static IP will automatically configure the IP. It may take a few minutes to take effect on the first boot. -> [!TIP] -> The script uses as the ISO source. All ISOs provided are official originals. +#### Method 1: Allow the script to automatically find the ISO -> [!IMPORTANT] -> Note that parameters should be enclosed in quotation marks. +- The script will search for ISO files from . The ISOs provided on this site are all official versions. ```bash bash reinstall.sh windows \ @@ -215,7 +199,9 @@ bash reinstall.sh windows \ --lang zh-cn ``` -- You can also specify an ISO link. +#### Method 2: Specify the ISO link manually + +- If you don’t know the `--image-name`, you can enter any value. After rebooting, connect via SSH and re-enter the correct value based on the error messages. ```bash bash reinstall.sh windows \ @@ -223,24 +209,25 @@ bash reinstall.sh windows \ --iso 'https://drive.massgrave.dev/en-us_windows_10_enterprise_ltsc_2021_x64_dvd_d289cf96.iso' ``` +> [!IMPORTANT] +> Note that parameters should be enclosed in quotation marks. +
The following website provides iso links. -- Massgrave - - (Recommended, iso sourced from official channels, updated monthly, includes the latest patches) -- Microsoft - - (Need to open it with a mobile User-Agent) - - - - (Preview) - - - - - - - - - - - - - - - - +- (Recommended, iso sourced from official channels, updated monthly, includes the latest patches) +- (Need to open it with a mobile User-Agent) +- +- (Preview) +- +- +- +- +- +- +- +-
diff --git a/README.md b/README.md index 21e0e89..0947097 100644 --- a/README.md +++ b/README.md @@ -2,21 +2,21 @@ # reinstall -[![Codacy](https://img.shields.io/codacy/grade/dc679a17751448628fe6d8ac35e26eed?logo=Codacy&label=Codacy)](https://app.codacy.com/gh/bin456789/reinstall/dashboard) -[![CodeFactor](https://img.shields.io/codefactor/grade/github/bin456789/reinstall?logo=CodeFactor&logoColor=white&label=CodeFactor)](https://www.codefactor.io/repository/github/bin456789/reinstall) -[![Lines of Code](https://aschey.tech/tokei/github/bin456789/reinstall?category=code&label=Lines%20of%20Code)](https://github.com/aschey/vercel-tokei) - +[![Codacy](https://img.shields.io/codacy/grade/dc679a17751448628fe6d8ac35e26eed?logo=Codacy&label=Codacy&style=flat-square)](https://app.codacy.com/gh/bin456789/reinstall/dashboard) +[![CodeFactor](https://img.shields.io/codefactor/grade/github/bin456789/reinstall?logo=CodeFactor&logoColor=white&label=CodeFactor&style=flat-square)](https://www.codefactor.io/repository/github/bin456789/reinstall) +[![Lines of Code](https://aschey.tech/tokei/github/bin456789/reinstall?category=code&label=Lines%20of%20Code&style=flat-square)](https://github.com/aschey/vercel-tokei) 一键重装脚本 [English](README.en.md) ## 亮点 - 支持安装 17 种常见 Linux 发行版 -- 支持用官方原版 iso 安装 Windows,并且脚本会自动查找 iso 和驱动 -- 支持任意方向重装,也就是支持 `Linux to Linux`、`Linux to Win`、`Win to Win`、`Win to Linux` -- 专门适配低配小鸡,解决内存过少导致无法进行网络安装 -- 自动判断动静态 IPv4 / IPv6,无需填写 IP / 掩码 / 网关 -- 支持 ARM,支持 BIOS、EFI 引导,原系统支持 LVM、BTRFS +- 支持安装官方原版 Windows iso,自动查找 iso 链接、集成虚拟机驱动 +- 支持任意方向重装,即 `Linux to Linux`、`Linux to Windows`、`Windows to Windows`、`Windows to Linux` +- 无需填写 IP 参数,自动识别动静态,支持 `/32`、`/128`、`网关不在子网范围内`、`纯 IPv6`、`双网卡` 等特殊网络 +- 专门适配低配小鸡,比官方 netboot 需要更少的内存 +- 全程用分区表 ID 识别硬盘,确保不会写错硬盘 +- 支持 BIOS、EFI 引导,支持 ARM - 不含自制包,所有资源均实时从源站点获得 - 有很多注释 @@ -52,17 +52,6 @@ > > 请改用 -## 系统账号 - -| 系统 | 用户名 | 密码 | -| ---------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------- | -------- | -| Linux | root | 123@@@ | -| Windows (ISO) | administrator | 123@@@ | -| Windows (DD) | 镜像用户名 | 镜像密码 | - -> [!TIP] -> 如果远程登录 Windows 失败,尝试使用用户名 `.\administrator` - ## 下载(当前系统是 Linux) 国外服务器: @@ -121,36 +110,25 @@ certutil -urlcache -f -split https://jihulab.com/bin456789/reinstall/-/raw/main/ ## 使用 -> [!TIP] -> 所有功能均可在 Linux / Windows 下使用。 -> -> Linux 下运行 `bash reinstall.sh` -> -> Windows 下运行 `reinstall.bat` +**所有功能** 都可在 Linux / Windows 下运行 + +- Linux 下运行 `bash reinstall.sh` +- Windows 下运行 `reinstall.bat` ### 功能 1: 安装 Linux - 不输入版本号,则安装最新版 - 不含 boot 分区(Fedora 例外),不含 swap 分区,最大化利用磁盘空间 -- 在虚拟机上,会自动安装官方精简内核 -- 首次登录可能会提示密码错误,稍等一下就正常了 - -> [!TIP] -> 安装 Debian / Kali 时,x86 可通过后台 VNC 查看安装进度,ARM 可通过串行控制台查看安装进度。 -> -> 安装其它系统时,可通过多种方式(SSH、HTTP 80 端口、后台 VNC、串行控制台)查看安装进度。 - -> [!IMPORTANT] -> 安装 Red Hat 需填写以下网站得到的 `qcow2` 镜像链接 -> -> +- 在虚拟机上,会自动安装合适的官方精简内核 +- 安装 Red Hat 需填写 得到的 `qcow2` 镜像链接 +- 用户名 `root` 密码 `123@@@`,可能首次开机几分钟后密码才生效 ```bash bash reinstall.sh centos 9 anolis 7|8 alma 8|9 rocky 8|9 - redhat 8|9 --img='http://xxx.qcow2' + redhat 8|9 --img='http://xxx.com/xxx.qcow2' opencloudos 8|9 oracle 7|8|9 fedora 39|40 @@ -165,21 +143,29 @@ bash reinstall.sh centos 9 gentoo ``` +> [!TIP] +> 安装 Debian / Kali 时,x86 可通过后台 VNC 查看安装进度,ARM 可通过串行控制台查看安装进度。 +> +> 安装其它系统时,可通过多种方式(SSH、HTTP 80 端口、后台 VNC、串行控制台)查看安装进度。 +> 即使安装过程出错,也能通过 SSH 安装到 Alpine。 + ### 功能 2: DD -- 支持 gzip、xz 格式 -- 静态 IP 的机器 DD Windows,会自动配置好 IP,可能首次开机几分钟后才完成配置 - -> [!TIP] -> 可通过多种方式(SSH、HTTP 80 端口、后台 VNC、串行控制台)查看安装进度。 +- 支持 `gzip`、`xz` 格式的镜像 +- DD Windows 镜像时,会自动扩展系统盘。静态的机器会自动配置好 IP,可能首次开机几分钟后才生效 ```bash bash reinstall.sh dd --img https://example.com/xxx.xz ``` +> [!TIP] +> 可通过多种方式(SSH、HTTP 80 端口、后台 VNC、串行控制台)查看安装进度。 +> 即使安装过程出错,也能通过 SSH 安装到 Alpine。 + ### 功能 3: 重启到 Alpine 救援系统 (Live OS) -- 可用 ssh 连接,进行手动 DD、修改分区、手动安装 Arch / Gentoo 等操作 +- 可用 ssh 连接,进行手动 DD、修改分区、手动安装 Alpine / Arch / Gentoo 等操作 +- 用户名 `root` 密码 `123@@@` - 如果没有修改硬盘内容,再次重启将回到原系统 ```bash @@ -199,15 +185,13 @@ bash reinstall.sh netboot.xyz ### 功能 5: 安装 Windows ISO -- 支持自动查找大部分 iso 链接,需指定语言 `--lang`,默认 `en-us` -- 静态 IP 的机器,安装后会自动配置好 IP -- 能够绕过 Windows 11 安装限制 +- 用户名 `administrator` 密码 `123@@@` +- 如果远程登录失败,尝试使用用户名 `.\administrator` +- 静态机器会自动配置好 IP,可能首次开机几分钟后才生效 -> [!TIP] -> 脚本以 作为 iso 镜像查找源。所有 iso 都是官方原版。 +#### 方法 1: 让脚本自动查找 ISO -> [!IMPORTANT] -> 注意参数两边有引号。 +- 脚本会从 查找 iso,该网站提供的 iso 都是官方原版 ```bash bash reinstall.sh windows \ @@ -215,7 +199,9 @@ bash reinstall.sh windows \ --lang zh-cn ``` -- 也可以指定 iso 链接 +#### 方法 2: 自行指定 ISO 连接 + +- 如果不知道 `--image-name`,可以随便填,重启后连接 SSH ,根据错误提示重新输入 ```bash bash reinstall.sh windows \ @@ -223,24 +209,25 @@ bash reinstall.sh windows \ --iso 'https://drive.massgrave.dev/en-us_windows_10_enterprise_ltsc_2021_x64_dvd_d289cf96.iso' ``` +> [!IMPORTANT] +> 注意参数两边有引号。 +
以下网站可找到 iso 链接 -- Massgrave - - (推荐,iso 来自官方,每月更新,包含最新补丁) -- 微软 - - (需用手机 User-Agent 打开) - - - - (预览版) - - - - - - - - - - - - - - - - +- (推荐,iso 来自官方,每月更新,包含最新补丁) +- (需用手机 User-Agent 打开) +- +- (预览版) +- +- +- +- +- +- +- +-
diff --git a/reinstall.sh b/reinstall.sh index 5487b27..9ec1386 100644 --- a/reinstall.sh +++ b/reinstall.sh @@ -14,6 +14,9 @@ export LC_ALL=C # 不要漏了最后的 $PATH,否则会找不到 windows 系统程序例如 diskpart export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$PATH +# 记录日志 +exec > >(exec tee /reinstall.log) 2>&1 + this_script=$(readlink -f "$0") trap 'trap_err $LINENO $?' ERR @@ -36,7 +39,7 @@ Usage: $reinstall____ centos 9 anolis 7|8 alma 8|9 rocky 8|9 - redhat 8|9 --img='http://xxx.qcow2' + redhat 8|9 --img='http://xxx.com/xxx.qcow2' opencloudos 8|9 oracle 7|8|9 fedora 39|40 @@ -49,9 +52,10 @@ Usage: $reinstall____ centos 9 kali arch gentoo - dd --img='http://xxx.gzip' or .xz - windows --image-name='windows xxx yyy' --lang=xx-yy - windows --image-name='windows xxx yyy' --iso='http://xxx.iso' + dd --img='http://xxx.com/xxx.xz' + dd --img='http://xxx.com/xxx.gzip' + windows --image-name='windows xxx yyy' --lang=xx-yy + windows --image-name='windows xxx yyy' --iso='http://xxx.com/xxx.iso' netboot.xyz Manual: https://github.com/bin456789/reinstall @@ -1363,10 +1367,9 @@ install_pkg() { if [ -f /etc/os-release ]; then # shellcheck source=/dev/null . /etc/os-release - set -- $ID_LIKE $ID - # https://github.com/chef/os_release - while [ $# -gt 0 ]; do - case "$1" in + for id in $ID_LIKE $ID; do + # https://github.com/chef/os_release + case "$id" in fedora | centos | rhel) is_have_cmd dnf && pkg_mgr=dnf || pkg_mgr=yum ;; debian | ubuntu) pkg_mgr=apt ;; opensuse | suse) pkg_mgr=zypper ;; @@ -1377,7 +1380,6 @@ install_pkg() { nixos) pkg_mgr=nix-env ;; esac [ -n "$pkg_mgr" ] && return - shift done fi