mirror of
https://github.com/bin456789/reinstall.git
synced 2025-01-31 10:58:06 +08:00
不重要的优化
This commit is contained in:
parent
a83cd16145
commit
d4f6ac2e56
257
README.en.md
257
README.en.md
@ -1,71 +1,115 @@
|
||||
<!-- markdownlint-disable MD028 MD033 MD045 -->
|
||||
|
||||
# reinstall
|
||||
|
||||
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/dc679a17751448628fe6d8ac35e26eed)](https://app.codacy.com/gh/bin456789/reinstall/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade)
|
||||
[![CodeFactor](https://www.codefactor.io/repository/github/bin456789/reinstall/badge)](https://www.codefactor.io/repository/github/bin456789/reinstall)
|
||||
[![Lines of Code](https://tokei.rs/b1/github/bin456789/reinstall?category=code&style=flat)](https://github.com/XAMPPRocky/tokei_rs)
|
||||
[![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://tokei.rs/b1/github/bin456789/reinstall?category=code&style=flat&label=Lines%20of%20Code)](https://github.com/XAMPPRocky/tokei_rs)
|
||||
|
||||
One-click reinstallation script
|
||||
|
||||
[中文](README.md) | English
|
||||
Reinstall server with one-click [中文](README.md)
|
||||
|
||||
## Highlights
|
||||
|
||||
- Support arbitrary conversion between the following systems (including Windows to Linux).
|
||||
- Compatible low-spec servers and automatically select the appropriate official slimmed-down kernel.
|
||||
- Supports installing Windows using the official ISO.
|
||||
- Automatically detect dynamic/static IPv4/IPv6, eliminating the need to fill in IP/mask/gateway (even for DD/ISO installation of Windows).
|
||||
- Supports BIOS, EFI, ARM. The original system partition supports LVM, Btrfs.
|
||||
- Progress of DD and cloud image installation can be viewed through SSH, HTTP port 80, serial console, and vendor backend VNC.
|
||||
- The script does not include third-party homemade packages; all resources are obtained in real-time from the source site.
|
||||
- Support installation of 12 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 third-party custom packages included, all resources obtained in real-time from source sites.
|
||||
- Includes many comments.
|
||||
|
||||
## System Requirements
|
||||
|
||||
| Target System | Memory | Disk |
|
||||
| -------------------------------------------------------- | --------- | ---------------------- |
|
||||
| Alpine | 256 MB | 1 GB |
|
||||
| Debian / Kali | 256 MB | 1~1.5 GB ^ |
|
||||
| Ubuntu | 512 MB \* | 2 GB |
|
||||
| CentOS / Alma / Rocky / Oracle | 512 MB \* | 5 GB |
|
||||
| Fedora | 512 MB \* | 5 GB |
|
||||
| openSUSE | 512 MB \* | 5 GB |
|
||||
| Arch | 512 MB | 5 GB |
|
||||
| Gentoo | 512 MB | 5 GB |
|
||||
| DD | 512 MB | Depending on the image |
|
||||
| Windows 8.1 (Server 2012 R2) or below (ISO installation) | 512 MB | 20~25 GB |
|
||||
| Windows 10 (Server 2016) or above (ISO installation) | 1G | 20~25 GB |
|
||||
| Target System | Version | Memory | Disk |
|
||||
| ---------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------- | --------- | ---------------------- |
|
||||
| <img width="16" height="16" src="https://www.alpinelinux.org/alpine-logo.ico" /> Alpine | 3.17, 3.18, 3.19, 3.20 | 256 MB | 1 GB |
|
||||
| <img width="16" height="16" src="https://www.debian.org/favicon.ico" /> Debian | 10, 11, 12 | 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://assets.ubuntu.com/v1/49a1a858-favicon-32x32.png" /> Ubuntu | 20.04, 22.04, 24.04 | 512 MB \* | 2 GB |
|
||||
| <img width="16" height="16" src="https://www.centos.org/assets/img/favicon.png" /> CentOS | 7, 8, 9 | 512 MB \* | 5 GB |
|
||||
| <img width="16" height="16" src="https://www.oracle.com/asset/web/favicons/favicon-32.png" /> Oracle | 7, 8, 9 | 512 MB \* | 5 GB |
|
||||
| <img width="16" height="16" src="https://almalinux.org/fav/favicon.ico" /> Alma | 8, 9 | 512 MB \* | 5 GB |
|
||||
| <img width="16" height="16" src="https://rockylinux.org/favicon.png" /> Rocky | 8, 9 | 512 MB \* | 5 GB |
|
||||
| <img width="16" height="16" src="https://fedoraproject.org/favicon.ico" /> Fedora | 39, 40 | 512 MB \* | 5 GB |
|
||||
| <img width="16" height="16" src="https://static.opensuse.org/favicon.ico" /> openSUSE | 15.5, Tumbleweed (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://blogs.windows.com/wp-content/uploads/prod/2022/09/cropped-Windows11IconTransparent512-32x32.png" /> Windows (DD) | Any | 512 MB | Depending on the 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) | 10, 11 (Server 2016 ~ 2022) | 1 GB | 25 GB |
|
||||
|
||||
(\*) Indicates installation using cloud images
|
||||
(\*) Indicates installation using cloud images, not traditional network installation.
|
||||
|
||||
(^) indicates requiring either 256 MB memory + 1.5 GB disk, or 512 MB memory + 1 GB disk
|
||||
|
||||
## Download (Current system is Linux)
|
||||
> [!WARNING]
|
||||
> ❌ This script does not support OpenVZ or LXC virtual machines.
|
||||
>
|
||||
> Please use <https://github.com/LloydAsp/OsMutation> instead.
|
||||
|
||||
For users outside China:
|
||||
## System Accounts
|
||||
|
||||
| System | Username | Password |
|
||||
| ---------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------- | -------------- |
|
||||
| <img width="16" height="16" src="https://www.kernel.org/theme/images/logos/favicon.png" /> Linux | root | 123@@@ |
|
||||
| <img width="16" height="16" src="https://blogs.windows.com/wp-content/uploads/prod/2022/09/cropped-Windows11IconTransparent512-32x32.png" /> Windows (ISO) | administrator | 123@@@ |
|
||||
| <img width="16" height="16" src="https://blogs.windows.com/wp-content/uploads/prod/2022/09/cropped-Windows11IconTransparent512-32x32.png" /> Windows (DD) | Image username | Image password |
|
||||
|
||||
> [!TIP]
|
||||
> If remote login to Windows fails, try using the username `.\administrator`.
|
||||
|
||||
## Download (Current system is <img width="20" height="20" src="https://www.kernel.org/theme/images/logos/favicon.png" /> Linux)
|
||||
|
||||
For server outside China:
|
||||
|
||||
```bash
|
||||
curl -O https://raw.githubusercontent.com/bin456789/reinstall/main/reinstall.sh
|
||||
```
|
||||
|
||||
For users in China:
|
||||
For server inside China:
|
||||
|
||||
```bash
|
||||
curl -O https://mirror.ghproxy.com/https://raw.githubusercontent.com/bin456789/reinstall/main/reinstall.sh
|
||||
```
|
||||
|
||||
## Download (Current system is Windows)
|
||||
## Download (Current system is <img width="20" height="20" src="https://blogs.windows.com/wp-content/uploads/prod/2022/09/cropped-Windows11IconTransparent512-32x32.png" /> Windows)
|
||||
|
||||
[Unable to download?](#if-the-script-cannot-be-downloaded-under-windows)
|
||||
> [!IMPORTANT]
|
||||
> Before proceeding, please disable the 'Real-time protection' feature in `Windows Defender`. This feature may prevent `certutil` from downloading any files.
|
||||
|
||||
Before proceeding, please disable the 'Real-time protection' feature in `Windows Defender`. This feature may prevent `certutil` from downloading any files.
|
||||
<details>
|
||||
|
||||
For users outside China:
|
||||
<summary>😢Still unable to download?</summary>
|
||||
|
||||
### Try the following methods
|
||||
|
||||
1. For Windows 7, install this patch to enable TLS 1.2.
|
||||
|
||||
<https://aka.ms/easyfix51044>
|
||||
|
||||
2. Update SSL root certificates.
|
||||
|
||||
```batch
|
||||
certutil -generateSSTFromWU root.sst
|
||||
certutil -addstore Root root.sst
|
||||
```
|
||||
|
||||
3. Download manually by copying these two files through `Remote Desktop Connection`.
|
||||
|
||||
<https://raw.githubusercontent.com/bin456789/reinstall/main/reinstall.bat>
|
||||
|
||||
<https://raw.githubusercontent.com/bin456789/reinstall/main/reinstall.sh>
|
||||
|
||||
</details>
|
||||
|
||||
For server outside China:
|
||||
|
||||
```batch
|
||||
certutil -urlcache -f -split https://raw.githubusercontent.com/bin456789/reinstall/main/reinstall.bat
|
||||
```
|
||||
|
||||
For users in China:
|
||||
For server inside China:
|
||||
|
||||
```batch
|
||||
certutil -urlcache -f -split https://mirror.ghproxy.com/https://raw.githubusercontent.com/bin456789/reinstall/main/reinstall.bat
|
||||
@ -73,26 +117,34 @@ certutil -urlcache -f -split https://mirror.ghproxy.com/https://raw.githubuserco
|
||||
|
||||
## Usage
|
||||
|
||||
All features can be used on both Linux and Windows.
|
||||
> [!TIP]
|
||||
> All features can be used on both Linux and Windows.
|
||||
>
|
||||
> on Linux, execute `bash reinstall.sh`
|
||||
>
|
||||
> on Windows, execute `reinstall.bat`
|
||||
|
||||
- on Linux, execute `bash reinstall.sh`
|
||||
- on Windows, execute `reinstall.bat`
|
||||
|
||||
### Feature 1: Install Linux
|
||||
### Feature 1: Install <img width="16" height="16" src="https://www.kernel.org/theme/images/logos/favicon.png" /> Linux
|
||||
|
||||
- If no version number is entered, the latest version will be installed.
|
||||
- When installing on a virtual machine, it will automatically select a slimmed-down kernel.
|
||||
- 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.
|
||||
|
||||
> [!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).
|
||||
|
||||
```bash
|
||||
bash reinstall.sh centos 7|8|9 (8|9 for the stream version)
|
||||
oracle 7|8|9
|
||||
alma 8|9
|
||||
rocky 8|9
|
||||
fedora 38|39|40
|
||||
fedora 39|40
|
||||
debian 10|11|12
|
||||
opensuse 15.5|tumbleweed
|
||||
ubuntu 20.04|22.04|24.04
|
||||
alpine 3.16|3.17|3.18|3.19
|
||||
alpine 3.17|3.18|3.19|3.20
|
||||
kali
|
||||
arch
|
||||
gentoo
|
||||
@ -103,11 +155,14 @@ bash reinstall.sh centos 7|8|9 (8|9 for the stream version)
|
||||
- Supports gzip, xz formats.
|
||||
- For machines with static IP, DD Windows, and the script will automatically configure the IP.
|
||||
|
||||
> [!TIP]
|
||||
> Can monitor the progress through various methods (SSH, HTTP 80 port, VNC in the background, serial console).
|
||||
|
||||
```bash
|
||||
bash reinstall.sh dd --img https://example.com/xxx.xz
|
||||
```
|
||||
|
||||
### Feature 3: Reboot to Alpine Rescue System (Live OS)
|
||||
### Feature 3: Reboot to <img width="16" height="16" src="https://www.alpinelinux.org/alpine-logo.ico" /> Alpine Rescue System (Live OS)
|
||||
|
||||
- Can be connected via SSH to perform manual DD, modify partitions, manually install Arch / Gentoo, etc.
|
||||
- If the disk content is not modified, rebooting again will return to the original system.
|
||||
@ -116,7 +171,7 @@ bash reinstall.sh dd --img https://example.com/xxx.xz
|
||||
bash reinstall.sh alpine --hold=1
|
||||
```
|
||||
|
||||
### Feature 4: Reboot to netboot.xyz
|
||||
### Feature 4: Reboot to <img width="16" height="16" src="https://netboot.xyz/img/favicon.ico" /> netboot.xyz
|
||||
|
||||
- Can install [more systems](https://github.com/netbootxyz/netboot.xyz?tab=readme-ov-file#what-operating-systems-are-currently-available-on-netbootxyz) using vendor backend VNC.
|
||||
- If the disk content is not modified, rebooting again will return to the original system.
|
||||
@ -127,10 +182,17 @@ bash reinstall.sh netboot.xyz
|
||||
|
||||
![netboot.xyz](https://netboot.xyz/images/netboot.xyz.gif)
|
||||
|
||||
### Feature 5: Install Windows ISO
|
||||
### Feature 5: Install <img width="16" height="16" src="https://blogs.windows.com/wp-content/uploads/prod/2022/09/cropped-Windows11IconTransparent512-32x32.png" /> Windows ISO
|
||||
|
||||
- Pay attention to the quotation marks around the parameters
|
||||
- Supports automatically searching for some ISO links. Need to set the language using `--lang`, default is `en-us`.
|
||||
- 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.
|
||||
|
||||
> [!TIP]
|
||||
> The script uses <https://massgrave.dev/genuine-installation-media.html> as the ISO source. All ISOs provided are official originals.
|
||||
|
||||
> [!IMPORTANT]
|
||||
> Note that parameters should be enclosed in quotation marks.
|
||||
|
||||
```bash
|
||||
bash reinstall.sh windows \
|
||||
@ -146,9 +208,28 @@ bash reinstall.sh windows \
|
||||
--iso 'https://drive.massgrave.dev/en-us_windows_10_enterprise_ltsc_2021_x64_dvd_d289cf96.iso'
|
||||
```
|
||||
|
||||
<details>
|
||||
|
||||
<summary>The following website provides iso links.</summary>
|
||||
|
||||
- Massgrave
|
||||
- <https://massgrave.dev/genuine-installation-media.html> (Recommended, iso sourced from official channels, updated monthly, includes the latest patches)
|
||||
- Microsoft
|
||||
- <https://www.microsoft.com/software-download/indows8>
|
||||
- <https://www.microsoft.com/software-download/indows10> (Need to open it with a mobile User-Agent)
|
||||
- <https://www.microsoft.com/software-download/indows11>
|
||||
- <https://www.microsoft.com/evalcenter/ownload-windows-10-enterprise>
|
||||
- <https://www.microsoft.com/evalcenter/ownload-windows-11-enterprise>
|
||||
- <https://www.microsoft.com/evalcenter/ownload-windows-server-2012-r2>
|
||||
- <https://www.microsoft.com/evalcenter/ownload-windows-server-2016>
|
||||
- <https://www.microsoft.com/evalcenter/ownload-windows-server-2019>
|
||||
- <https://www.microsoft.com/evalcenter/download-windows-server-2022>
|
||||
|
||||
</details>
|
||||
|
||||
![Installing Windows](https://github.com/bin456789/reinstall/assets/7548515/07c1aea2-1ce3-4967-904f-aaf9d6eec3f7)
|
||||
|
||||
Parameters Description:
|
||||
#### Parameters Description
|
||||
|
||||
`--image-name` Specify the image to install, case-insensitive, Commonly used images include:
|
||||
|
||||
@ -163,78 +244,36 @@ Use `Dism++` File menu > Open Image File, select the iso to be installed to get
|
||||
|
||||
![image-name](https://github.com/bin456789/reinstall/assets/7548515/5aae0a9b-61e2-4f66-bb98-d470a6beaac2)
|
||||
|
||||
1. Supported systems:
|
||||
- Windows Vista to 11
|
||||
- Windows Server 2008 to 2022, including the following variants
|
||||
#### Supported systems
|
||||
|
||||
- Windows (Vista ~ 11)
|
||||
- Windows Server (2008 ~ 2022)
|
||||
- Windows Server Essentials
|
||||
- Windows Server Annual Channel
|
||||
- Windows Server (Semi) Annual Channel
|
||||
- Hyper-V Server
|
||||
- Azure Stack HCI
|
||||
2. The script will install the following drivers as needed:
|
||||
|
||||
#### The script will install the following drivers as needed
|
||||
|
||||
- KVM ([Virtio](https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/))
|
||||
- XEN ([XEN](https://xenproject.org/windows-pv-drivers/), [Citrix](https://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/Upgrading_PV_drivers.html#win2008-citrix-upgrade), [AWS](https://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/xen-drivers-overview.html))
|
||||
- AWS ([ENA Network Adapter](https://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/enhanced-networking-ena.html), [NVMe Storage Controller](https://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/aws-nvme-drivers.html))
|
||||
- GCP ([gVNIC Network Adapter](https://cloud.google.com/compute/docs/networking/using-gvnic), [GGA Graphics](https://cloud.google.com/compute/docs/instances/enable-instance-virtual-display))
|
||||
- Azure ([MANA Network Adapter](https://learn.microsoft.com/azure/virtual-network/accelerated-networking-mana-windows))
|
||||
3. Vista (Server 2008) and 32-bit systems may lack drivers.
|
||||
4. For EFI machines without CSM enabled, Windows 7 (Server 2008 R2) cannot be installed.
|
||||
5. If the machine has a static IP, the IP will be automatically set after installation.
|
||||
6. Can bypass Windows 11 hardware restrictions.
|
||||
7. Supports Windows 11 on ARM, exclusively for Hyper-V (Azure), not compatible with KVM (Oracle Cloud).
|
||||
8. The process `wsappx` will occupy CPU for a long time after installing the image `zh-cn_windows_10_enterprise_ltsc_2021_x64_dvd_033b7312.iso`.
|
||||
|
||||
This is an issue with the image, and the solution is to install the `VCLibs` library.
|
||||
> [!WARNING]
|
||||
> Vista (Server 2008) and 32-bit systems may lack drivers.
|
||||
|
||||
<https://www.google.com/search?q=ltsc+wsappx>
|
||||
> [!WARNING]
|
||||
> For EFI machines without CSM enabled, Windows 7 (Server 2008 R2) cannot be installed.
|
||||
|
||||
9. The following website provides iso links.
|
||||
> [!WARNING]
|
||||
> Supports installation of Windows 11 on ARM machines, limited to Hyper-V (Azure) only, not supported on KVM (Oracle Cloud).
|
||||
|
||||
<https://massgrave.dev/genuine-installation-media.html> (Recommended, iso sourced from official channels, updated monthly, includes the latest patches)
|
||||
|
||||
<https://www.microsoft.com/software-download/windows8>
|
||||
|
||||
<https://www.microsoft.com/software-download/windows10> (Need to open it with a mobile User-Agent)
|
||||
|
||||
<https://www.microsoft.com/software-download/windows11>
|
||||
|
||||
## Virtualization Requirements
|
||||
|
||||
Not supported on OpenVZ, LXC virtual machines.
|
||||
|
||||
Please use <https://github.com/LloydAsp/OsMutation>.
|
||||
|
||||
## Default Passwords
|
||||
|
||||
| System | Username | Password |
|
||||
| ------------- | -------------- | -------------- |
|
||||
| Linux | root | 123@@@ |
|
||||
| Windows (iso) | administrator | 123@@@ |
|
||||
| Windows (dd) | Image username | Image password |
|
||||
|
||||
If encountering a password error during remote login to Windows, try using the username .\administrator.
|
||||
|
||||
## If the script cannot be downloaded under Windows
|
||||
|
||||
You can try the following methods:
|
||||
|
||||
1. Disable Windows Defender Real-time Protection.
|
||||
|
||||
2. For Windows 7, install this patch to enable TLS 1.2.
|
||||
|
||||
<https://aka.ms/easyfix51044>
|
||||
|
||||
3. Update SSL root certificates.
|
||||
|
||||
```batch
|
||||
certutil -generateSSTFromWU root.sst
|
||||
certutil -addstore Root root.sst
|
||||
```
|
||||
|
||||
4. Download manually by copying these two files through `Remote Desktop Connection`.
|
||||
|
||||
<https://raw.githubusercontent.com/bin456789/reinstall/main/reinstall.bat>
|
||||
|
||||
<https://raw.githubusercontent.com/bin456789/reinstall/main/reinstall.sh>
|
||||
> [!WARNING]
|
||||
> In the Chinese version of Windows 10 LTSC 2021 ISO `zh-cn_windows_10_enterprise_ltsc_2021_x64_dvd_033b7312.iso`, the `wsappx` process may indefinitely consume CPU resources.
|
||||
>
|
||||
> The solution is to update the system patches or manually install the `VCLibs` library <https://www.google.com/search?q=ltsc+wsappx>.
|
||||
|
||||
## Thanks
|
||||
|
||||
|
256
README.md
256
README.md
@ -1,71 +1,115 @@
|
||||
<!-- markdownlint-disable MD028 MD033 MD045 -->
|
||||
|
||||
# reinstall
|
||||
|
||||
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/dc679a17751448628fe6d8ac35e26eed)](https://app.codacy.com/gh/bin456789/reinstall/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade)
|
||||
[![CodeFactor](https://www.codefactor.io/repository/github/bin456789/reinstall/badge)](https://www.codefactor.io/repository/github/bin456789/reinstall)
|
||||
[![Lines of Code](https://tokei.rs/b1/github/bin456789/reinstall?category=code&style=flat)](https://github.com/XAMPPRocky/tokei_rs)
|
||||
[![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://tokei.rs/b1/github/bin456789/reinstall?category=code&style=flat&label=Lines%20of%20Code)](https://github.com/XAMPPRocky/tokei_rs)
|
||||
|
||||
一键重装脚本
|
||||
|
||||
中文 | [English](README.en.md)
|
||||
一键重装脚本 [English](README.en.md)
|
||||
|
||||
## 亮点
|
||||
|
||||
- 支持以下系统任意转换(包括 Windows 转 Linux)
|
||||
- 适配低配小鸡,并自动选择合适的官方精简内核
|
||||
- 支持用官方 iso 安装 Windows
|
||||
- 自动判断动静态 IPv4 / IPv6,无需填写 IP / 掩码 / 网关(即使是 DD / ISO 安装 Windows)
|
||||
- 支持 BIOS、EFI、ARM,原系统分区支持 lvm、btrfs
|
||||
- 可通过 SSH、HTTP 80 端口、串行控制台、商家后台 VNC 查看 DD、云镜像安装进度
|
||||
- 支持安装 12 种常见 Linux 发行版
|
||||
- 支持用官方原版 iso 安装 Windows,并且脚本会自动查找 iso 和驱动
|
||||
- 支持任意方向重装,也就是支持 `Linux to Linux`、`Linux to Win`、`Win to Win`、`Win to Linux`
|
||||
- 专门适配低配小鸡,解决内存过少导致无法进行网络安装
|
||||
- 自动判断动静态 IPv4 / IPv6,无需填写 IP / 掩码 / 网关
|
||||
- 支持 ARM,支持 BIOS、EFI 引导,原系统支持 LVM、BTRFS
|
||||
- 不含第三方自制包,所有资源均实时从源站点获得
|
||||
- 有很多注释
|
||||
|
||||
## 配置要求
|
||||
|
||||
| 目标系统 | 内存 | 硬盘 |
|
||||
| ---------------------------------------------- | --------- | ---------- |
|
||||
| Alpine | 256 MB | 1 GB |
|
||||
| Debian / Kali | 256 MB | 1~1.5 GB ^ |
|
||||
| Ubuntu | 512 MB \* | 2 GB |
|
||||
| CentOS / Alma / Rocky / Oracle | 512 MB \* | 5 GB |
|
||||
| Fedora | 512 MB \* | 5 GB |
|
||||
| openSUSE | 512 MB \* | 5 GB |
|
||||
| Arch | 512 MB | 5 GB |
|
||||
| Gentoo | 512 MB | 5 GB |
|
||||
| DD | 512 MB | 取决于镜像 |
|
||||
| Windows 8.1 (Server 2012 R2) 或以下 (ISO 安装) | 512 MB | 20~25 GB |
|
||||
| Windows 10 (Server 2016) 或以上 (ISO 安装) | 1024 MB | 20~25 GB |
|
||||
| 目标系统 | 版本 | 内存 | 硬盘 |
|
||||
| ---------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------- | --------- | ------------ |
|
||||
| <img width="16" height="16" src="https://www.alpinelinux.org/alpine-logo.ico" /> Alpine | 3.17, 3.18, 3.19, 3.20 | 256 MB | 1 GB |
|
||||
| <img width="16" height="16" src="https://www.debian.org/favicon.ico" /> Debian | 10, 11, 12 | 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://assets.ubuntu.com/v1/49a1a858-favicon-32x32.png" /> Ubuntu | 20.04, 22.04, 24.04 | 512 MB \* | 2 GB |
|
||||
| <img width="16" height="16" src="https://www.centos.org/assets/img/favicon.png" /> CentOS | 7, 8, 9 | 512 MB \* | 5 GB |
|
||||
| <img width="16" height="16" src="https://www.oracle.com/asset/web/favicons/favicon-32.png" /> Oracle | 7, 8, 9 | 512 MB \* | 5 GB |
|
||||
| <img width="16" height="16" src="https://almalinux.org/fav/favicon.ico" /> Alma | 8, 9 | 512 MB \* | 5 GB |
|
||||
| <img width="16" height="16" src="https://rockylinux.org/favicon.png" /> Rocky | 8, 9 | 512 MB \* | 5 GB |
|
||||
| <img width="16" height="16" src="https://fedoraproject.org/favicon.ico" /> Fedora | 39, 40 | 512 MB \* | 5 GB |
|
||||
| <img width="16" height="16" src="https://static.opensuse.org/favicon.ico" /> openSUSE | 15.5, Tumbleweed (滚动) | 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://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) | 10, 11 (Server 2016 ~ 2022) | 1 GB | 25 GB |
|
||||
|
||||
(\*) 表示使用云镜像安装
|
||||
(\*) 表示使用云镜像安装,非传统网络安装
|
||||
|
||||
(^) 需要 256 MB 内存 + 1.5 GB 硬盘,或 512 MB 内存 + 1 GB 硬盘
|
||||
|
||||
## 下载(当前系统是 Linux)
|
||||
> [!WARNING]
|
||||
> ❌ 本脚本不支持 OpenVZ、LXC 虚拟机
|
||||
>
|
||||
> 请改用 <https://github.com/LloydAsp/OsMutation>
|
||||
|
||||
国外:
|
||||
## 系统账号
|
||||
|
||||
| 系统 | 用户名 | 密码 |
|
||||
| ---------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------- | -------- |
|
||||
| <img width="16" height="16" src="https://www.kernel.org/theme/images/logos/favicon.png" /> Linux | root | 123@@@ |
|
||||
| <img width="16" height="16" src="https://blogs.windows.com/wp-content/uploads/prod/2022/09/cropped-Windows11IconTransparent512-32x32.png" /> Windows (ISO) | administrator | 123@@@ |
|
||||
| <img width="16" height="16" src="https://blogs.windows.com/wp-content/uploads/prod/2022/09/cropped-Windows11IconTransparent512-32x32.png" /> Windows (DD) | 镜像用户名 | 镜像密码 |
|
||||
|
||||
> [!TIP]
|
||||
> 如果远程登录 Windows 失败,尝试使用用户名 `.\administrator`
|
||||
|
||||
## 下载(当前系统是 <img width="20" height="20" src="https://www.kernel.org/theme/images/logos/favicon.png" /> Linux)
|
||||
|
||||
国外服务器:
|
||||
|
||||
```bash
|
||||
curl -O https://raw.githubusercontent.com/bin456789/reinstall/main/reinstall.sh
|
||||
```
|
||||
|
||||
国内:
|
||||
国内服务器:
|
||||
|
||||
```bash
|
||||
curl -O https://mirror.ghproxy.com/https://raw.githubusercontent.com/bin456789/reinstall/main/reinstall.sh
|
||||
```
|
||||
|
||||
## 下载(当前系统是 Windows)
|
||||
## 下载(当前系统是 <img width="20" height="20" src="https://blogs.windows.com/wp-content/uploads/prod/2022/09/cropped-Windows11IconTransparent512-32x32.png" /> Windows)
|
||||
|
||||
[无法下载?](#如果-windows-下无法下载脚本)
|
||||
> [!IMPORTANT]
|
||||
> 请先关闭 `Windows Defender` 的 `实时保护` 功能。该功能会阻止 `certutil` 下载任何文件。
|
||||
|
||||
请先关闭 `Windows Defender` 的 `实时保护` 功能。该功能会阻止 `certutil` 下载任何文件
|
||||
<details>
|
||||
|
||||
国外:
|
||||
<summary>😢还是无法下载?</summary>
|
||||
|
||||
### 可尝试以下几种方法
|
||||
|
||||
1. Windows 7 安装此补丁启用 TLS 1.2
|
||||
|
||||
<https://aka.ms/easyfix51044>
|
||||
|
||||
2. 更新 SSL 根证书
|
||||
|
||||
```batch
|
||||
certutil -generateSSTFromWU root.sst
|
||||
certutil -addstore Root root.sst
|
||||
```
|
||||
|
||||
3. 手动下载,通过 `远程桌面` 复制这两个文件
|
||||
|
||||
<https://raw.githubusercontent.com/bin456789/reinstall/main/reinstall.bat>
|
||||
|
||||
<https://raw.githubusercontent.com/bin456789/reinstall/main/reinstall.sh>
|
||||
|
||||
</details>
|
||||
|
||||
国外服务器:
|
||||
|
||||
```batch
|
||||
certutil -urlcache -f -split https://raw.githubusercontent.com/bin456789/reinstall/main/reinstall.bat
|
||||
```
|
||||
|
||||
国内:
|
||||
国内服务器:
|
||||
|
||||
```batch
|
||||
certutil -urlcache -f -split https://mirror.ghproxy.com/https://raw.githubusercontent.com/bin456789/reinstall/main/reinstall.bat
|
||||
@ -73,26 +117,35 @@ certutil -urlcache -f -split https://mirror.ghproxy.com/https://raw.githubuserco
|
||||
|
||||
## 使用
|
||||
|
||||
所有功能均可在 Linux / Windows 下使用
|
||||
> [!TIP]
|
||||
>
|
||||
> 所有功能均可在 Linux / Windows 下使用。
|
||||
>
|
||||
> Linux 下运行 `bash reinstall.sh`
|
||||
>
|
||||
> Windows 下运行 `reinstall.bat`
|
||||
|
||||
- Linux 下运行 `bash reinstall.sh`
|
||||
- Windows 下运行 `reinstall.bat`
|
||||
|
||||
### 功能 1: 安装 Linux
|
||||
### 功能 1: 安装 <img width="16" height="16" src="https://www.kernel.org/theme/images/logos/favicon.png" /> Linux
|
||||
|
||||
- 不输入版本号,则安装最新版
|
||||
- 在虚拟机上,会自动安装精简内核
|
||||
- 不含 boot 分区(Fedora 例外),不含 swap 分区,最大化利用磁盘空间
|
||||
- 在虚拟机上,会自动安装官方精简内核
|
||||
|
||||
> [!TIP]
|
||||
> 安装 Debian / Kali 时,x86 可通过后台 VNC 查看安装进度,ARM 可通过串行控制台查看安装进度。
|
||||
>
|
||||
> 安装其它系统时,可通过多种方式(SSH、HTTP 80 端口、后台 VNC、串行控制台)查看安装进度。
|
||||
|
||||
```bash
|
||||
bash reinstall.sh centos 7|8|9 (8|9 为 stream 版本)
|
||||
oracle 7|8|9
|
||||
alma 8|9
|
||||
rocky 8|9
|
||||
fedora 38|39|40
|
||||
fedora 39|40
|
||||
debian 10|11|12
|
||||
opensuse 15.5|tumbleweed
|
||||
ubuntu 20.04|22.04|24.04
|
||||
alpine 3.16|3.17|3.18|3.19
|
||||
alpine 3.17|3.18|3.19|3.20
|
||||
kali
|
||||
arch
|
||||
gentoo
|
||||
@ -103,11 +156,14 @@ bash reinstall.sh centos 7|8|9 (8|9 为 stream 版本)
|
||||
- 支持 gzip、xz 格式
|
||||
- 静态 IP 的机器 DD Windows,会自动配置好 IP
|
||||
|
||||
> [!TIP]
|
||||
> 可通过多种方式(SSH、HTTP 80 端口、后台 VNC、串行控制台)查看安装进度。
|
||||
|
||||
```bash
|
||||
bash reinstall.sh dd --img https://example.com/xxx.xz
|
||||
```
|
||||
|
||||
### 功能 3: 重启到 Alpine 救援系统 (Live OS)
|
||||
### 功能 3: 重启到 <img width="16" height="16" src="https://www.alpinelinux.org/alpine-logo.ico" /> Alpine 救援系统 (Live OS)
|
||||
|
||||
- 可用 ssh 连接,进行手动 DD、修改分区、手动安装 Arch / Gentoo 等操作
|
||||
- 如果没有修改硬盘内容,再次重启将回到原系统
|
||||
@ -116,7 +172,7 @@ bash reinstall.sh dd --img https://example.com/xxx.xz
|
||||
bash reinstall.sh alpine --hold=1
|
||||
```
|
||||
|
||||
### 功能 4: 重启到 netboot.xyz
|
||||
### 功能 4: 重启到 <img width="16" height="16" src="https://netboot.xyz/img/favicon.ico" /> netboot.xyz
|
||||
|
||||
- 可使用商家后台 VNC 安装 [更多系统](https://github.com/netbootxyz/netboot.xyz?tab=readme-ov-file#what-operating-systems-are-currently-available-on-netbootxyz)
|
||||
- 如果没有修改硬盘内容,再次重启将回到原系统
|
||||
@ -127,10 +183,17 @@ bash reinstall.sh netboot.xyz
|
||||
|
||||
![netboot.xyz](https://netboot.xyz/images/netboot.xyz.gif)
|
||||
|
||||
### 功能 5: 安装 Windows ISO
|
||||
### 功能 5: 安装 <img width="16" height="16" src="https://blogs.windows.com/wp-content/uploads/prod/2022/09/cropped-Windows11IconTransparent512-32x32.png" /> Windows ISO
|
||||
|
||||
- 注意参数两边的引号
|
||||
- 支持自动查找部分 iso 链接,需设置语言 `--lang`,默认 `en-us`
|
||||
- 支持自动查找大部分 iso 链接,需指定语言 `--lang`,默认 `en-us`
|
||||
- 静态 IP 的机器,安装后会自动配置好 IP
|
||||
- 能够绕过 Windows 11 安装限制
|
||||
|
||||
> [!TIP]
|
||||
> 脚本以 <https://massgrave.dev/genuine-installation-media.html> 作为 iso 镜像查找源。所有 iso 都是官方原版。
|
||||
|
||||
> [!IMPORTANT]
|
||||
> 注意参数两边有引号。
|
||||
|
||||
```bash
|
||||
bash reinstall.sh windows \
|
||||
@ -146,9 +209,28 @@ bash reinstall.sh windows \
|
||||
--iso 'https://drive.massgrave.dev/en-us_windows_10_enterprise_ltsc_2021_x64_dvd_d289cf96.iso'
|
||||
```
|
||||
|
||||
<details>
|
||||
|
||||
<summary>以下网站可找到 iso 链接</summary>
|
||||
|
||||
- Massgrave
|
||||
- <https://massgrave.dev/genuine-installation-media.html> (推荐,iso 来自官方,每月更新,包含最新补丁)
|
||||
- 微软
|
||||
- <https://www.microsoft.com/software-download/windows8>
|
||||
- <https://www.microsoft.com/software-download/windows10> (需用手机 User-Agent 打开)
|
||||
- <https://www.microsoft.com/software-download/windows11>
|
||||
- <https://www.microsoft.com/evalcenter/download-windows-10-enterprise>
|
||||
- <https://www.microsoft.com/evalcenter/download-windows-11-enterprise>
|
||||
- <https://www.microsoft.com/evalcenter/download-windows-server-2012-r2>
|
||||
- <https://www.microsoft.com/evalcenter/download-windows-server-2016>
|
||||
- <https://www.microsoft.com/evalcenter/download-windows-server-2019>
|
||||
- <https://www.microsoft.com/evalcenter/download-windows-server-2022>
|
||||
|
||||
</details>
|
||||
|
||||
![Installing Windows](https://github.com/bin456789/reinstall/assets/7548515/07c1aea2-1ce3-4967-904f-aaf9d6eec3f7)
|
||||
|
||||
参数说明:
|
||||
#### 参数说明
|
||||
|
||||
`--image-name` 指定要安装的映像,不区分大小写,常用映像有:
|
||||
|
||||
@ -163,78 +245,36 @@ Windows Server 2022 SERVERDATACENTER
|
||||
|
||||
![image-name](https://github.com/bin456789/reinstall/assets/7548515/5aae0a9b-61e2-4f66-bb98-d470a6beaac2)
|
||||
|
||||
1. 支持的系统:
|
||||
- Windows Vista 到 11
|
||||
- Windows Server 2008 到 2022,包括以下衍生版
|
||||
#### 支持的系统
|
||||
|
||||
- Windows (Vista ~ 11)
|
||||
- Windows Server (2008 ~ 2022)
|
||||
- Windows Server Essentials
|
||||
- Windows Server Annual Channel
|
||||
- Windows Server (Semi) Annual Channel
|
||||
- Hyper-V Server
|
||||
- Azure Stack HCI
|
||||
2. 脚本会按需安装以下驱动:
|
||||
|
||||
#### 脚本会按需安装以下驱动
|
||||
|
||||
- KVM ([Virtio](https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/))
|
||||
- XEN ([XEN](https://xenproject.org/windows-pv-drivers/)、[Citrix](https://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/Upgrading_PV_drivers.html#win2008-citrix-upgrade)、[AWS](https://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/xen-drivers-overview.html))
|
||||
- AWS ([ENA 网卡](https://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/enhanced-networking-ena.html)、[NVME 存储控制器](https://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/aws-nvme-drivers.html))
|
||||
- GCP ([gVNIC 网卡](https://cloud.google.com/compute/docs/networking/using-gvnic)、[GGA 显卡](https://cloud.google.com/compute/docs/instances/enable-instance-virtual-display))
|
||||
- Azure ([MANA 网卡](https://learn.microsoft.com/azure/virtual-network/accelerated-networking-mana-windows))
|
||||
3. Vista (Server 2008) 和 32 位系统可能会缺少驱动
|
||||
4. 未开启 CSM 的 EFI 机器,无法安装 Windows 7 (Server 2008 R2)
|
||||
5. 静态 IP 的机器,安装后会自动配置好 IP
|
||||
6. 可绕过 Windows 11 硬件限制
|
||||
7. 支持 Windows 11 on ARM,仅限 Hyper-V (Azure) ,不支持 KVM (甲骨文云)
|
||||
8. `zh-cn_windows_10_enterprise_ltsc_2021_x64_dvd_033b7312.iso` 此镜像安装后 `wsappx` 进程会长期占用 CPU
|
||||
|
||||
这是镜像的问题,解决方法是安装 `VCLibs` 库
|
||||
> [!WARNING]
|
||||
> Vista (Server 2008) 和 32 位系统可能会缺少驱动
|
||||
|
||||
<https://www.google.com/search?q=ltsc+wsappx>
|
||||
> [!WARNING]
|
||||
> 未开启 CSM 的 EFI 机器,无法安装 Windows 7 (Server 2008 R2)
|
||||
|
||||
9. 以下网站可找到 iso 链接
|
||||
> [!WARNING]
|
||||
> 支持 ARM 机器安装 Windows 11,仅限于 Hyper-V (Azure) ,不支持 KVM (甲骨文云)
|
||||
|
||||
<https://massgrave.dev/genuine-installation-media.html> (推荐,iso 来自官方,每月更新,包含最新补丁)
|
||||
|
||||
<https://www.microsoft.com/software-download/windows8>
|
||||
|
||||
<https://www.microsoft.com/software-download/windows10> (需用手机 User-Agent 打开)
|
||||
|
||||
<https://www.microsoft.com/software-download/windows11>
|
||||
|
||||
## 虚拟化要求
|
||||
|
||||
不支持 OpenVZ、LXC 虚拟机
|
||||
|
||||
请使用 <https://github.com/LloydAsp/OsMutation>
|
||||
|
||||
## 默认密码
|
||||
|
||||
| 系统 | 用户名 | 密码 |
|
||||
| ------------- | ------------- | -------- |
|
||||
| Linux | root | 123@@@ |
|
||||
| Windows (iso) | administrator | 123@@@ |
|
||||
| Windows (dd) | 镜像用户名 | 镜像密码 |
|
||||
|
||||
如果远程登录 Windows 提示密码错误,尝试用户名 `.\administrator`
|
||||
|
||||
## 如果 Windows 下无法下载脚本
|
||||
|
||||
可尝试以下几种方法
|
||||
|
||||
1. 关闭 Windows Defender 实时保护
|
||||
|
||||
2. Windows 7 安装此补丁启用 TLS 1.2
|
||||
|
||||
<https://aka.ms/easyfix51044>
|
||||
|
||||
3. 更新 SSL 根证书
|
||||
|
||||
```batch
|
||||
certutil -generateSSTFromWU root.sst
|
||||
certutil -addstore Root root.sst
|
||||
```
|
||||
|
||||
4. 手动下载,通过 `远程桌面` 复制这两个文件
|
||||
|
||||
<https://raw.githubusercontent.com/bin456789/reinstall/main/reinstall.bat>
|
||||
|
||||
<https://raw.githubusercontent.com/bin456789/reinstall/main/reinstall.sh>
|
||||
> [!WARNING]
|
||||
> Windows 10 LTSC 2021 中文版镜像 `zh-cn_windows_10_enterprise_ltsc_2021_x64_dvd_033b7312.iso` 的 `wsappx` 进程会长期占用 CPU
|
||||
>
|
||||
> 解决方法是更新系统补丁,或者手动安装 `VCLibs` 库 <https://www.google.com/search?q=ltsc+wsappx>
|
||||
|
||||
## 感谢
|
||||
|
||||
|
@ -190,10 +190,12 @@ fix_wicked_conf() {
|
||||
}
|
||||
|
||||
# debian 10/11/12: netplan + networkd/resolved
|
||||
# 23.1.1 修复
|
||||
fix_netplan_conf
|
||||
|
||||
# arch: networkd/resolved
|
||||
# gentoo: networkd/resolved
|
||||
# 24.2 修复
|
||||
fix_networkd_conf
|
||||
|
||||
# opensuse 15.5: ifcfg + netconfig (dns) + wicked
|
||||
|
20
debian.cfg
20
debian.cfg
@ -1,4 +1,5 @@
|
||||
# shellcheck disable=SC2148,SC2154
|
||||
#_preseed_V1
|
||||
# shellcheck disable=SC1091,SC2148
|
||||
# https://www.debian.org/releases/stable/amd64/apbs04.zh-cn.html
|
||||
# https://www.debian.org/releases/stable/example-preseed.txt
|
||||
# https://preseed.debian.net/debian-preseed/bookworm/amd64-main-full.txt
|
||||
@ -109,6 +110,8 @@ d-i finish-install/reboot_in_progress note
|
||||
# B.5.1. 安装过程中运行用户命令
|
||||
# 注意所有命令都会合并成一行命令
|
||||
|
||||
# 最后的 true; \ 没什么用,只是让 vscode 代码高亮不报错误
|
||||
|
||||
# 有 /cdrom/simple-cdd 才安装 simple-cdd-profiles
|
||||
# 不然安装时 control 脚本会报错:
|
||||
# Loading simple-cdd-profiles failed for unknown reasons
|
||||
@ -118,16 +121,19 @@ d-i preseed/early_command string true; \
|
||||
# debian 11 initrd 没有 xargs awk
|
||||
# debian 12 initrd 没有 xargs
|
||||
# efi 分区大小未改变时,不会被格式化,因此需要手动删除旧系统的 efi 文件
|
||||
# os-prober 卡太久,因此跳过
|
||||
d-i partman/early_command string true; \
|
||||
confhome="$(grep -o 'extra\.confhome=[^ ]*' /proc/cmdline | cut -d= -f2)"; \
|
||||
|
||||
swapfile=/target/swapfile; \
|
||||
postinst=/var/lib/dpkg/info/bootstrap-base.postinst; \
|
||||
cp $postinst $postinst.orig; \
|
||||
true >$postinst; \
|
||||
|
||||
mem=$(grep ^MemTotal: /proc/meminfo | { read x y z; echo $y; }); \
|
||||
swapfile=/target/swapfile; \
|
||||
mem=$(grep ^MemTotal: /proc/meminfo | { read -r _ y _; echo "$y"; }); \
|
||||
mem=$((mem / 1024)); \
|
||||
swap_size=$((512 - mem)); \
|
||||
[ $swap_size -gt 0 ] && echo "fallocate -l ${swap_size}M $swapfile; mkswap $swapfile; swapon $swapfile; $postinst.orig" >$postinst; \
|
||||
[ $swap_size -gt 0 ] && echo "fallocate -l ${swap_size}M $swapfile; mkswap $swapfile; swapon $swapfile" >>$postinst; \
|
||||
|
||||
echo "swapoff -a; rm -f $swapfile" >/usr/lib/finish-install.d/95swapoff; \
|
||||
chmod a+x /usr/lib/finish-install.d/95swapoff; \
|
||||
@ -139,7 +145,7 @@ d-i preseed/early_command string true; \
|
||||
debconf-set grub-installer/bootdev "/dev/$xda"; \
|
||||
rm -rf /usr/sbin/fdisk /usr/sbin/sfdisk; \
|
||||
|
||||
ttys=$(wget --tries=5 $confhome/ttys.sh -O- | sh -s console=); \
|
||||
ttys=$(wget --tries=5 "$confhome/ttys.sh" -O- | sh -s console=); \
|
||||
debconf-set debian-installer/add-kernel-opts "$ttys"; \
|
||||
|
||||
sh /can_use_cloud_kernel.sh "$xda" || debconf-set base-installer/kernel/image "$(debconf-get base-installer/kernel/image | sed 's/-cloud//')"; \
|
||||
@ -149,11 +155,9 @@ d-i preseed/early_command string true; \
|
||||
|
||||
true >/bin/os-prober
|
||||
|
||||
# os-prober 卡太久,因此跳过
|
||||
|
||||
# debian 10 没有 /target/etc/ssh/sshd_config.d/ 文件夹
|
||||
# kali ssh 默认关闭
|
||||
d-i preseed/late_command string \
|
||||
d-i preseed/late_command string true; \
|
||||
in-target systemctl enable ssh; \
|
||||
echo "PermitRootLogin yes" >/target/etc/ssh/sshd_config.d/01-permitrootlogin.conf || \
|
||||
echo "PermitRootLogin yes" >>/target/etc/ssh/sshd_config
|
||||
|
@ -48,6 +48,7 @@ if not errorlevel 1 (
|
||||
)
|
||||
)
|
||||
) else (
|
||||
rem 服务器在美国 equinix 机房,不是 cdn
|
||||
set mirror=http://mirrors.kernel.org
|
||||
)
|
||||
|
||||
|
104
reinstall.sh
104
reinstall.sh
@ -30,11 +30,11 @@ Usage: $reinstall____ centos 7|8|9
|
||||
oracle 7|8|9
|
||||
alma 8|9
|
||||
rocky 8|9
|
||||
fedora 38|39|40
|
||||
fedora 39|40
|
||||
debian 10|11|12
|
||||
ubuntu 20.04|22.04|24.04
|
||||
alpine 3.16|3.17|3.18|3.19
|
||||
opensuse 15.5|tumbleweed
|
||||
ubuntu 20.04|22.04|24.04
|
||||
alpine 3.17|3.18|3.19|3.20
|
||||
kali
|
||||
arch
|
||||
gentoo
|
||||
@ -472,15 +472,16 @@ is_have_arm_version() {
|
||||
case "$version" in
|
||||
10)
|
||||
case "$edition" in
|
||||
pro | 'pro for workstations' | education | 'pro education' | enterprise) return ;;
|
||||
pro | education | enterprise | 'pro education' | 'pro for workstations') return ;;
|
||||
'iot enterprise') return ;;
|
||||
'iot enterprise ltsc 2021' | 'enterprise ltsc 2021') return ;;
|
||||
'enterprise ltsc 2021' | 'iot enterprise ltsc 2021') return ;;
|
||||
esac
|
||||
;;
|
||||
11)
|
||||
case "$edition" in
|
||||
pro | 'pro for workstations' | education | 'pro education' | enterprise) return ;;
|
||||
pro | education | enterprise | 'pro education' | 'pro for workstations') return ;;
|
||||
'iot enterprise') return ;;
|
||||
'enterprise ltsc 2024' | 'iot enterprise ltsc 2024' | 'iot enterprise ltsc 2024 subscription') return ;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
@ -567,7 +568,7 @@ get_windows_iso_links() {
|
||||
10)
|
||||
case "$edition" in
|
||||
home | 'home single language') echo consumer ;;
|
||||
pro | 'pro for workstations' | education | 'pro education' | enterprise) echo business ;;
|
||||
pro | education | enterprise | 'pro education' | 'pro for workstations') echo business ;;
|
||||
'iot enterprise') echo 'iot enterprise' ;;
|
||||
'enterprise 2015 ltsb' | 'enterprise 2016 ltsb' | 'enterprise ltsc 2019') echo "$edition" ;;
|
||||
'enterprise ltsc 2021')
|
||||
@ -583,8 +584,10 @@ get_windows_iso_links() {
|
||||
11)
|
||||
case "$edition" in
|
||||
home | 'home single language') echo consumer ;;
|
||||
pro | 'pro for workstations' | education | 'pro education' | enterprise) echo business ;;
|
||||
pro | education | enterprise | 'pro education' | 'pro for workstations') echo business ;;
|
||||
'iot enterprise') echo 'iot enterprise' ;;
|
||||
'enterprise ltsc 2024') echo 'enterprise ltsc 2024' ;;
|
||||
'iot enterprise ltsc 2024' | 'iot enterprise ltsc 2024 subscription') echo 'iot enterprise ltsc 2024' ;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
@ -595,7 +598,7 @@ get_windows_iso_links() {
|
||||
case "$version" in
|
||||
10 | 11)
|
||||
case "$edition" in
|
||||
pro | 'pro for workstations' | education | 'pro education' | enterprise) echo pro ;;
|
||||
pro | education | enterprise | 'pro education' | 'pro for workstations') echo pro ;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
@ -640,7 +643,7 @@ get_windows_iso_links() {
|
||||
error_and_exit "Not support find this iso. Check --image-name or set --iso manually."
|
||||
fi
|
||||
|
||||
curl -L "$page_url" | grep -ioP 'https://.*?.iso' | awk -F/ '{print $NF}' >$tmp/win.list
|
||||
curl -L "$page_url" | grep -ioP 'https://.*?.iso' >$tmp/win.list
|
||||
|
||||
# 如果不是 ltsc ,应该先去除 ltsc 链接,否则最终链接有 ltsc 的
|
||||
# 例如查找 windows 10 iot enterprise,会得到
|
||||
@ -689,9 +692,8 @@ get_windows_iso_link() {
|
||||
for regex in "${regexs[@]}"; do
|
||||
regex=${regex// /_}
|
||||
|
||||
echo "finding: $regex" >&2
|
||||
if file=$(grep -Eix "$regex" "$tmp/win.list" | get_shortest_line | grep .); then
|
||||
iso="https://drive.massgrave.dev/$file"
|
||||
echo "looking for: $regex" >&2
|
||||
if iso=$(grep -Ei "/$regex" "$tmp/win.list" | get_shortest_line | grep .); then
|
||||
return
|
||||
fi
|
||||
done
|
||||
@ -759,22 +761,25 @@ setos() {
|
||||
if is_in_china; then
|
||||
cdimage_mirror=https://mirrors.ustc.edu.cn/debian-cdimage
|
||||
else
|
||||
cdimage_mirror=https://cdimage.debian.org/images
|
||||
cdimage_mirror=https://cdimage.debian.org/images # 在瑞典,不是 cdn
|
||||
# cloud.debian.org 同样在瑞典,不是 cdn
|
||||
fi
|
||||
|
||||
if is_use_cloud_image; then
|
||||
# cloud image
|
||||
is_virt && ci_type=genericcloud || ci_type=generic
|
||||
# 甲骨文 debian 10 amd64 genericcloud vnc 没有显示
|
||||
[ "$releasever" -eq 10 ] && [ "$basearch_alt" = amd64 ] && ci_type=generic
|
||||
# 甲骨文 debian 10 arm64 没有 genericcloud 镜像
|
||||
[ "$releasever" -eq 10 ] && ci_type=generic
|
||||
eval ${step}_img=$cdimage_mirror/cloud/$codename/latest/debian-$releasever-$ci_type-$basearch_alt.qcow2
|
||||
else
|
||||
# 传统安装
|
||||
if is_in_china; then
|
||||
# 部分国内机无法访问 ftp.cn.debian.org
|
||||
# ftp.cn.debian.org 不在国内还严重丢包
|
||||
# https://www.itdog.cn/ping/ftp.cn.debian.org
|
||||
deb_hostname=mirrors.tuna.tsinghua.edu.cn
|
||||
else
|
||||
deb_hostname=deb.debian.org
|
||||
deb_hostname=deb.debian.org # fastly
|
||||
fi
|
||||
mirror=http://$deb_hostname/debian/dists/$codename/main/installer-$basearch_alt/current/images/netboot/debian-installer/$basearch_alt
|
||||
|
||||
@ -800,7 +805,8 @@ setos() {
|
||||
if is_in_china; then
|
||||
deb_hostname=mirrors.tuna.tsinghua.edu.cn
|
||||
else
|
||||
deb_hostname=kali.download
|
||||
# http.kali.org (geoip 重定向) 到 kali.download (cf)
|
||||
deb_hostname=http.kali.org
|
||||
fi
|
||||
codename=kali-rolling
|
||||
mirror=http://$deb_hostname/kali/dists/$codename/main/installer-$basearch_alt/current/images/netboot/debian-installer/$basearch_alt
|
||||
@ -827,6 +833,12 @@ setos() {
|
||||
if is_use_cloud_image; then
|
||||
# cloud image
|
||||
if is_in_china; then
|
||||
# 有的源没有 releases 镜像
|
||||
# https://mirrors.tuna.tsinghua.edu.cn/ubuntu-cloud-images/releases/
|
||||
# https://unicom.mirrors.ustc.edu.cn/ubuntu-cloud-images/releases/
|
||||
# https://mirror.nju.edu.cn/ubuntu-cloud-images/releases/
|
||||
|
||||
# mirrors.cloud.tencent.com
|
||||
ci_mirror=https://mirror.nju.edu.cn/ubuntu-cloud-images
|
||||
else
|
||||
ci_mirror=https://cloud-images.ubuntu.com
|
||||
@ -869,14 +881,14 @@ setos() {
|
||||
if is_in_china; then
|
||||
mirror=https://mirrors.tuna.tsinghua.edu.cn/archlinux
|
||||
else
|
||||
mirror=https://geo.mirror.pkgbuild.com
|
||||
mirror=https://geo.mirror.pkgbuild.com # geoip
|
||||
fi
|
||||
else
|
||||
if is_in_china; then
|
||||
mirror=https://mirrors.tuna.tsinghua.edu.cn/archlinuxarm
|
||||
else
|
||||
# https 证书有问题
|
||||
mirror=http://mirror.archlinuxarm.org
|
||||
mirror=http://mirror.archlinuxarm.org # geoip
|
||||
fi
|
||||
fi
|
||||
|
||||
@ -898,8 +910,7 @@ setos() {
|
||||
if is_in_china; then
|
||||
mirror=https://mirrors.tuna.tsinghua.edu.cn/gentoo
|
||||
else
|
||||
# mirror=https://mirror.leaseweb.com/gentoo # 不支持 ipv6
|
||||
mirror=https://distfiles.gentoo.org
|
||||
mirror=https://distfiles.gentoo.org # cdn77
|
||||
fi
|
||||
|
||||
if is_use_cloud_image; then
|
||||
@ -995,13 +1006,7 @@ setos() {
|
||||
"8" | "9") ci_image=$ci_mirror/$releasever-stream/$basearch/images/CentOS-Stream-GenericCloud-$releasever-latest.$basearch.qcow2 ;;
|
||||
esac
|
||||
;;
|
||||
"alma")
|
||||
# alma8 x86_64 有独立的uefi镜像
|
||||
if [ "$releasever" = 8 ] && is_efi && [ "$basearch" = x86_64 ]; then
|
||||
alma_efi=-UEFI
|
||||
fi
|
||||
ci_image=$ci_mirror/AlmaLinux-$releasever-GenericCloud$alma_efi-latest.$basearch.qcow2
|
||||
;;
|
||||
"alma") ci_image=$ci_mirror/AlmaLinux-$releasever-GenericCloud-latest.$basearch.qcow2 ;;
|
||||
"rocky") ci_image=$ci_mirror/Rocky-$releasever-GenericCloud-Base.latest.$basearch.qcow2 ;;
|
||||
"fedora")
|
||||
# Fedora-Cloud-Base-39-1.5.x86_64.qcow2
|
||||
@ -1128,11 +1133,11 @@ verify_os_name() {
|
||||
'oracle 7|8|9' \
|
||||
'alma 8|9' \
|
||||
'rocky 8|9' \
|
||||
'fedora 38|39|40' \
|
||||
'fedora 39|40' \
|
||||
'debian 10|11|12' \
|
||||
'ubuntu 20.04|22.04|24.04' \
|
||||
'alpine 3.16|3.17|3.18|3.19' \
|
||||
'opensuse 15.5|tumbleweed' \
|
||||
'ubuntu 20.04|22.04|24.04' \
|
||||
'alpine 3.17|3.18|3.19|3.20' \
|
||||
'kali' \
|
||||
'arch' \
|
||||
'gentoo' \
|
||||
@ -1690,7 +1695,7 @@ add_efi_entry_in_linux() {
|
||||
install_pkg efibootmgr
|
||||
|
||||
for efi_part in $(get_maybe_efi_dirs_in_linux); do
|
||||
if find $efi_part -name "*.efi" >/dev/null; then
|
||||
if find $efi_part -iname "*.efi" >/dev/null; then
|
||||
dist_dir=$efi_part/EFI/reinstall
|
||||
basename=$(basename $source)
|
||||
mkdir -p $dist_dir
|
||||
@ -1740,9 +1745,10 @@ install_grub_linux_efi() {
|
||||
|
||||
# 不要用 download.opensuse.org 和 download.fedoraproject.org
|
||||
# 因为 ipv6 访问有时跳转到 ipv4 地址,造成 ipv6 only 机器无法下载
|
||||
# 日韩机器有时得到国内链接,且连不上
|
||||
# 日韩机器有时得到国内镜像源,但镜像源屏蔽了国外 IP 导致连不上
|
||||
# https://mirrors.bfsu.edu.cn/opensuse/ports/aarch64/tumbleweed/repo/oss/EFI/BOOT/grub.efi
|
||||
if [ "$efi_distro" = fedora ]; then
|
||||
fedora_ver=39
|
||||
fedora_ver=40
|
||||
|
||||
if is_in_china; then
|
||||
mirror=https://mirrors.tuna.tsinghua.edu.cn/fedora
|
||||
@ -1770,6 +1776,8 @@ install_grub_win() {
|
||||
# 下载 grub
|
||||
info download grub
|
||||
grub_ver=2.06
|
||||
# ftpmirror.gnu.org 是 geoip 重定向,不是 cdn
|
||||
# 有可能重定义到一个拉黑了部分 IP 的服务器
|
||||
is_in_china && grub_url=https://mirrors.tuna.tsinghua.edu.cn/gnu/grub/grub-$grub_ver-for-windows.zip ||
|
||||
grub_url=https://ftpmirror.gnu.org/gnu/grub/grub-$grub_ver-for-windows.zip
|
||||
curl -Lo $tmp/grub.zip $grub_url
|
||||
@ -1796,6 +1804,7 @@ install_grub_win() {
|
||||
# efi
|
||||
info install grub for efi
|
||||
if [ "$basearch" = aarch64 ]; then
|
||||
# 3.20 是 grub 2.12,可能会有问题
|
||||
alpine_ver=3.19
|
||||
is_in_china && mirror=http://mirrors.tuna.tsinghua.edu.cn/alpine || mirror=https://dl-cdn.alpinelinux.org/alpine
|
||||
grub_efi_apk=$(curl -L $mirror/v$alpine_ver/main/aarch64/ | grep -oP 'grub-efi-.*?apk' | head -1)
|
||||
@ -2436,7 +2445,7 @@ mod_initrd() {
|
||||
|
||||
# 解压
|
||||
# 先删除临时文件,避免之前运行中断有残留文件
|
||||
tmp_dir=$tmp/reinstall
|
||||
tmp_dir=$tmp/initrd
|
||||
mkdir_clear $tmp_dir
|
||||
cd $tmp_dir
|
||||
|
||||
@ -2562,7 +2571,7 @@ else
|
||||
fi
|
||||
|
||||
# 整理参数
|
||||
if ! opts=$(getopt -n $0 -o "" --long ci,debug,hold:,sleep:,iso:,image-name:,img:,lang: -- "$@"); then
|
||||
if ! opts=$(getopt -n $0 -o "" --long ci,debug,hold:,sleep:,iso:,image-name:,img:,lang,commit: -- "$@"); then
|
||||
usage_and_exit
|
||||
fi
|
||||
|
||||
@ -2570,6 +2579,10 @@ eval set -- "$opts"
|
||||
# shellcheck disable=SC2034
|
||||
while true; do
|
||||
case "$1" in
|
||||
--commit)
|
||||
commit=$2
|
||||
shift 2
|
||||
;;
|
||||
--debug)
|
||||
set -x
|
||||
shift
|
||||
@ -2681,10 +2694,25 @@ esac
|
||||
# gitee 不支持ipv6
|
||||
# jsdelivr 有12小时缓存
|
||||
# https://github.com/XIU2/UserScript/blob/master/GithubEnhanced-High-Speed-Download.user.js#L31
|
||||
if [ -n "$github_proxy" ] && [[ "$confhome" = http*://raw.githubusercontent.com/* ]] && is_in_china; then
|
||||
if [ -n "$github_proxy" ] && [[ "$confhome" = http*://raw.githubusercontent.com/* ]]; then
|
||||
# 未测试
|
||||
if false; then
|
||||
repo=$(echo $confhome | cut -d/ -f4,5)
|
||||
branch=$(echo $confhome | cut -d/ -f6)
|
||||
# 避免脚本更新时,文件不同步造成错误
|
||||
if [ -z "$commit" ]; then
|
||||
commit=$(curl -L https://api.github.com/repos/$repo/git/refs/heads/$branch |
|
||||
grep '"sha"' | grep -Eo '[0-9a-f]{40}')
|
||||
fi
|
||||
# shellcheck disable=SC2001
|
||||
confhome=$(echo "$confhome" | sed "s/main$/$commit/")
|
||||
fi
|
||||
|
||||
if is_in_china; then
|
||||
confhome=${confhome/http:\/\//https:\/\/}
|
||||
confhome=${confhome/https:\/\/raw.githubusercontent.com/$github_proxy}
|
||||
fi
|
||||
fi
|
||||
|
||||
# 以下目标系统不需要两步安装
|
||||
# alpine
|
||||
|
50
trans.sh
50
trans.sh
@ -112,7 +112,7 @@ download() {
|
||||
apk add coreutils
|
||||
fi
|
||||
|
||||
# 阿里云源检测 user-agent 禁止 axel/aria2 下载
|
||||
# 阿里云源限速,而且检测 user-agent 禁止 axel/aria2 下载
|
||||
# aria2 默认 --max-tries 5
|
||||
|
||||
# 默认 --max-tries=5,但以下情况服务器出错,aria2不会重试,而是直接返回错误
|
||||
@ -395,10 +395,10 @@ get_netconf_to() {
|
||||
# shellcheck disable=SC2154
|
||||
# debian initrd 没有 xargs
|
||||
case "$1" in
|
||||
slaac) echo "$ra" | grep 'Autonomous address conf' | grep Yes && res=1 || res=0 ;;
|
||||
dhcpv6) echo "$ra" | grep 'Stateful address conf' | grep Yes && res=1 || res=0 ;;
|
||||
slaac) echo "$ra" | grep 'Autonomous address conf' | grep -q Yes && res=1 || res=0 ;;
|
||||
dhcpv6) echo "$ra" | grep 'Stateful address conf' | grep -q Yes && res=1 || res=0 ;;
|
||||
rdnss) res=$(echo "$ra" | grep 'Recursive DNS server' | cut -d: -f2-) ;;
|
||||
other) echo "$ra" | grep 'Stateful other conf' | grep Yes && res=1 || res=0 ;;
|
||||
other) echo "$ra" | grep 'Stateful other conf' | grep -q Yes && res=1 || res=0 ;;
|
||||
*) res=$(cat /dev/$1) ;;
|
||||
esac
|
||||
|
||||
@ -936,7 +936,7 @@ EOF
|
||||
pacstrap -K $os_dir $pkgs
|
||||
|
||||
# dns
|
||||
cp -f /etc/resolv.conf $os_dir/etc/resolv.conf
|
||||
cp_resolv_conf $os_dir
|
||||
|
||||
# 挂载伪文件系统
|
||||
mount_pseudo_fs $os_dir
|
||||
@ -982,7 +982,7 @@ EOF
|
||||
apk del tar xz
|
||||
|
||||
# dns
|
||||
cp -f /etc/resolv.conf $os_dir/etc/resolv.conf
|
||||
cp_resolv_conf $os_dir
|
||||
|
||||
# 挂载伪文件系统
|
||||
mount_pseudo_fs $os_dir
|
||||
@ -1187,7 +1187,7 @@ EOF
|
||||
apk del arch-install-scripts
|
||||
|
||||
# 删除 resolv.conf,不然 systemd-resolved 无法创建软链接
|
||||
rm -f $os_dir/etc/resolv.conf
|
||||
rm_resolv_conf $os_dir
|
||||
|
||||
# 删除 swap
|
||||
swapoff -a
|
||||
@ -1587,7 +1587,7 @@ download_cloud_init_config() {
|
||||
if ! grep -w swap $os_dir/etc/fstab; then
|
||||
# btrfs
|
||||
# 目前只有 arch 和 fedora 镜像使用 btrfs
|
||||
# 等 fedora 38 cloud-init 升级到 v23.3 后删除
|
||||
# 等 fedora 39 cloud-init 升级到 v23.3 后删除
|
||||
if mount | grep 'on /os type btrfs'; then
|
||||
insert_into_file $ci_file after '^runcmd:' <<EOF
|
||||
- btrfs filesystem mkswapfile --size 1G /swapfile
|
||||
@ -1711,12 +1711,16 @@ get_axx64() {
|
||||
esac
|
||||
}
|
||||
|
||||
cp_resolv_conf() {
|
||||
os_dir=$1
|
||||
is_file_or_link() {
|
||||
# -e / -f 坏软连接,返回 false
|
||||
# -L 坏软连接,返回 true
|
||||
if { [ -e $os_dir/etc/resolv.conf ] || [ -L $os_dir/etc/resolv.conf ]; } &&
|
||||
! { [ -e $os_dir/etc/resolv.conf.orig ] || [ -L $os_dir/etc/resolv.conf.orig ]; }; then
|
||||
[ -f $1 ] || [ -L $1 ]
|
||||
}
|
||||
|
||||
cp_resolv_conf() {
|
||||
os_dir=$1
|
||||
if is_file_or_link $os_dir/etc/resolv.conf &&
|
||||
! is_file_or_link $os_dir/etc/resolv.conf.orig; then
|
||||
mv $os_dir/etc/resolv.conf $os_dir/etc/resolv.conf.orig
|
||||
fi
|
||||
cp -f /etc/resolv.conf $os_dir/etc/resolv.conf
|
||||
@ -1729,7 +1733,7 @@ rm_resolv_conf() {
|
||||
|
||||
restore_resolv_conf() {
|
||||
os_dir=$1
|
||||
if [ -f $os_dir/etc/resolv.conf.orig ]; then
|
||||
if is_file_or_link $os_dir/etc/resolv.conf.orig; then
|
||||
mv -f $os_dir/etc/resolv.conf.orig $os_dir/etc/resolv.conf
|
||||
fi
|
||||
}
|
||||
@ -1770,7 +1774,7 @@ EOF
|
||||
# 修复 fedora 38 或以下用静态 ipv6 会掉线
|
||||
# el 全系也用 NetworkManager,但他们的配置文件是 sysconfig,因此不受影响
|
||||
# https://github.com/canonical/cloud-init/commit/5d440856cb6d2b4c908015fe4eb7227615c17c8b
|
||||
if grep -E 'fedora:38' $os_dir/etc/os-release; then
|
||||
if false && grep -E 'fedora:38' $os_dir/etc/os-release; then
|
||||
network_manager_py=$os_dir/usr/lib/python3.11/site-packages/cloudinit/net/network_manager.py
|
||||
if ! grep '"static6": "manual",' $network_manager_py; then
|
||||
echo '"static6": "manual",' | insert_into_file $network_manager_py after '"static": "manual",'
|
||||
@ -1850,19 +1854,18 @@ EOF
|
||||
add_onlink_script_if_need
|
||||
|
||||
# 同步证书
|
||||
rm $os_dir/etc/resolv.conf
|
||||
cp /etc/resolv.conf $os_dir/etc/resolv.conf
|
||||
cp_resolv_conf $os_dir
|
||||
mount_pseudo_fs $os_dir
|
||||
chroot $os_dir pacman-key --init
|
||||
chroot $os_dir pacman-key --populate
|
||||
rm $os_dir/etc/resolv.conf
|
||||
rm_resolv_conf $os_dir
|
||||
fi
|
||||
|
||||
# gentoo
|
||||
if [ -f $os_dir/etc/gentoo-release ]; then
|
||||
# 挂载伪文件系统
|
||||
mount_pseudo_fs $os_dir
|
||||
cp -f /etc/resolv.conf $os_dir/etc/resolv.conf
|
||||
cp_resolv_conf $os_dir
|
||||
|
||||
# 在这里修改密码,而不是用cloud-init,因为我们的默认密码太弱
|
||||
sed -i 's/enforce=everyone/enforce=none/' $os_dir/etc/security/passwdqc.conf
|
||||
@ -1876,7 +1879,7 @@ EOF
|
||||
chroot $os_dir eselect profile set $profile
|
||||
|
||||
# 删除 resolv.conf,不然 systemd-resolved 无法创建软链接
|
||||
rm -f $os_dir/etc/resolv.conf
|
||||
rm_resolv_conf $os_dir
|
||||
|
||||
# 启用网络服务
|
||||
chroot $os_dir systemctl enable systemd-networkd
|
||||
@ -2201,7 +2204,7 @@ install_qcow_by_copy() {
|
||||
|
||||
modify_el_ol() {
|
||||
# resolv.conf
|
||||
cp /etc/resolv.conf /os/etc/resolv.conf
|
||||
cp_resolv_conf /os
|
||||
|
||||
# selinux kdump
|
||||
disable_selinux_kdump /os
|
||||
@ -2219,6 +2222,7 @@ install_qcow_by_copy() {
|
||||
# 删除云镜像自带的 dhcp 配置,防止歧义
|
||||
# clout-init 网络配置在 /etc/sysconfig/network-scripts/
|
||||
rm -rf /os/etc/NetworkManager/system-connections/*.nmconnection
|
||||
rm -rf /os/etc/sysconfig/network-scripts/ifcfg-*
|
||||
|
||||
# 为 centos 7 ci 安装 NetworkManager
|
||||
# 1. 能够自动配置 onlink 网关
|
||||
@ -2332,14 +2336,13 @@ EOF
|
||||
fi
|
||||
|
||||
# 不删除可能网络管理器不会写入dns
|
||||
rm -f /os/etc/resolv.conf
|
||||
rm_resolv_conf /os
|
||||
}
|
||||
|
||||
modify_ubuntu() {
|
||||
os_dir=/os
|
||||
|
||||
mv $os_dir/etc/resolv.conf $os_dir/etc/resolv.conf.orig
|
||||
cp /etc/resolv.conf $os_dir/etc/resolv.conf
|
||||
cp_resolv_conf $os_dir
|
||||
|
||||
# 关闭 os prober,因为 os prober 有时很慢
|
||||
cp $os_dir/etc/default/grub $os_dir/etc/default/grub.orig
|
||||
@ -3375,6 +3378,7 @@ if [ "$hold" = 2 ]; then
|
||||
exit
|
||||
fi
|
||||
|
||||
cd /
|
||||
# 让 web 输出全部内容
|
||||
sleep 5
|
||||
reboot
|
||||
|
Loading…
x
Reference in New Issue
Block a user