mirror of
https://github.com/bin456789/reinstall.git
synced 2026-04-09 17:57:47 +08:00
Compare commits
69 Commits
ce8a315a2e
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 2d676731bb | |||
| 93e83dfc58 | |||
| e93d71680c | |||
| f0fc83a060 | |||
| 07d8018db3 | |||
| e104735538 | |||
| 43e226cc5c | |||
| c6000c16ab | |||
| 8dd873d7dd | |||
| 41c4df9fdb | |||
| f0b3a475fc | |||
| 5e2f46444c | |||
| c784479408 | |||
| ca11ab5ef8 | |||
| 2c6b28108a | |||
| 28119bb0c5 | |||
| 53e699fa11 | |||
| b2f2927c4e | |||
| 13e3155d02 | |||
| 5b1b9103f4 | |||
| 5b0d91c633 | |||
| ecacaab103 | |||
| 99b99cc7ac | |||
| 81081873df | |||
| 4cf8e81fc7 | |||
| ff4b6de258 | |||
| fc7bdc5711 | |||
| f2cfe672d1 | |||
| 0cc3fc77d6 | |||
| 6a35bf681a | |||
| e7f8802bdd | |||
| 259bcf7275 | |||
| 90becc9850 | |||
| 85e2661161 | |||
| 74d9524a9b | |||
| 1a3d8b4f3b | |||
| 0c5fac6d6b | |||
| e60a8d0de2 | |||
| 2a561f0d8c | |||
| 586eb5dee1 | |||
| c94f334663 | |||
| bd5e118570 | |||
| 78ba0690f9 | |||
| 9e0968eabd | |||
| 3263ea3875 | |||
| 7c19559d86 | |||
| 8b838f8871 | |||
| 5bf00edeed | |||
| 85637edc5b | |||
| baa430eb10 | |||
| 66f3173c7b | |||
| af84ac0b3c | |||
| 57a88a6bd9 | |||
| 24a4446a02 | |||
| 780e1a694f | |||
| 43ba86076f | |||
| f22cda1f10 | |||
| 28e10128ff | |||
| 974d5712f0 | |||
| 845fa66e03 | |||
| 48823b4101 | |||
| d212eb793c | |||
| aa1fc741fa | |||
| 74665b65cc | |||
| 6708c77c63 | |||
| 1afc1a0022 | |||
| cdf09d017f | |||
| 8d55af091d | |||
| 8689c45b07 |
@ -23,3 +23,6 @@ charset = utf-8-bom
|
||||
|
||||
[*.{yml,yaml}]
|
||||
indent_size = 2
|
||||
|
||||
[reinstall.sh]
|
||||
shell_variant = bash
|
||||
|
||||
21
.github/workflows/run_reinstall.yml
vendored
21
.github/workflows/run_reinstall.yml
vendored
@ -21,23 +21,26 @@ jobs:
|
||||
git config --global core.autocrlf false
|
||||
- uses: actions/checkout@v4
|
||||
- run: |
|
||||
${{ matrix.command }} centos
|
||||
${{ matrix.command }} almalinux 8
|
||||
${{ matrix.command }} rocky 9
|
||||
${{ matrix.command }} fedora
|
||||
# ${{ matrix.command }} centos
|
||||
${{ matrix.command }} almalinux
|
||||
# ${{ matrix.command }} rocky
|
||||
# ${{ matrix.command }} fedora
|
||||
# ${{ matrix.command }} oracle
|
||||
${{ matrix.command }} ubuntu
|
||||
${{ matrix.command }} debian
|
||||
${{ matrix.command }} debian --ci
|
||||
${{ matrix.command }} kali
|
||||
${{ matrix.command }} alpine
|
||||
${{ matrix.command }} opensuse
|
||||
${{ matrix.command }} arch
|
||||
${{ matrix.command }} gentoo
|
||||
# ${{ matrix.command }} kali
|
||||
# ${{ matrix.command }} alpine
|
||||
# ${{ matrix.command }} opensuse
|
||||
# ${{ matrix.command }} arch
|
||||
# ${{ matrix.command }} gentoo
|
||||
|
||||
${{ matrix.command }} netboot.xyz
|
||||
${{ matrix.command }} dd --img=https://download.opensuse.org/tumbleweed/appliances/openSUSE-MicroOS.x86_64-SelfInstall.raw.xz
|
||||
${{ matrix.command }} windows --image-name='Windows Server blah' --iso https://aka.ms/HCIReleaseImage
|
||||
|
||||
${{ matrix.command }} reset
|
||||
|
||||
# 测试失败例子
|
||||
# ${{ matrix.command }} wrong-os
|
||||
# ${{ matrix.command }} dd --img=https://github.com/
|
||||
|
||||
204
README.en.md
204
README.en.md
@ -4,7 +4,8 @@
|
||||
|
||||
[](https://app.codacy.com/gh/bin456789/reinstall/dashboard)
|
||||
[](https://www.codefactor.io/repository/github/bin456789/reinstall)
|
||||
[](https://github.com/XAMPPRocky/tokei_rs)
|
||||
[](https://github.com/aschey/vercel-tokei)
|
||||
<!-- [](https://github.com/XAMPPRocky/tokei_rs) -->
|
||||
|
||||
One-Click system reinstallation script for VPS [中文](README.md)
|
||||
|
||||
@ -34,9 +35,10 @@ If this helped you, you can buy me a milk tea.
|
||||
- [Download](#download-current-system-is--linux)
|
||||
- [Feature 1. One-click reinstallation to Linux](#feature-1-install--linux)
|
||||
- [Feature 2. One-click DD Raw image to hard disk](#feature-2-dd-raw-image-to-hard-disk)
|
||||
- [Feature 3. One-click reboot to Alpine Live OS in-memory system](#feature-3-reboot-to--alpine-live-os-ram-os)
|
||||
- [Feature 3. One-click reboot to Alpine Live OS](#feature-3-reboot-to--alpine-live-os)
|
||||
- [Feature 4. One-click reboot to netboot.xyz](#feature-4-reboot-to--netbootxyz)
|
||||
- [Feature 5. One-click reinstallation to Windows](#feature-5-install--windows-iso)
|
||||
- [Cancel the reinstallation](#cancel-the-reinstallation)
|
||||
|
||||
## System Requirements
|
||||
|
||||
@ -46,22 +48,22 @@ The system requirements for the target system are as follows:
|
||||
|
||||
| System | Version | Memory | Disk |
|
||||
| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------- | --------- | ---------------- |
|
||||
| <img width="16" height="16" src="https://www.alpinelinux.org/alpine-logo.ico" /> Alpine | 3.19, 3.20, 3.21, 3.22 | 256 MB | 1 GB |
|
||||
| <img width="16" height="16" src="https://www.alpinelinux.org/alpine-logo.ico" /> Alpine | 3.20, 3.21, 3.22, 3.23 | 256 MB | 1 GB |
|
||||
| <img width="16" height="16" src="https://www.debian.org/favicon.ico" /> Debian | 9, 10, 11, 12, 13 | 256 MB | 1 ~ 1.5 GB ^ |
|
||||
| <img width="16" height="16" src="https://github.com/bin456789/reinstall/assets/7548515/f74b3d5b-085f-4df3-bcc9-8a9bd80bb16d" /> Kali | Rolling | 256 MB | 1 ~ 1.5 GB ^ |
|
||||
| <img width="16" height="16" src="https://documentation.ubuntu.com/server/_static/favicon.png" /> Ubuntu | 16.04 LTS - 24.04 LTS, 25.04 | 512 MB \* | 2 GB |
|
||||
| <img width="16" height="16" src="https://documentation.ubuntu.com/server/_static/favicon.png" /> Ubuntu | 16.04 LTS - 24.04 LTS, 25.10 | 512 MB \* | 2 GB |
|
||||
| <img width="16" height="16" src="https://img.alicdn.com/imgextra/i1/O1CN01oJnJZg1yK4RzI4Rx2_!!6000000006559-2-tps-118-118.png" /> Anolis | 7, 8, 23 | 512 MB \* | 5 GB |
|
||||
| <img width="16" height="16" src="https://www.redhat.com/favicon.ico" /> RHEL <img width="16" height="16" src="https://almalinux.org/fav/favicon.ico" /> AlmaLinux <img width="16" height="16" src="https://rockylinux.org/favicon.png" /> Rocky <img width="16" height="16" src="https://www.oracle.com/asset/web/favicons/favicon-32.png" /> Oracle | 8, 9, 10 (if released) | 512 MB \* | 5 GB |
|
||||
| <img width="16" height="16" src="https://www.redhat.com/favicon.ico" /> RHEL <img width="16" height="16" src="https://almalinux.org/fav/favicon.ico" /> AlmaLinux <img width="16" height="16" src="https://rockylinux.org/favicon.png" /> Rocky <img width="16" height="16" src="https://www.oracle.com/asset/web/favicons/favicon-32.png" /> Oracle | 8, 9, 10 | 512 MB \* | 5 GB |
|
||||
| <img width="16" height="16" src="https://opencloudos.org/qq.ico" /> OpenCloudOS | 8, 9, Stream 23 | 512 MB \* | 5 GB |
|
||||
| <img width="16" height="16" src="https://www.centos.org/assets/icons/favicon.svg" /> CentOS Stream | 9, 10 | 512 MB \* | 5 GB |
|
||||
| <img width="16" height="16" src="https://fedoraproject.org/favicon.ico" /> Fedora | 41, 42 | 512 MB \* | 5 GB |
|
||||
| <img width="16" height="16" src="https://www.openeuler.org/favicon.ico" /> openEuler | 20.03 LTS - 24.03 LTS, 25.03 | 512 MB \* | 5 GB |
|
||||
| <img width="16" height="16" src="https://static.opensuse.org/favicon.ico" /> openSUSE | Leap 15.6, Tumbleweed (Rolling) | 512 MB \* | 5 GB |
|
||||
| <img width="16" height="16" src="https://nixos.org/favicon.svg" /> NixOS | 25.05 | 512 MB | 5 GB |
|
||||
| <img width="16" height="16" src="https://fedoraproject.org/favicon.ico" /> Fedora | 42, 43 | 512 MB \* | 5 GB |
|
||||
| <img width="16" height="16" src="https://www.openeuler.org/favicon.ico" /> openEuler | 20.03 LTS - 24.03 LTS, 25.09 | 512 MB \* | 5 GB |
|
||||
| <img width="16" height="16" src="https://static.opensuse.org/favicon.ico" /> openSUSE | Leap 15.6, 16.0, Tumbleweed (Rolling) | 512 MB \* | 5 GB |
|
||||
| <img width="16" height="16" src="https://nixos.org/favicon.svg" /> NixOS | 25.11 | 512 MB | 5 GB |
|
||||
| <img width="16" height="16" src="https://archlinux.org/static/favicon.png" /> Arch | Rolling | 512 MB | 5 GB |
|
||||
| <img width="16" height="16" src="https://www.gentoo.org/assets/img/logo/gentoo-g.png" /> Gentoo | Rolling | 512 MB | 5 GB |
|
||||
| <img width="16" height="16" src="https://aosc.io/assets/distros/aosc-os.svg" /> AOSC OS | Rolling | 512 MB | 5 GB |
|
||||
| <img width="16" height="16" src="https://www.fnnas.com/favicon.ico" /> fnOS | Beta | 512 MB | 8 GB |
|
||||
| <img width="16" height="16" src="https://aosc.io/distros/aosc-os.svg" /> AOSC OS | Rolling | 512 MB | 5 GB |
|
||||
| <img width="16" height="16" src="https://www.fnnas.com/favicon.ico" /> fnOS | 1 | 512 MB | 8 GB |
|
||||
| <img width="16" height="16" src="https://blogs.windows.com/wp-content/uploads/prod/2022/09/cropped-Windows11IconTransparent512-32x32.png" /> Windows (DD) | Any | 512 MB | Depends on image |
|
||||
| <img width="16" height="16" src="https://blogs.windows.com/wp-content/uploads/prod/2022/09/cropped-Windows11IconTransparent512-32x32.png" /> Windows (ISO) | Vista, 7, 8.x (Server 2008 - 2012 R2) | 512 MB | 25 GB |
|
||||
| <img width="16" height="16" src="https://blogs.windows.com/wp-content/uploads/prod/2022/09/cropped-Windows11IconTransparent512-32x32.png" /> Windows (ISO) | 10, 11 (Server 2016 - 2025) | 1 GB | 25 GB |
|
||||
@ -143,34 +145,34 @@ certutil -urlcache -f -split https://cnb.cool/bin456789/reinstall/-/git/raw/main
|
||||
>
|
||||
> This feature will erase **the entire hard disk** of the current system (including other partitions)!
|
||||
>
|
||||
> Data is priceless — please think twice before proceeding!
|
||||
> If the script was run by mistake, you can run `bash reinstall.sh reset` before rebooting to cancel the reinstallation operation.
|
||||
|
||||
- The username is `root` with a default password of `123@@@`.
|
||||
- Username `root`. The script prompts for a password. If left blank, a random one is generated.
|
||||
- When installing the latest version, the version number does not need to be specified.
|
||||
- Maximizes disk space usage: no boot partition (except for Fedora) and no swap partition.
|
||||
- Automatically selects different optimized kernels based on machine type, such as `Cloud` or `HWE` kernels.
|
||||
- When installing Red Hat, you must provide the `qcow2` image link obtained from <https://access.redhat.com/downloads/content/rhel>. You can also install other RHEL-based OS, such as `Alibaba Cloud Linux` and `TencentOS Server`.
|
||||
- When installing Red Hat, you must provide the `qcow2` image link obtained from <https://access.redhat.com/downloads/content/rhel>. You can also install `qcow2` of other RHEL-based OS, such as `Alibaba Cloud Linux` and `TencentOS Server`.
|
||||
- After reinstallation, if you need to change the SSH port or switch to key-based login, make sure to also modify the files inside `/etc/ssh/sshd_config.d/`.
|
||||
|
||||
```bash
|
||||
bash reinstall.sh anolis 7|8|23
|
||||
rocky 8|9|10
|
||||
oracle 8|9
|
||||
oracle 8|9|10
|
||||
almalinux 8|9|10
|
||||
opencloudos 8|9|23
|
||||
centos 9|10
|
||||
fedora 41|42
|
||||
nixos 25.05
|
||||
fnos 1
|
||||
nixos 25.11
|
||||
fedora 42|43
|
||||
debian 9|10|11|12|13
|
||||
opensuse 15.6|tumbleweed
|
||||
alpine 3.19|3.20|3.21|3.22
|
||||
openeuler 20.03|22.03|24.03|25.03
|
||||
ubuntu 16.04|18.04|20.04|22.04|24.04|25.04 [--minimal]
|
||||
alpine 3.20|3.21|3.22|3.23
|
||||
opensuse 15.6|16.0|tumbleweed
|
||||
openeuler 20.03|22.03|24.03|25.09
|
||||
ubuntu 16.04|18.04|20.04|22.04|24.04|25.10 [--minimal]
|
||||
kali
|
||||
arch
|
||||
gentoo
|
||||
aosc
|
||||
fnos
|
||||
redhat --img="http://access.cdn.redhat.com/xxx.qcow2"
|
||||
```
|
||||
|
||||
@ -180,14 +182,17 @@ bash reinstall.sh anolis 7|8|23
|
||||
- `--ssh-key KEY` Set up SSH login public key, [formatted as follows](#--ssh-key). When using public key, password is empty.
|
||||
- `--ssh-port PORT` Change the SSH port (for log observation during installation and for the new system)
|
||||
- `--web-port PORT` Change the Web port (for log observation during installation only)
|
||||
- `--frpc-toml /path/to/frpc.toml` Add frpc for intranet tunneling
|
||||
- `--hold 2` Prevent reboot after installation completes, allowing SSH login to modify system content; the system is mounted at `/os` (this feature is not supported on Debian/Kali).
|
||||
- `--frpc-config PATH` Add frpc for intranet tunneling. Parameter can be local filepath or HTTP URL of the configuration file.
|
||||
- `--hold 1` Reboot only into install environment, without running installer, only for SSH connect to test network connection.
|
||||
- `--hold 2` Prevent reboot after installation completes, allowing SSH login to modify system content; the system is mounted at `/target` for Debian/Kali and `/os` for other distros.
|
||||
|
||||
> [!TIP]
|
||||
> When installing Debian/Kali, x86 architectures can monitor the installation progress through VNC from server provider, while ARM architectures can use the serial console.
|
||||
>
|
||||
> When installing other systems, can monitor the progress through various methods (SSH, HTTP 80 port, VNC from server provider, serial console).
|
||||
> <br />Even if errors occur during the installation process, you can still install to Alpine via SSH by running `/trans.sh alpine`
|
||||
> Can monitor the progress through various methods (SSH, HTTP 80 port, VNC from server provider, serial console).
|
||||
>
|
||||
> Even if errors occur during the installation process, SSH is available for manual recovery.
|
||||
>
|
||||
> If the target system is not Debian/Kali, run `/trans.sh alpine` can automatically recover to Alpine Linux.
|
||||
|
||||
<details>
|
||||
|
||||
@ -227,9 +232,9 @@ bash reinstall.sh ubuntu --installer
|
||||
>
|
||||
> This feature will erase **the entire hard disk** of the current system (including other partitions)!
|
||||
>
|
||||
> Data is priceless — please think twice before proceeding!
|
||||
> If the script was run by mistake, you can run `bash reinstall.sh reset` before rebooting to cancel the reinstallation operation.
|
||||
|
||||
- Supports `raw` and `vhd` image formats (either uncompressed or compressed as `.gz`, `.xz`, `.zst`, `.tar`, `.tar.gz`, `.tar.xz`, `.tar.zst`).
|
||||
- Supports `raw` and fixed-size `vhd` image formats. Either uncompressed or compressed as `.gz`, `.xz`, `.zst`, `.tar`, `.tar.gz`, `.tar.xz`, `.tar.zst`.
|
||||
- When deploy a Windows image, the system disk will be automatically expanded, and machines with a static IP will have their IP configured, and may take a few minutes after the first boot for the configuration to take effect.
|
||||
- When deploy a Linux image, will **NOT** modify any contents of the image.
|
||||
|
||||
@ -243,26 +248,50 @@ bash reinstall.sh dd --img "https://example.com/xxx.xz"
|
||||
- `--rdp-port PORT` Change RDP port (DD Windows only)
|
||||
- `--ssh-port PORT` Change SSH port (for log observation during installation)
|
||||
- `--web-port PORT` Change Web port (for log observation during installation)
|
||||
- `--frpc-toml /path/to/frpc.toml` Add frpc for intranet tunneling (DD Windows only)
|
||||
- `--hold 2` Prevent reboot after the DD process finishes, allowing SSH login to modify system content. The Windows system will be mounted at `/os`, but Linux systems will **NOT** be automatically mounted.
|
||||
- `--frpc-config PATH` Add frpc for intranet tunneling (DD Windows only). Parameter can be local filepath or HTTP URL of the configuration file.
|
||||
- `--cloud-data PATH_OR_URL` Inject cloud-init NoCloud configuration into the DD'd Linux image (DD Linux only)
|
||||
- `--hold 1` Reboot only into install environment, without running installer, only for SSH connect to test network connection.
|
||||
- `--hold 2` Prevent reboot after the DD process finishes. For SSH login to modify system content. The Windows system will be mounted at `/os`, but Linux systems will **NOT** be automatically mounted.
|
||||
|
||||
> [!TIP]
|
||||
> Can monitor the progress through various methods (SSH, HTTP 80 port, VNC from server provider, serial console).
|
||||
> <br />Even if errors occur during the installation process, you can still install to Alpine via SSH by running `/trans.sh alpine`
|
||||
>
|
||||
> `--cloud-data` accepts a local directory path or an HTTP base URL. The directory must contain a `user-data` file; `meta-data` and `network-config` are optional:
|
||||
>
|
||||
> ```
|
||||
> seed/
|
||||
> ├── user-data # required
|
||||
> ├── meta-data # optional
|
||||
> └── network-config # optional
|
||||
> ```
|
||||
>
|
||||
> ```bash
|
||||
> # Local directory
|
||||
> bash reinstall.sh dd --img "https://example.com/xxx.xz" --cloud-data /path/to/seed/
|
||||
> # HTTP directory
|
||||
> bash reinstall.sh dd --img "https://example.com/xxx.xz" --cloud-data "https://example.com/seed/"
|
||||
> ```
|
||||
|
||||
### Feature 3: Reboot to <img width="16" height="16" src="https://www.alpinelinux.org/alpine-logo.ico" /> Alpine Live OS (RAM OS)
|
||||
> [!TIP]
|
||||
>
|
||||
> Can monitor the progress through various methods (SSH, HTTP 80 port, VNC from server provider, serial console).
|
||||
>
|
||||
> Even if errors occur during the installation process, SSH is available for manual recovery.
|
||||
>
|
||||
> Or Run `/trans.sh alpine` to automatically recover to Alpine Linux.
|
||||
|
||||
### Feature 3: Reboot to <img width="16" height="16" src="https://www.alpinelinux.org/alpine-logo.ico" /> Alpine Live OS
|
||||
|
||||
- You can use SSH to backup/restore disk, manually perform DD operations, partition modifications, manual Alpine installation, and other operations.
|
||||
- Username `root`, Default password `123@@@`
|
||||
- Username `root`. The script prompts for a password. If left blank, a random one is generated.
|
||||
|
||||
> [!TIP]
|
||||
>
|
||||
> Although the script being run is `reinstall`, this feature **does not** delete any data or perform an automatic reinstallation; manual user operation is required.
|
||||
|
||||
>
|
||||
> If the user does not damage the original system during manual operation, rebooting will return to the original system.
|
||||
|
||||
```bash
|
||||
bash reinstall.sh alpine --hold=1
|
||||
bash reinstall.sh alpine --hold 1
|
||||
```
|
||||
|
||||
#### Optional Parameters
|
||||
@ -270,7 +299,7 @@ bash reinstall.sh alpine --hold=1
|
||||
- `--password PASSWORD` Set password
|
||||
- `--ssh-port PORT` Change SSH port
|
||||
- `--ssh-key KEY` Set up SSH login public key, [formatted as follows](#--ssh-key). When using public key, password is empty.
|
||||
- `--frpc-toml /path/to/frpc.toml` Add frpc for intranet tunneling
|
||||
- `--frpc-config PATH` Add frpc for intranet tunneling. Parameter can be local filepath or HTTP URL of the configuration file.
|
||||
|
||||
### Feature 4: Reboot to <img width="16" height="16" src="https://netboot.xyz/img/favicon.ico" /> netboot.xyz
|
||||
|
||||
@ -279,7 +308,7 @@ bash reinstall.sh alpine --hold=1
|
||||
> [!TIP]
|
||||
>
|
||||
> Although the script being run is `reinstall`, this feature **does not** delete any data or perform an automatic reinstallation; manual user operation is required.
|
||||
|
||||
>
|
||||
> If the user does not damage the original system during manual operation, rebooting will return to the original system.
|
||||
|
||||
```bash
|
||||
@ -296,26 +325,27 @@ bash reinstall.sh netboot.xyz
|
||||
>
|
||||
> This feature will erase **the entire hard disk** of the current system (including other partitions)!
|
||||
>
|
||||
> Data is priceless — please think twice before proceeding!
|
||||
> If the script was run by mistake, you can run `bash reinstall.sh reset` before rebooting to cancel the reinstallation operation.
|
||||
|
||||
- Username `administrator`, Default password `123@@@`
|
||||
- Username `administrator`. The script prompts for a password. If left blank, a random one is generated.
|
||||
- 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.
|
||||
- Supports all languages.
|
||||
- Supports ISO images in any language.
|
||||
- Supports bypassing Windows 11 hardware requirements.
|
||||
|
||||
#### Supported Systems
|
||||
|
||||
- Windows (Vista ~ 11)
|
||||
- Windows Server (2008 ~ 2025)
|
||||
- Windows Server Essentials \*
|
||||
- Windows Server (Semi) Annual Channel \*
|
||||
- Hyper-V Server \*
|
||||
- Azure Local (Azure Stack HCI) \*
|
||||
- Windows Server Essentials
|
||||
- Windows Server (Semi) Annual Channel
|
||||
- Hyper-V Server
|
||||
- Azure Local (Azure Stack HCI)
|
||||
|
||||
#### Method 1: Let the Script Automatically Search for ISO
|
||||
|
||||
- The script will search for ISOs from <https://massgrave.dev/genuine-installation-media>, a site that collects official ISOs.
|
||||
- Systems marked with \* do not support automatic ISO searching.
|
||||
- Only supports ISOs searching for Windows 10, 11, Server 2019, 2022, 2025.
|
||||
|
||||
```bash
|
||||
bash reinstall.sh windows \
|
||||
@ -401,7 +431,6 @@ bash reinstall.sh windows \
|
||||
- <https://www.microsoft.com/software-download/windows11>
|
||||
- <https://www.microsoft.com/software-download/windows11arm64>
|
||||
- Evaluation
|
||||
- <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-11-iot-enterprise-ltsc-eval>
|
||||
- <https://www.microsoft.com/evalcenter/download-windows-server-2012-r2>
|
||||
@ -425,8 +454,9 @@ bash reinstall.sh windows \
|
||||
- `--add-driver INF_OR_DIR` Add additional driver, specifying .inf path, or the folder contains .inf file.
|
||||
- The driver must be downloaded to current system first.
|
||||
- This parameter can be set multiple times to add different driver.
|
||||
- `--frpc-toml /path/to/frpc.toml` Add frpc for intranet tunneling
|
||||
- `--hold 2` Allow SSH connections for modifying the disk content before rebooting into the official Windows installation program, with the disk mounted at `/os`.
|
||||
- `--frpc-config PATH` Add frpc for intranet tunneling. Parameter can be local filepath or HTTP URL of the configuration file.
|
||||
- `--hold 1` Reboot only into install environment, without running installer, only for SSH connect to test network connection.
|
||||
- `--hold 2` Allow SSH connections for modifying `boot.wim`, `install.wim` or other contents before rebooting into the official Windows installation program, with the disk mounted at `/os`.
|
||||
|
||||
#### The following drivers will automatic download and install as needed, without the need for manual addition
|
||||
|
||||
@ -435,7 +465,7 @@ bash reinstall.sh windows \
|
||||
- AWS ([ENA Network Adapter][aws-ena], [NVME Storage Controller][aws-nvme])
|
||||
- GCP ([gVNIC Network Adapter][gcp-gvnic], [GGA Display Adapter][gcp-gga])
|
||||
- Azure ([MANA Network Adapter][azure-mana])
|
||||
- Intel ([VMD Storage Controller][intel-vmd], Network Adapter: [7][intel-nic-7], [8][intel-nic-8], [8.1][intel-nic-8.1], [10][intel-nic-10], [11][intel-nic-11], [2008 R2][intel-nic-2008-r2], [2012][intel-nic-2012], [2012 R2][intel-nic-2012-r2], [2016][intel-nic-2016], [2019][intel-nic-2019], [2022][intel-nic-2022], [2025][intel-nic-2025])
|
||||
- Intel (VMD Storage Controller: [11th Gen Core][intel-vmd-gen11], [12th-15th Gen Core][intel-vmd-gen12-to-gen15], Network Adapter: [7][intel-nic-7], [8.x][intel-nic-8.1], [10][intel-nic-10], [11][intel-nic-11], [2008 R2][intel-nic-7], [2012][intel-nic-2012], [2012 R2][intel-nic-2012-r2], [2016][intel-nic-2016], [2019][intel-nic-2019], [2022][intel-nic-2022], [2025][intel-nic-2025])
|
||||
|
||||
[virtio-virtio]: https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/
|
||||
[virtio-aliyun]: https://www.alibabacloud.com/help/ecs/user-guide/install-the-virtio-driver-1
|
||||
@ -449,13 +479,12 @@ bash reinstall.sh windows \
|
||||
[gcp-gvnic]: https://cloud.google.com/compute/docs/networking/using-gvnic
|
||||
[gcp-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
|
||||
[intel-vmd]: https://www.intel.com/content/www/us/en/download/849936/intel-rapid-storage-technology-driver-installation-software-with-intel-optane-memory-12th-to-15th-gen-platforms.html
|
||||
[intel-vmd-gen11]: https://www.intel.com/content/www/us/en/download/849933/intel-rapid-storage-technology-driver-installation-software-with-intel-optane-memory-12th-to-13th-gen-platforms.html
|
||||
[intel-vmd-gen12-to-gen15]: https://www.intel.com/content/www/us/en/download/849936/intel-rapid-storage-technology-driver-installation-software-with-intel-optane-memory-12th-to-15th-gen-platforms.html
|
||||
[intel-nic-7]: https://www.intel.com/content/www/us/en/download/15590/intel-network-adapter-driver-for-windows-7-final-release.html
|
||||
[intel-nic-8]: https://web.archive.org/web/20250501043104/https://www.intel.com/content/www/us/en/download/16765/intel-network-adapter-driver-for-windows-8-final-release.html
|
||||
[intel-nic-8.1]: https://www.intel.com/content/www/us/en/download/17479/intel-network-adapter-driver-for-windows-8-1.html
|
||||
[intel-nic-10]: https://www.intel.com/content/www/us/en/download/18293/intel-network-adapter-driver-for-windows-10.html
|
||||
[intel-nic-11]: https://www.intel.com/content/www/us/en/download/727998/intel-network-adapter-driver-for-microsoft-windows-11.html
|
||||
[intel-nic-2008-r2]: https://web.archive.org/web/20250501002542/https://www.intel.com/content/www/us/en/download/15591/intel-network-adapter-driver-for-windows-server-2008-r2-final-release.html
|
||||
[intel-nic-2012]: https://www.intel.com/content/www/us/en/download/16789/intel-network-adapter-driver-for-windows-server-2012.html
|
||||
[intel-nic-2012-r2]: https://www.intel.com/content/www/us/en/download/17480/intel-network-adapter-driver-for-windows-server-2012-r2.html
|
||||
[intel-nic-2016]: https://www.intel.com/content/www/us/en/download/18737/intel-network-adapter-driver-for-windows-server-2016.html
|
||||
@ -488,43 +517,53 @@ Open File menu > Open Image File, select the iso to be installed to get the imag
|
||||
> Vista (Server 2008) and 32-bit systems may lack drivers.
|
||||
|
||||
> [!WARNING]
|
||||
> For EFI machines without CSM enabled, Windows 7 (Server 2008 R2) cannot be installed.
|
||||
>
|
||||
> Hyper-V (Azure) requires selecting the appropriate VM generation: <https://learn.microsoft.com/windows-server/virtualization/hyper-v/plan/should-i-create-a-generation-1-or-2-virtual-machine-in-hyper-v>
|
||||
> For Windows 7 (Server 2008 R2) installation:
|
||||
>
|
||||
> 1. EFI-boot machines must enable CSM.
|
||||
>
|
||||
> 2. On Hyper-V (Azure), select Generation 1 VM. <https://learn.microsoft.com/windows-server/virtualization/hyper-v/plan/should-i-create-a-generation-1-or-2-virtual-machine-in-hyper-v>
|
||||
|
||||
> [!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>.
|
||||
|
||||
> [!WARNING]
|
||||
>
|
||||
> When installing Windows ISOs released in `May 2022` or later on GCP, the system may repeatedly reboot during the Windows installation (PE) stage. You can resolve this issue using one of the following two methods:
|
||||
>
|
||||
> 1. Add the `--force-boot-mode bios` parameter. The script will install Windows in `BIOS boot + MBR partition table` mode.
|
||||
>
|
||||
> (Optional) After installation, you can convert it to `EFI boot + GPT partition table` using the command `MBR2GPT /convert /allowFullOS`.
|
||||
>
|
||||
> 2. Create a custom RAW image and install it via DD.
|
||||
|
||||
#### Considerations for Installing Windows on ARM
|
||||
|
||||
Most ARM machines support installing latest Windows 11.
|
||||
|
||||
During the installation process, you might encounter a black screen, and the serial console may display `ConvertPages: failed to find range`, but neither issue affects the installation.
|
||||
|
||||
| Compatibility | Cloud Provider | Instance Type | Issues |
|
||||
| ------------- | -------------- | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
||||
| ✔️ | Azure | B2pts_v2 | |
|
||||
| ✔️ | Alibaba Cloud | g6r, c6r | |
|
||||
| ✔️ | Alibaba Cloud | g8y, c8y, r8y | There is a chance of hanging at the boot logo during restart; forced reboot will resolve it. |
|
||||
| ✔️ | AWS | T4g | |
|
||||
| ✔️ | Scaleway | COPARM1 | |
|
||||
| ✔️ | Gcore | | |
|
||||
| ❔ | Oracle Cloud | A1.Flex | Installation success is not guaranteed; newer instances are more likely to succeed.<br />Manual loading of GPU drivers is required after installation. |
|
||||
| ❌ | Google Cloud | t2a | Missing network card drivers |
|
||||
| Compatibility | Cloud Provider | Instance Type | Issues |
|
||||
| ------------- | -------------- | ----------------------- | ----------------------------------------------------------------------------------- |
|
||||
| ✔️ | Azure | B2pts_v2 | |
|
||||
| ✔️ | AWS | T4g | |
|
||||
| ✔️ | Scaleway | COPARM1 | |
|
||||
| ✔️ | Gcore | | |
|
||||
| ❔ | Alibaba Cloud | g6r, c6r, g8y, c8y, r8y | Might hanging at the boot logo during restart; forced reboot will resolve it. |
|
||||
| ❔ | Oracle Cloud | A1.Flex | Installation success is not guaranteed; newer instances are more likely to succeed. |
|
||||
| ❌ | Google Cloud | t2a | Missing network card drivers |
|
||||
|
||||
<details>
|
||||
### Cancel the reinstallation
|
||||
|
||||
<summary>Loading Graphics Driver on Oracle Cloud</summary>
|
||||
- If the script was run by mistake, you can run this command to cancel the reinstallation operation.
|
||||
- Must be run before rebooting.
|
||||
|
||||
Log in to the server using Remote Desktop, open Device Manager, locate the graphics card, select "Update Driver," and choose `Red Hat VirtIO GPU DOD controller` from the list. There's no need to download the drivers in advance.
|
||||
|
||||

|
||||

|
||||

|
||||
|
||||
</details>
|
||||
```bash
|
||||
bash reinstall.sh reset
|
||||
```
|
||||
|
||||
## Parameter Format
|
||||
|
||||
@ -539,6 +578,21 @@ Log in to the server using Remote Desktop, open Device Manager, locate the graph
|
||||
- `--ssh-key /path/to/public_key`
|
||||
- `--ssh-key C:\path\to\public_key`
|
||||
|
||||
## How to Use an Old Version
|
||||
|
||||
According to the Law of Bug Conservation, fixing old bugs often introduces new ones.
|
||||
|
||||
If a new bug occurs, try using an older version to see if it works.
|
||||
|
||||
Go to <https://github.com/bin456789/reinstall/commits/main> and find the old version’s `commit_id` on the right side.
|
||||
|
||||
```bash
|
||||
commit_id=xxxxxxx
|
||||
curl -O https://raw.githubusercontent.com/bin456789/reinstall/$commit_id/reinstall.sh || wget -O ${_##*/} $_
|
||||
sed -i "/^confhome.*main$/s/main/$commit_id/" reinstall.sh
|
||||
bash reinstall.sh ...
|
||||
```
|
||||
|
||||
## How to Modify the Script for Your Own
|
||||
|
||||
1. Fork this repository.
|
||||
|
||||
194
README.md
194
README.md
@ -4,7 +4,8 @@
|
||||
|
||||
[](https://app.codacy.com/gh/bin456789/reinstall/dashboard)
|
||||
[](https://www.codefactor.io/repository/github/bin456789/reinstall)
|
||||
[](https://github.com/XAMPPRocky/tokei_rs)
|
||||
[](https://github.com/aschey/vercel-tokei)
|
||||
<!-- [](https://github.com/XAMPPRocky/tokei_rs) -->
|
||||
|
||||
一键 VPS 系统重装脚本 [English](README.en.md)
|
||||
|
||||
@ -37,6 +38,7 @@
|
||||
- [功能 3. 一键引导到 Alpine Live OS 内存系统](#功能-3-重启到--alpine-live-os内存系统)
|
||||
- [功能 4. 一键引导到 netboot.xyz](#功能-4-重启到--netbootxyz)
|
||||
- [功能 5. 一键重装到 Windows](#功能-5-安装--windows-iso)
|
||||
- [取消重装](#取消重装)
|
||||
|
||||
## 系统要求
|
||||
|
||||
@ -46,22 +48,22 @@
|
||||
|
||||
| 系统 | 版本 | 内存 | 硬盘 |
|
||||
| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------- | --------- | ------------ |
|
||||
| <img width="16" height="16" src="https://www.alpinelinux.org/alpine-logo.ico" /> Alpine | 3.19, 3.20, 3.21, 3.22 | 256 MB | 1 GB |
|
||||
| <img width="16" height="16" src="https://www.alpinelinux.org/alpine-logo.ico" /> Alpine | 3.20, 3.21, 3.22, 3.23 | 256 MB | 1 GB |
|
||||
| <img width="16" height="16" src="https://www.debian.org/favicon.ico" /> Debian | 9, 10, 11, 12, 13 | 256 MB | 1 ~ 1.5 GB ^ |
|
||||
| <img width="16" height="16" src="https://github.com/bin456789/reinstall/assets/7548515/f74b3d5b-085f-4df3-bcc9-8a9bd80bb16d" /> Kali | 滚动 | 256 MB | 1 ~ 1.5 GB ^ |
|
||||
| <img width="16" height="16" src="https://documentation.ubuntu.com/server/_static/favicon.png" /> Ubuntu | 16.04 LTS - 24.04 LTS, 25.04 | 512 MB \* | 2 GB |
|
||||
| <img width="16" height="16" src="https://documentation.ubuntu.com/server/_static/favicon.png" /> Ubuntu | 16.04 LTS - 24.04 LTS, 25.10 | 512 MB \* | 2 GB |
|
||||
| <img width="16" height="16" src="https://img.alicdn.com/imgextra/i1/O1CN01oJnJZg1yK4RzI4Rx2_!!6000000006559-2-tps-118-118.png" /> Anolis | 7, 8, 23 | 512 MB \* | 5 GB |
|
||||
| <img width="16" height="16" src="https://www.redhat.com/favicon.ico" /> RHEL <img width="16" height="16" src="https://almalinux.org/fav/favicon.ico" /> AlmaLinux <img width="16" height="16" src="https://rockylinux.org/favicon.png" /> Rocky <img width="16" height="16" src="https://www.oracle.com/asset/web/favicons/favicon-32.png" /> Oracle | 8, 9, 10 (如果有) | 512 MB \* | 5 GB |
|
||||
| <img width="16" height="16" src="https://www.redhat.com/favicon.ico" /> RHEL <img width="16" height="16" src="https://almalinux.org/fav/favicon.ico" /> AlmaLinux <img width="16" height="16" src="https://rockylinux.org/favicon.png" /> Rocky <img width="16" height="16" src="https://www.oracle.com/asset/web/favicons/favicon-32.png" /> Oracle | 8, 9, 10 | 512 MB \* | 5 GB |
|
||||
| <img width="16" height="16" src="https://opencloudos.org/qq.ico" /> OpenCloudOS | 8, 9, Stream 23 | 512 MB \* | 5 GB |
|
||||
| <img width="16" height="16" src="https://www.centos.org/assets/icons/favicon.svg" /> CentOS Stream | 9, 10 | 512 MB \* | 5 GB |
|
||||
| <img width="16" height="16" src="https://fedoraproject.org/favicon.ico" /> Fedora | 41, 42 | 512 MB \* | 5 GB |
|
||||
| <img width="16" height="16" src="https://www.openeuler.org/favicon.ico" /> openEuler | 20.03 LTS - 24.03 LTS, 25.03 | 512 MB \* | 5 GB |
|
||||
| <img width="16" height="16" src="https://static.opensuse.org/favicon.ico" /> openSUSE | Leap 15.6, Tumbleweed (滚动) | 512 MB \* | 5 GB |
|
||||
| <img width="16" height="16" src="https://nixos.org/favicon.svg" /> NixOS | 25.05 | 512 MB | 5 GB |
|
||||
| <img width="16" height="16" src="https://fedoraproject.org/favicon.ico" /> Fedora | 42, 43 | 512 MB \* | 5 GB |
|
||||
| <img width="16" height="16" src="https://www.openeuler.org/favicon.ico" /> openEuler | 20.03 LTS - 24.03 LTS, 25.09 | 512 MB \* | 5 GB |
|
||||
| <img width="16" height="16" src="https://static.opensuse.org/favicon.ico" /> openSUSE | Leap 15.6, 16.0, Tumbleweed (滚动) | 512 MB \* | 5 GB |
|
||||
| <img width="16" height="16" src="https://nixos.org/favicon.svg" /> NixOS | 25.11 | 512 MB | 5 GB |
|
||||
| <img width="16" height="16" src="https://archlinux.org/static/favicon.png" /> Arch | 滚动 | 512 MB | 5 GB |
|
||||
| <img width="16" height="16" src="https://www.gentoo.org/assets/img/logo/gentoo-g.png" /> Gentoo | 滚动 | 512 MB | 5 GB |
|
||||
| <img width="16" height="16" src="https://aosc.io/assets/distros/aosc-os.svg" /> 安同 OS | 滚动 | 512 MB | 5 GB |
|
||||
| <img width="16" height="16" src="https://www.fnnas.com/favicon.ico" /> 飞牛 fnOS | 公测 | 512 MB | 8 GB |
|
||||
| <img width="16" height="16" src="https://aosc.io/distros/aosc-os.svg" /> 安同 OS | 滚动 | 512 MB | 5 GB |
|
||||
| <img width="16" height="16" src="https://www.fnnas.com/favicon.ico" /> 飞牛 fnOS | 1 | 512 MB | 8 GB |
|
||||
| <img width="16" height="16" src="https://blogs.windows.com/wp-content/uploads/prod/2022/09/cropped-Windows11IconTransparent512-32x32.png" /> Windows (DD) | 任何 | 512 MB | 取决于镜像 |
|
||||
| <img width="16" height="16" src="https://blogs.windows.com/wp-content/uploads/prod/2022/09/cropped-Windows11IconTransparent512-32x32.png" /> Windows (ISO) | Vista, 7, 8.x (Server 2008 - 2012 R2) | 512 MB | 25 GB |
|
||||
| <img width="16" height="16" src="https://blogs.windows.com/wp-content/uploads/prod/2022/09/cropped-Windows11IconTransparent512-32x32.png" /> Windows (ISO) | 10, 11 (Server 2016 - 2025) | 1 GB | 25 GB |
|
||||
@ -143,34 +145,34 @@ certutil -urlcache -f -split https://cnb.cool/bin456789/reinstall/-/git/raw/main
|
||||
>
|
||||
> 此功能会清除当前系统**整个硬盘**的全部数据(包含其它分区)!
|
||||
>
|
||||
> 数据无价,请三思而后行!
|
||||
> 如果不小心运行了脚本,可以在重启前运行 `bash reinstall.sh reset` 取消重装
|
||||
|
||||
- 用户名 `root` 默认密码 `123@@@`
|
||||
- 用户名为 `root`,脚本会提示输入密码,不输入则使用随机密码
|
||||
- 安装最新版可不输入版本号
|
||||
- 最大化利用磁盘空间:不含 boot 分区(Fedora 例外),不含 swap 分区
|
||||
- 自动根据机器类型选择不同的优化内核,例如 `Cloud`、`HWE` 内核
|
||||
- 安装 Red Hat 时需填写 <https://access.redhat.com/downloads/content/rhel> 得到的 `qcow2` 镜像链接,也可以安装其它类 RHEL 系统,例如 `Alibaba Cloud Linux` 和 `TencentOS Server`
|
||||
- 安装 Red Hat 时需填写 <https://access.redhat.com/downloads/content/rhel> 得到的 `qcow2` 镜像链接,也可以安装其它类 RHEL 系统的 `qcow2`,例如 `Alibaba Cloud Linux` 和 `TencentOS Server`
|
||||
- 重装后如需修改 SSH 端口或者改成密钥登录,注意还要修改 `/etc/ssh/sshd_config.d/` 里面的文件
|
||||
|
||||
```bash
|
||||
bash reinstall.sh anolis 7|8|23
|
||||
rocky 8|9|10
|
||||
oracle 8|9
|
||||
oracle 8|9|10
|
||||
almalinux 8|9|10
|
||||
opencloudos 8|9|23
|
||||
centos 9|10
|
||||
fedora 41|42
|
||||
nixos 25.05
|
||||
fnos 1
|
||||
nixos 25.11
|
||||
fedora 42|43
|
||||
debian 9|10|11|12|13
|
||||
opensuse 15.6|tumbleweed
|
||||
alpine 3.19|3.20|3.21|3.22
|
||||
openeuler 20.03|22.03|24.03|25.03
|
||||
ubuntu 16.04|18.04|20.04|22.04|24.04|25.04 [--minimal]
|
||||
alpine 3.20|3.21|3.22|3.23
|
||||
opensuse 15.6|16.0|tumbleweed
|
||||
openeuler 20.03|22.03|24.03|25.09
|
||||
ubuntu 16.04|18.04|20.04|22.04|24.04|25.10 [--minimal]
|
||||
kali
|
||||
arch
|
||||
gentoo
|
||||
aosc
|
||||
fnos
|
||||
redhat --img="http://access.cdn.redhat.com/xxx.qcow2"
|
||||
```
|
||||
|
||||
@ -180,14 +182,17 @@ bash reinstall.sh anolis 7|8|23
|
||||
- `--ssh-key KEY` 设置 SSH 登录公钥,[格式如下](#--ssh-key)。当使用公钥时,密码为空
|
||||
- `--ssh-port PORT` 修改 SSH 端口(安装期间观察日志用,也作用于新系统)
|
||||
- `--web-port PORT` 修改 Web 端口(安装期间观察日志用)
|
||||
- `--frpc-toml /path/to/frpc.toml` 添加 frpc 内网穿透
|
||||
- `--hold 2` 安装结束后不重启,此时可以 SSH 登录修改系统内容,系统挂载在 `/os` (此功能不支持 Debian/Kali)
|
||||
- `--frpc-config PATH` 添加 frpc 内网穿透,参数填配置文件的本地路径或 HTTP 链接
|
||||
- `--hold 1` 仅重启到安装环境,不运行安装,用于 SSH 登录验证网络连通性
|
||||
- `--hold 2` 安装结束后不重启,用于 SSH 登录修改系统内容,Debian/Kali 会挂载在 `/target`,其它系统会挂载在 `/os`
|
||||
|
||||
> [!TIP]
|
||||
> 安装 Debian/Kali 时,x86 可通过商家后台 VNC 查看安装进度,ARM 可通过串行控制台查看安装进度。
|
||||
>
|
||||
> 安装其它系统时,可通过多种方式(SSH、HTTP 80 端口、商家后台 VNC、串行控制台)查看安装进度。
|
||||
> <br />即使安装过程出错,也能通过 SSH 运行 `/trans.sh alpine` 安装到 Alpine。
|
||||
> 可通过多种方式(SSH、HTTP 80 端口、商家后台 VNC、串行控制台)查看安装进度。
|
||||
>
|
||||
> 即使安装过程出错,也能连接 SSH 手动救砖。
|
||||
>
|
||||
> 目标系统非 Debian/Kali 时,可以运行 `/trans.sh alpine` 自动救砖成 Alpine 系统。
|
||||
|
||||
<details>
|
||||
|
||||
@ -227,9 +232,9 @@ bash reinstall.sh ubuntu --installer
|
||||
>
|
||||
> 此功能会清除当前系统**整个硬盘**的全部数据(包含其它分区)!
|
||||
>
|
||||
> 数据无价,请三思而后行!
|
||||
> 如果不小心运行了脚本,可以在重启前运行 `bash reinstall.sh reset` 取消重装
|
||||
|
||||
- 支持 `raw` `vhd` 格式的镜像(未压缩,或者压缩成 `.gz` `.xz` `.zst` `.tar` `.tar.gz` `.tar.xz` `.tar.zst`)
|
||||
- 支持 `raw` 和固定大小的 `vhd` 镜像。未压缩或者压缩成 `.gz` `.xz` `.zst` `.tar` `.tar.gz` `.tar.xz` `.tar.zst`
|
||||
- DD Windows 镜像时,会自动扩展系统盘,静态 IP 的机器会配置好 IP,可能首次开机几分钟后才生效
|
||||
- DD Linux 镜像时,**不会**修改镜像的任何内容
|
||||
|
||||
@ -243,17 +248,41 @@ bash reinstall.sh dd --img "https://example.com/xxx.xz"
|
||||
- `--rdp-port PORT` 修改 RDP 端口 (仅限 DD Windows)
|
||||
- `--ssh-port PORT` 修改 SSH 端口(安装期间观察日志用)
|
||||
- `--web-port PORT` 修改 Web 端口(安装期间观察日志用)
|
||||
- `--frpc-toml /path/to/frpc.toml` 添加 frpc 内网穿透(仅限 DD Windows)
|
||||
- `--hold 2` DD 结束后不重启,此时可以 SSH 登录修改系统内容,Windows 系统会挂载在 `/os`,Linux 系统**不会**自动挂载
|
||||
- `--frpc-config PATH` 添加 frpc 内网穿透(仅限 DD Windows),参数填配置文件的本地路径或 HTTP 链接
|
||||
- `--cloud-data PATH_OR_URL` 为 DD Linux 镜像注入 cloud-init NoCloud 配置(仅限 DD Linux)
|
||||
- `--hold 1` 仅重启到安装环境,不运行安装,用于 SSH 登录验证网络连通性
|
||||
- `--hold 2` DD 结束后不重启,用于 SSH 登录修改系统内容,Windows 系统会挂载在 `/os`,Linux 系统**不会**自动挂载
|
||||
|
||||
> [!TIP]
|
||||
>
|
||||
> `--cloud-data` 参数为本地目录或 HTTP 基础 URL,目录须包含 `user-data` 文件,`meta-data`、`network-config` 可选:
|
||||
>
|
||||
> ```
|
||||
> seed/
|
||||
> ├── user-data # 必须
|
||||
> ├── meta-data # 可选
|
||||
> └── network-config # 可选
|
||||
> ```
|
||||
>
|
||||
> ```bash
|
||||
> # 使用本地目录
|
||||
> bash reinstall.sh dd --img "https://example.com/xxx.xz" --cloud-data /path/to/seed/
|
||||
> # 使用 HTTP 目录
|
||||
> bash reinstall.sh dd --img "https://example.com/xxx.xz" --cloud-data "https://example.com/seed/"
|
||||
> ```
|
||||
|
||||
> [!TIP]
|
||||
>
|
||||
> 可通过多种方式(SSH、HTTP 80 端口、商家后台 VNC、串行控制台)查看安装进度。
|
||||
> <br />即使安装过程出错,也能通过 SSH 运行 `/trans.sh alpine` 安装到 Alpine。
|
||||
>
|
||||
> 即使安装过程出错,也能连接 SSH 手动救砖
|
||||
>
|
||||
> 也可以运行 `/trans.sh alpine` 自动救砖成 Alpine 系统。
|
||||
|
||||
### 功能 3: 重启到 <img width="16" height="16" src="https://www.alpinelinux.org/alpine-logo.ico" /> Alpine Live OS(内存系统)
|
||||
|
||||
- 可用 ssh 连接,进行备份/恢复硬盘、手动 DD、修改分区、手动安装 Alpine 等操作
|
||||
- 用户名 `root` 默认密码 `123@@@`
|
||||
- 用户名为 `root`,脚本会提示输入密码,不输入则使用随机密码
|
||||
|
||||
> [!TIP]
|
||||
>
|
||||
@ -262,7 +291,7 @@ bash reinstall.sh dd --img "https://example.com/xxx.xz"
|
||||
> 如果用户手动操作没有破坏原系统,再次重启将回到原系统
|
||||
|
||||
```bash
|
||||
bash reinstall.sh alpine --hold=1
|
||||
bash reinstall.sh alpine --hold 1
|
||||
```
|
||||
|
||||
#### 可选参数
|
||||
@ -270,7 +299,7 @@ bash reinstall.sh alpine --hold=1
|
||||
- `--password PASSWORD` 设置密码
|
||||
- `--ssh-port PORT` 修改 SSH 端口
|
||||
- `--ssh-key KEY` 设置 SSH 登录公钥,[格式如下](#--ssh-key)。当使用公钥时,密码为空
|
||||
- `--frpc-toml /path/to/frpc.toml` 添加 frpc 内网穿透
|
||||
- `--frpc-config PATH` 添加 frpc 内网穿透,参数填配置文件的本地路径或 HTTP 链接
|
||||
|
||||
### 功能 4: 重启到 <img width="16" height="16" src="https://netboot.xyz/img/favicon.ico" /> netboot.xyz
|
||||
|
||||
@ -296,26 +325,27 @@ bash reinstall.sh netboot.xyz
|
||||
>
|
||||
> 此功能会清除当前系统**整个硬盘**的全部数据(包含其它分区)!
|
||||
>
|
||||
> 数据无价,请三思而后行!
|
||||
> 如果不小心运行了脚本,可以在重启前运行 `bash reinstall.sh reset` 取消重装
|
||||
|
||||
- 用户名 `administrator` 默认密码 `123@@@`
|
||||
- 用户名为 `administrator`,脚本会提示输入密码,不输入则使用随机密码
|
||||
- 如果远程登录失败,可以尝试使用用户名 `.\administrator`
|
||||
- 静态机器会自动配置好 IP,可能首次开机几分钟后才生效
|
||||
- 支持所有语言
|
||||
- 支持任意语言的 ISO
|
||||
- 支持绕过 Windows 11 硬件限制
|
||||
|
||||
#### 支持的系统
|
||||
|
||||
- Windows (Vista ~ 11)
|
||||
- Windows Server (2008 ~ 2025)
|
||||
- Windows Server Essentials \*
|
||||
- Windows Server (Semi) Annual Channel \*
|
||||
- Hyper-V Server \*
|
||||
- Azure Local (Azure Stack HCI) \*
|
||||
- Windows Server Essentials
|
||||
- Windows Server (Semi) Annual Channel
|
||||
- Hyper-V Server
|
||||
- Azure Local (Azure Stack HCI)
|
||||
|
||||
#### 方法 1: 让脚本自动查找 ISO
|
||||
|
||||
- 脚本会从 <https://massgrave.dev/genuine-installation-media> 查找 ISO,该网站专门提供官方 ISO 下载
|
||||
- 上面带 \* 的系统不支持自动查找 ISO
|
||||
- 只支持查找 Windows 10, 11, Server 2019, 2022, 2025 的 ISO
|
||||
|
||||
```bash
|
||||
bash reinstall.sh windows \
|
||||
@ -401,7 +431,6 @@ bash reinstall.sh windows \
|
||||
- <https://www.microsoft.com/software-download/windows11>
|
||||
- <https://www.microsoft.com/software-download/windows11arm64>
|
||||
- 评估版
|
||||
- <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-11-iot-enterprise-ltsc-eval>
|
||||
- <https://www.microsoft.com/evalcenter/download-windows-server-2012-r2>
|
||||
@ -425,8 +454,9 @@ bash reinstall.sh windows \
|
||||
- `--add-driver INF_OR_DIR` 添加额外驱动,填写 .inf 路径,或者 .inf 所在的文件夹
|
||||
- 需先下载驱动到当前系统
|
||||
- 可多次设置该参数以添加不同的驱动
|
||||
- `--frpc-toml /path/to/frpc.toml` 添加 frpc 内网穿透
|
||||
- `--hold 2` 在进入 Windows 官方安装程序之前,可以 SSH 登录修改硬盘内容,硬盘挂载在 `/os`
|
||||
- `--frpc-config PATH` 添加 frpc 内网穿透,参数填配置文件的本地路径或 HTTP 链接
|
||||
- `--hold 1` 仅重启到安装环境,不运行安装,用于 SSH 登录验证网络连通性
|
||||
- `--hold 2` 用于在进入 Windows 官方安装程序之前,SSH 登录修改 `boot.wim`、`install.wim` 或者其它内容,硬盘挂载在 `/os`
|
||||
|
||||
#### 以下驱动会自动按需下载安装,无需手动添加
|
||||
|
||||
@ -435,7 +465,7 @@ bash reinstall.sh windows \
|
||||
- AWS ([ENA 网卡][aws-ena], [NVME 存储控制器][aws-nvme])
|
||||
- GCP ([gVNIC 网卡][gcp-gvnic], [GGA 显卡][gcp-gga])
|
||||
- Azure ([MANA 网卡][azure-mana])
|
||||
- Intel ([VMD 存储控制器][intel-vmd], 网卡: [7][intel-nic-7], [8][intel-nic-8], [8.1][intel-nic-8.1], [10][intel-nic-10], [11][intel-nic-11], [2008 R2][intel-nic-2008-r2], [2012][intel-nic-2012], [2012 R2][intel-nic-2012-r2], [2016][intel-nic-2016], [2019][intel-nic-2019], [2022][intel-nic-2022], [2025][intel-nic-2025])
|
||||
- Intel (VMD 存储控制器: [11代酷睿][intel-vmd-gen11], [12-15代酷睿][intel-vmd-gen12-to-gen15], 网卡: [7][intel-nic-7], [8.x][intel-nic-8.1], [10][intel-nic-10], [11][intel-nic-11], [2008 R2][intel-nic-7], [2012][intel-nic-2012], [2012 R2][intel-nic-2012-r2], [2016][intel-nic-2016], [2019][intel-nic-2019], [2022][intel-nic-2022], [2025][intel-nic-2025])
|
||||
|
||||
[virtio-virtio]: https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/
|
||||
[virtio-aliyun]: https://www.alibabacloud.com/help/ecs/user-guide/install-the-virtio-driver-1
|
||||
@ -449,13 +479,12 @@ bash reinstall.sh windows \
|
||||
[gcp-gvnic]: https://cloud.google.com/compute/docs/networking/using-gvnic
|
||||
[gcp-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
|
||||
[intel-vmd]: https://www.intel.com/content/www/us/en/download/849936/intel-rapid-storage-technology-driver-installation-software-with-intel-optane-memory-12th-to-15th-gen-platforms.html
|
||||
[intel-vmd-gen11]: https://www.intel.com/content/www/us/en/download/849933/intel-rapid-storage-technology-driver-installation-software-with-intel-optane-memory-12th-to-13th-gen-platforms.html
|
||||
[intel-vmd-gen12-to-gen15]: https://www.intel.com/content/www/us/en/download/849936/intel-rapid-storage-technology-driver-installation-software-with-intel-optane-memory-12th-to-15th-gen-platforms.html
|
||||
[intel-nic-7]: https://www.intel.com/content/www/us/en/download/15590/intel-network-adapter-driver-for-windows-7-final-release.html
|
||||
[intel-nic-8]: https://web.archive.org/web/20250501043104/https://www.intel.com/content/www/us/en/download/16765/intel-network-adapter-driver-for-windows-8-final-release.html
|
||||
[intel-nic-8.1]: https://www.intel.com/content/www/us/en/download/17479/intel-network-adapter-driver-for-windows-8-1.html
|
||||
[intel-nic-10]: https://www.intel.com/content/www/us/en/download/18293/intel-network-adapter-driver-for-windows-10.html
|
||||
[intel-nic-11]: https://www.intel.com/content/www/us/en/download/727998/intel-network-adapter-driver-for-microsoft-windows-11.html
|
||||
[intel-nic-2008-r2]: https://web.archive.org/web/20250501002542/https://www.intel.com/content/www/us/en/download/15591/intel-network-adapter-driver-for-windows-server-2008-r2-final-release.html
|
||||
[intel-nic-2012]: https://www.intel.com/content/www/us/en/download/16789/intel-network-adapter-driver-for-windows-server-2012.html
|
||||
[intel-nic-2012-r2]: https://www.intel.com/content/www/us/en/download/17480/intel-network-adapter-driver-for-windows-server-2012-r2.html
|
||||
[intel-nic-2016]: https://www.intel.com/content/www/us/en/download/18737/intel-network-adapter-driver-for-windows-server-2016.html
|
||||
@ -488,43 +517,53 @@ Windows Server 2025 SERVERDATACENTER
|
||||
> Vista (Server 2008) 和 32 位系统可能会缺少驱动
|
||||
|
||||
> [!WARNING]
|
||||
> 未开启 CSM 的 EFI 机器,无法安装 Windows 7 (Server 2008 R2)
|
||||
>
|
||||
> Hyper-V (Azure) 需选择合适的虚拟机代系 <https://learn.microsoft.com/windows-server/virtualization/hyper-v/plan/should-i-create-a-generation-1-or-2-virtual-machine-in-hyper-v>
|
||||
> 安装 Windows 7 (Server 2008 R2) 时
|
||||
>
|
||||
> 1. EFI 引导的机器要开启 CSM
|
||||
>
|
||||
> 2. Hyper-V (Azure) 需选择第 1 代虚拟机 <https://learn.microsoft.com/windows-server/virtualization/hyper-v/plan/should-i-create-a-generation-1-or-2-virtual-machine-in-hyper-v>
|
||||
|
||||
> [!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>
|
||||
|
||||
> [!WARNING]
|
||||
>
|
||||
> 在 GCP 上安装 `2022年5月` 和之后发布的 Windows ISO,在引导 Windows 安装界面 (PE) 时会不断反复重启。解决方法如下,二选一
|
||||
>
|
||||
> 1. 添加 `--force-boot-mode bios` 参数,脚本将以 `BIOS 引导 + MBR 分区表` 方式安装 Windows
|
||||
>
|
||||
> (可选) 安装完成后用 `MBR2GPT /convert /allowFullOS` 命令转为 `EFI 引导 + GPT 分区表`
|
||||
>
|
||||
> 2. 自制 RAW 镜像并通过 DD 安装
|
||||
|
||||
#### ARM 安装 Windows 的注意事项
|
||||
|
||||
大部分 ARM 机器都支持安装最新版 Windows 11
|
||||
|
||||
安装过程可能会黑屏,串行控制台可能会显示 `ConvertPages: failed to find range`,均不影响正常安装
|
||||
|
||||
| 兼容性 | 云服务商 | 实例类型 | 问题 |
|
||||
| ------ | -------- | ------------- | ---------------------------------------------------------------------------- |
|
||||
| ✔️ | Azure | B2pts_v2 | |
|
||||
| ✔️ | 阿里云 | g6r, c6r | |
|
||||
| ✔️ | 阿里云 | g8y, c8y, r8y | 有几率重启时卡开机 Logo,强制重启即可 |
|
||||
| ✔️ | AWS | T4g | |
|
||||
| ✔️ | Scaleway | COPARM1 | |
|
||||
| ✔️ | Gcore | | |
|
||||
| ❔ | 甲骨文云 | A1.Flex | 不一定能安装成功,越新创建的实例越容易成功<br />安装后还需要手动加载显卡驱动 |
|
||||
| ❌ | 谷歌云 | t2a | 缺少网卡驱动 |
|
||||
| 兼容性 | 云服务商 | 实例类型 | 问题 |
|
||||
| ------ | -------- | ----------------------- | ------------------------------------------ |
|
||||
| ✔️ | Azure | B2pts_v2 | |
|
||||
| ✔️ | AWS | T4g | |
|
||||
| ✔️ | Scaleway | COPARM1 | |
|
||||
| ✔️ | Gcore | | |
|
||||
| ❔ | 阿里云 | g6r, c6r, g8y, c8y, r8y | 有几率重启时卡开机 Logo,强制重启即可 |
|
||||
| ❔ | 甲骨文云 | A1.Flex | 不一定能安装成功,越新创建的实例越容易成功 |
|
||||
| ❌ | 谷歌云 | t2a | 缺少网卡驱动 |
|
||||
|
||||
<details>
|
||||
### 取消重装
|
||||
|
||||
<summary>甲骨文云加载显卡驱动</summary>
|
||||
- 如果不小心运行了脚本,可以运行以下命令取消重装
|
||||
- 需要在重启前运行
|
||||
|
||||
使用远程桌面登录到服务器,打开设备管理器,找到显卡,选择更新驱动,在列表中选择 `Red Hat VirtIO GPU DOD controller` 即可。不需要提前下载驱动。
|
||||
|
||||

|
||||

|
||||

|
||||
|
||||
</details>
|
||||
```bash
|
||||
bash reinstall.sh reset
|
||||
```
|
||||
|
||||
## 参数格式
|
||||
|
||||
@ -539,6 +578,21 @@ Windows Server 2025 SERVERDATACENTER
|
||||
- `--ssh-key /path/to/public_key`
|
||||
- `--ssh-key C:\path\to\public_key`
|
||||
|
||||
## 如何使用旧版本
|
||||
|
||||
根据 Bug 守恒定律,修复旧 Bug 的同时会引入新的 Bug
|
||||
|
||||
如果遇到新的 Bug,可以试下旧版本是否正常
|
||||
|
||||
从 <https://github.com/bin456789/reinstall/commits/main> 右侧找到旧版本的 `commit_id`
|
||||
|
||||
```bash
|
||||
commit_id=xxxxxxx
|
||||
curl -O https://raw.githubusercontent.com/bin456789/reinstall/$commit_id/reinstall.sh || wget -O ${_##*/} $_
|
||||
sed -i "/^confhome.*main$/s/main/$commit_id/" reinstall.sh
|
||||
bash reinstall.sh ...
|
||||
```
|
||||
|
||||
## 如何修改脚本自用
|
||||
|
||||
1. Fork 本仓库
|
||||
|
||||
155
debian.cfg
155
debian.cfg
@ -6,10 +6,10 @@
|
||||
# 需要留意 kali initrd 自带的 /preseed.cfg
|
||||
|
||||
# 下面这行语句无效,因为本行后面有反斜杠,前面有空格(安装器认为不算注释)\
|
||||
d-i debian-installer/locale string en_US
|
||||
d-i debian-installer/locale string en_US.UTF-8
|
||||
|
||||
# B.4.1. 本地化
|
||||
d-i debian-installer/locale string en_US
|
||||
d-i debian-installer/locale string en_US.UTF-8
|
||||
d-i keyboard-configuration/xkb-keymap select us
|
||||
|
||||
# B.4.2. 网络设置
|
||||
@ -25,10 +25,10 @@ d-i mirror/country string manual
|
||||
|
||||
# B.4.5. 帐号设置
|
||||
d-i passwd/make-user boolean false
|
||||
# 单纯为了跳过设置,实际上是在 partman/early_command 里设置密码,preseed/early_command 无法设置密码
|
||||
# 注意如果用 ssh key 后面还要删除密码
|
||||
d-i passwd/root-password password ''
|
||||
d-i passwd/root-password-again password ''
|
||||
# d-i passwd/root-password password ''
|
||||
# d-i passwd/root-password-again password ''
|
||||
# d-i passwd/root-password-crypted password ''
|
||||
# kali 需要下面这行,否则会提示输入用户名
|
||||
d-i passwd/root-login boolean true
|
||||
|
||||
@ -63,6 +63,9 @@ d-i partman-efi/non_efi_system boolean true
|
||||
# 选择 true 就一直死循环
|
||||
d-i partman-basicfilesystems/no_swap boolean false
|
||||
|
||||
# 分区大小计算
|
||||
# https://salsa.debian.org/installer-team/partman-base/-/blob/master/lib/base.sh
|
||||
|
||||
# 最小值 膨胀权重 最大值
|
||||
# https://salsa.debian.org/installer-team/partman-auto/-/blob/master/recipes/atomic?ref_type=heads
|
||||
# https://salsa.debian.org/installer-team/partman-auto/-/blob/master/recipes-amd64-efi/atomic?ref_type=heads
|
||||
@ -73,6 +76,7 @@ d-i partman-auto/expert_recipe_efi string efi :: \
|
||||
1 1 -1 $default_filesystem \
|
||||
method{ format } format{ } use_filesystem{ } $default_filesystem{ } mountpoint{ / } .
|
||||
|
||||
# 大于 2T 会自动用 gpt
|
||||
# shellcheck disable=SC1083,SC2086,SC2154
|
||||
d-i partman-auto/expert_recipe_bios string bios :: \
|
||||
1 1 1 free \
|
||||
@ -99,26 +103,127 @@ d-i pkgsel/upgrade select none
|
||||
d-i grub-installer/force-efi-extra-removable boolean true
|
||||
|
||||
# B.4.12. 完成安装
|
||||
d-i finish-install/reboot_in_progress note
|
||||
# 由下面的 hold 2 设置
|
||||
# d-i finish-install/reboot_in_progress note
|
||||
|
||||
# B.4.13. 预置其他的软件包
|
||||
|
||||
# 其他设置
|
||||
# d-i anna/standard_modules boolean false
|
||||
# d-i anna/choose_modules string network-console
|
||||
# d-i network-console/password password 123@@@
|
||||
# d-i network-console/password-again password 123@@@
|
||||
# d-i network-console/password password ''
|
||||
# d-i network-console/password-again password ''
|
||||
|
||||
# B.5.1. 安装过程中运行用户命令
|
||||
# 注意所有命令都会合并成一行命令
|
||||
|
||||
# 最后的 true; \ 没什么用,只是让 vscode 代码高亮不报错误
|
||||
|
||||
# debian 11+ 才有 websocketd
|
||||
|
||||
# 有 /cdrom/simple-cdd 才安装 simple-cdd-profiles
|
||||
# 不然安装时 control 脚本会报错:
|
||||
# Loading simple-cdd-profiles failed for unknown reasons
|
||||
|
||||
# 未下载的组件,无法用 debconf-set,需要用 debconf-set-selections
|
||||
|
||||
# https://salsa.debian.org/installer-team/network-console/-/blob/master/debian/network-console.postinst?ref_type=heads
|
||||
# https://salsa.debian.org/installer-team/user-setup/-/blob/master/user-setup-apply?ref_type=heads
|
||||
|
||||
# 此时还没有配置源,anna-install 会在配置完源后再安装
|
||||
d-i preseed/early_command string true; \
|
||||
if [ -d /cdrom/simple-cdd ]; then anna-install simple-cdd-profiles; fi
|
||||
for str in $(grep -wo "extra_[^ ]*" /proc/cmdline | sed 's/^extra_//'); do eval "$str"; done; \
|
||||
|
||||
di(){ \
|
||||
echo "d-i $*" >/tmp/selections.cfg; \
|
||||
echo "d-i $*" >>/tmp/selections.cfg.all; \
|
||||
debconf-set-selections /tmp/selections.cfg; \
|
||||
rm -f /tmp/selections.cfg; \
|
||||
}; \
|
||||
|
||||
run_as_service_with_screen() { \
|
||||
if ! [ -f /etc/screenrc.bak ]; then \
|
||||
cp /etc/screenrc /etc/screenrc.bak; \
|
||||
fi; \
|
||||
true >/etc/screenrc; \
|
||||
screen sh -c 'while true; do pidof ${1##*/} || "$@"; sleep 5; done' _ "$@"; \
|
||||
cp -f /etc/screenrc.bak /etc/screenrc; \
|
||||
}; \
|
||||
|
||||
if [ "$hold" = 1 ]; then \
|
||||
di auto-install/enable boolean false; \
|
||||
di debconf/priority select low; \
|
||||
di partman/early_command string; \
|
||||
else \
|
||||
{ \
|
||||
echo 'Reinstalling...'; \
|
||||
echo 'Option 1. View logs:'; \
|
||||
echo ' tail -fn+1 /var/log/syslog'; \
|
||||
echo 'Option 2. Attach to the installer:'; \
|
||||
echo ' TERM=screen screen -xp1'; \
|
||||
} >>/etc/motd; \
|
||||
mem=$(grep ^MemTotal: /proc/meminfo | { read -r _ y _; echo "$((y / 1024))"; }); \
|
||||
if command -v websocketd && [ "$mem" -ge 400 ]; then \
|
||||
for _ in {1..10}; do \
|
||||
if wget "$confhome/logviewer.html" -O /tmp/index.html; then \
|
||||
break; \
|
||||
fi; \
|
||||
sleep 5; \
|
||||
done; \
|
||||
if [ -z "$web_port" ]; then \
|
||||
web_port=80; \
|
||||
fi; \
|
||||
run_as_service_with_screen websocketd --port 80 --loglevel=fatal --staticdir=/tmp \
|
||||
sh -c "tail -fn+0 /var/log/syslog | tr '\r' '\n' | grep -Fiv -e password -e token" ; \
|
||||
fi; \
|
||||
fi; \
|
||||
|
||||
if ! [ "$hold" = 2 ]; then \
|
||||
di finish-install/reboot_in_progress note; \
|
||||
fi; \
|
||||
|
||||
if [ -s /configs/ssh_keys ]; then \
|
||||
di passwd/root-password-crypted password "''"; \
|
||||
else \
|
||||
di passwd/root-password-crypted password "$(cat /configs/password-linux-sha512)"; \
|
||||
fi; \
|
||||
|
||||
mkdir -p /etc/ssh; \
|
||||
true >/etc/ssh/sshd_config; \
|
||||
if [ -s /configs/ssh_keys ]; then \
|
||||
(umask 077; mkdir -p /.ssh; cat /configs/ssh_keys >/.ssh/authorized_keys); \
|
||||
else \
|
||||
echo "PermitRootLogin yes" >>/etc/ssh/sshd_config; \
|
||||
fi; \
|
||||
if [ -n "$ssh_port" ] && ! [ "$ssh_port" = 22 ]; then \
|
||||
echo "Port $ssh_port" >>/etc/ssh/sshd_config; \
|
||||
fi; \
|
||||
grep -qs ^root: /etc/shadow || echo "root:$(cat /configs/password-linux-sha512):1:0:99999:7:::" >>/etc/shadow; \
|
||||
grep -qs ^nogroup: /etc/group || echo "nogroup:*:65534:" >>/etc/group; \
|
||||
grep -qs ^sshd: /etc/passwd || echo "sshd:*:100:65534::/run/sshd:/bin/false" >>/etc/passwd; \
|
||||
mkdir -p /run/sshd; \
|
||||
chmod 0755 /run/sshd; \
|
||||
ssh-keygen -A; \
|
||||
run_as_service_with_screen /usr/sbin/sshd -D; \
|
||||
|
||||
if ls /configs/frpc.* >/dev/null 2>&1; then \
|
||||
url=$(sh /get-frpc-url.sh linux); \
|
||||
mkdir -p /usr/local/bin; \
|
||||
mkdir -p /usr/local/etc/frpc; \
|
||||
for _ in {1..10}; do \
|
||||
if wget -O- "$url" | tar xz "*/frpc" -O >/usr/local/bin/frpc; then \
|
||||
break; \
|
||||
fi; \
|
||||
sleep 5; \
|
||||
done; \
|
||||
chmod a+x /usr/local/bin/frpc; \
|
||||
cp /configs/frpc.* /usr/local/etc/frpc/; \
|
||||
run_as_service_with_screen /usr/local/bin/frpc -c /usr/local/etc/frpc/frpc.*; \
|
||||
fi; \
|
||||
|
||||
if [ -d /cdrom/simple-cdd ]; then \
|
||||
anna-install simple-cdd-profiles; \
|
||||
fi
|
||||
|
||||
# debian 11 initrd 没有 xargs awk
|
||||
# debian 12 initrd 没有 xargs
|
||||
@ -132,10 +237,11 @@ d-i partman/early_command string true; \
|
||||
true >$postinst; \
|
||||
|
||||
swapfile=/target/swapfile; \
|
||||
mem=$(grep ^MemTotal: /proc/meminfo | { read -r _ y _; echo "$y"; }); \
|
||||
mem=$((mem / 1024)); \
|
||||
mem=$(grep ^MemTotal: /proc/meminfo | { read -r _ y _; echo "$((y / 1024))"; }); \
|
||||
swap_size=$((512 - mem)); \
|
||||
[ $swap_size -gt 0 ] && echo "fallocate -l ${swap_size}M $swapfile; mkswap $swapfile; swapon $swapfile" >>$postinst; \
|
||||
if [ $swap_size -gt 0 ]; then \
|
||||
echo "fallocate -l ${swap_size}M $swapfile; mkswap $swapfile; swapon $swapfile" >>$postinst; \
|
||||
fi; \
|
||||
|
||||
echo "swapoff -a; rm -f $swapfile" >/usr/lib/finish-install.d/95swapoff; \
|
||||
chmod a+x /usr/lib/finish-install.d/95swapoff; \
|
||||
@ -152,12 +258,15 @@ d-i partman/early_command string true; \
|
||||
|
||||
eths=$(cd /dev/netconf/ && ls); \
|
||||
|
||||
sh /can_use_cloud_kernel.sh "$xda" $eths || debconf-set base-installer/kernel/image "$(debconf-get base-installer/kernel/image | sed 's/-cloud//')"; \
|
||||
if ! sh /can_use_cloud_kernel.sh "$xda" $eths; then \
|
||||
debconf-set base-installer/kernel/image "$(debconf-get base-installer/kernel/image | sed 's/-cloud//')"; \
|
||||
fi; \
|
||||
|
||||
[ -d /sys/firmware/efi ] && debconf-set partman-auto/expert_recipe "$(debconf-get partman-auto/expert_recipe_efi)"; \
|
||||
[ -d /sys/firmware/efi ] || debconf-set partman-auto/expert_recipe "$(debconf-get partman-auto/expert_recipe_bios)"; \
|
||||
|
||||
debconf-set passwd/root-password-crypted "$(cat /configs/password-linux-sha512)"; \
|
||||
if [ -d /sys/firmware/efi ]; then \
|
||||
debconf-set partman-auto/expert_recipe "$(debconf-get partman-auto/expert_recipe_efi)"; \
|
||||
else \
|
||||
debconf-set partman-auto/expert_recipe "$(debconf-get partman-auto/expert_recipe_bios)"; \
|
||||
fi; \
|
||||
|
||||
true >/bin/os-prober
|
||||
|
||||
@ -187,18 +296,12 @@ d-i preseed/late_command string true; \
|
||||
echo "Port $ssh_port" >>/target/etc/ssh/sshd_config; \
|
||||
fi; \
|
||||
|
||||
if [ -s /configs/frpc.toml ]; then \
|
||||
url=$(sh /get-frpc-url.sh linux); \
|
||||
basename=$(echo "$url" | sed 's,.*/,,' | sed 's,\.tar\.gz,,'); \
|
||||
if ls /configs/frpc.* >/dev/null 2>&1; then \
|
||||
mkdir -p /target/usr/local/bin; \
|
||||
mkdir -p /target/usr/local/etc/frpc; \
|
||||
for i in {1..5}; do \
|
||||
wget -O /target/frpc.tar.gz "$url" && break; \
|
||||
done; \
|
||||
tar xzf /target/frpc.tar.gz "$basename/frpc" -O >/target/usr/local/bin/frpc; \
|
||||
rm -f /target/frpc.tar.gzx; \
|
||||
cp /usr/local/bin/frpc /target/usr/local/bin/; \
|
||||
cp /usr/local/etc/frpc/frpc.* /target/usr/local/etc/frpc/; \
|
||||
chmod a+x /target/usr/local/bin/frpc; \
|
||||
cp /configs/frpc.toml /target/usr/local/etc/frpc/; \
|
||||
cp /frpc.service /target/etc/systemd/system/; \
|
||||
in-target systemctl enable frpc; \
|
||||
fi; \
|
||||
|
||||
@ -48,20 +48,39 @@ retry() {
|
||||
# 用 systemd-analyze plot >a.svg 发现 sys-subsystem-net-devices-enp3s0.device 也是出现在 NetworkManager 之后
|
||||
# 因此需要等待网卡出现
|
||||
get_ethx_by_mac() {
|
||||
mac=$(echo "$1" | to_lower)
|
||||
retry 10 _get_ethx_by_mac "$mac"
|
||||
retry 10 _get_ethx_by_mac "$@"
|
||||
}
|
||||
|
||||
_get_ethx_by_mac() {
|
||||
mac=$(echo "$1" | to_lower)
|
||||
|
||||
flag=$2
|
||||
if [ -z "$flag" ]; then
|
||||
flag=master
|
||||
fi
|
||||
|
||||
if true; then
|
||||
# 过滤 azure vf (带 master ethx)
|
||||
ip -o link | grep -i "$mac" | grep -v master | awk '{print $2}' | cut -d: -f1 | grep .
|
||||
return
|
||||
if [ "$flag" = master ]; then
|
||||
# master
|
||||
# 过滤 azure vf (带 master ethx)
|
||||
ip -o link | grep -i "$mac" | grep -v master | awk '{print $2}' | cut -d: -f1 | grep .
|
||||
else
|
||||
# slave
|
||||
# 带 master ethx
|
||||
ip -o link | grep -i "$mac" | grep -w master | awk '{print $2}' | cut -d: -f1 | grep .
|
||||
fi
|
||||
else
|
||||
for i in $(cd /sys/class/net && echo *); do
|
||||
if [ "$(cat "/sys/class/net/$i/address")" = "$mac" ]; then
|
||||
echo "$i"
|
||||
return
|
||||
if [ $(($(cat "/sys/class/net/$i/flags") & 0x800)) -ne 0 ]; then
|
||||
fact_flag=slave
|
||||
else
|
||||
fact_flag=master
|
||||
fi
|
||||
if [ "$flag" = "$fact_flag" ]; then
|
||||
echo "$i"
|
||||
return
|
||||
fi
|
||||
fi
|
||||
done
|
||||
return 1
|
||||
@ -138,6 +157,23 @@ fix_network_manager() {
|
||||
|
||||
# 更改文件名
|
||||
mv "$file" "$proper_file"
|
||||
|
||||
# NM 不会自动忽略 Azure 的 slave 网卡,需手动设置
|
||||
# azure 文档中的方法不够通用,只适合 azure
|
||||
# https://learn.microsoft.com/zh-cn/azure/virtual-network/accelerated-networking-overview
|
||||
|
||||
# 我们采用红帽的方法
|
||||
# https://docs.redhat.com/en/documentation/red_hat_enterprise_linux/8/html/configuring_and_managing_networking/configuring-networkmanager-to-ignore-certain-devices_configuring-and-managing-networking
|
||||
if slave_ethx=$(get_ethx_by_mac "$mac" slave); then
|
||||
cat >"/etc/NetworkManager/conf.d/99-$slave_ethx-unmanaged.conf" <<EOF
|
||||
[device-$slave_ethx-unmanaged]
|
||||
match-device=interface-name:$slave_ethx
|
||||
managed=0
|
||||
EOF
|
||||
fi
|
||||
|
||||
# 也可以设置 unmanaged-devices, 但是官方文档不推荐
|
||||
# https://networkmanager.pages.freedesktop.org/NetworkManager/NetworkManager/NetworkManager.conf.html#:~:text=may%20be%20a-,better%20choice,-.
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
serverAddr = "YOUR_FRP_SERVER_IP"
|
||||
serverAddr = "11.22.33.44"
|
||||
serverPort = 7000
|
||||
auth.token = "YOUR_FRP_TOKEN"
|
||||
auth.token = "123456"
|
||||
|
||||
[[proxies]]
|
||||
name = "ssh"
|
||||
|
||||
@ -10,8 +10,8 @@ Type=simple
|
||||
User=nobody
|
||||
Restart=on-failure
|
||||
RestartSec=5s
|
||||
ExecStart=/usr/local/bin/frpc -c /usr/local/etc/frpc/frpc.toml
|
||||
ExecReload=/usr/local/bin/frpc reload -c /usr/local/etc/frpc/frpc.toml
|
||||
ExecStart=/usr/local/bin/frpc -c /usr/local/etc/frpc/frpc.conf
|
||||
ExecReload=/usr/local/bin/frpc reload -c /usr/local/etc/frpc/frpc.conf
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
|
||||
@ -10,21 +10,48 @@ is_in_china() {
|
||||
}
|
||||
|
||||
is_ipv6_only() {
|
||||
! grep -q 1 /dev/netconf/eth*/ipv4_has_internet
|
||||
! grep -q 1 /dev/netconf/*/ipv4_has_internet
|
||||
}
|
||||
|
||||
get_frpc_url() {
|
||||
# 传入 windows 或者 linux
|
||||
local os_type=$1
|
||||
local nt_ver=$2
|
||||
local os_bit=${3:-64}
|
||||
|
||||
get_old_version() {
|
||||
# 脚本不支持安装 32 位 linux 系统,因此不用管
|
||||
if [ "$os_type" = windows ]; then
|
||||
# 最早支持 toml 的版本是 0.52.0
|
||||
|
||||
# 最后支持 vista 的版本是 0.29.0
|
||||
# 最后支持 32 位的版本是 0.51.3
|
||||
# 最后支持 win7 的版本是 0.54.0
|
||||
case "$os_bit" in
|
||||
32)
|
||||
case "$nt_ver" in
|
||||
6.0) echo 0.29.0 ;; # vista
|
||||
*) echo 0.51.3 ;; # win7+
|
||||
esac
|
||||
;;
|
||||
64)
|
||||
case "$nt_ver" in
|
||||
6.0) echo 0.29.0 ;; # vista
|
||||
6.1) echo 0.54.0 ;; # win7
|
||||
# 目前最新版本 v0.66.0 依然可以在 win8 上运行
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
}
|
||||
|
||||
is_need_old_version() {
|
||||
[ "$nt_ver" = "6.0" ] || [ "$nt_ver" = "6.1" ]
|
||||
[ -n "$(get_old_version)" ]
|
||||
}
|
||||
|
||||
version=$(
|
||||
if is_need_old_version; then
|
||||
echo 0.54.0
|
||||
get_old_version
|
||||
else
|
||||
# debian 11 initrd 没有 xargs awk
|
||||
# debian 12 initrd 没有 xargs
|
||||
@ -46,7 +73,7 @@ get_frpc_url() {
|
||||
)
|
||||
|
||||
if [ -z "$version" ]; then
|
||||
echo 'cannot find version'
|
||||
echo 'cannot find version' >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
@ -60,10 +87,11 @@ get_frpc_url() {
|
||||
mirror=$(
|
||||
# nju 没有 win7 用的旧版
|
||||
# github 不支持 ipv6
|
||||
# daocloud 加速不支持 ipv6
|
||||
# jsdelivr 不支持 github releases 文件
|
||||
if is_ipv6_only; then
|
||||
if is_need_old_version; then
|
||||
echo 'NOT_SUPPORT'
|
||||
echo 'NOT_SUPPORT' >&2
|
||||
return 1
|
||||
else
|
||||
echo https://mirrors.nju.edu.cn/github-release/fatedier/frp
|
||||
@ -71,7 +99,7 @@ get_frpc_url() {
|
||||
else
|
||||
if is_in_china; then
|
||||
if is_need_old_version; then
|
||||
echo https://github.com/fatedier/frp/releases/download
|
||||
echo https://files.m.daocloud.io/github.com/fatedier/frp/releases/download
|
||||
else
|
||||
echo https://mirrors.nju.edu.cn/github-release/fatedier/frp
|
||||
fi
|
||||
@ -83,7 +111,12 @@ get_frpc_url() {
|
||||
|
||||
arch=$(
|
||||
case "$(uname -m)" in
|
||||
x86_64) echo amd64 ;;
|
||||
x86_64)
|
||||
case "$os_bit" in
|
||||
32) echo 386 ;;
|
||||
64) echo amd64 ;;
|
||||
esac
|
||||
;;
|
||||
aarch64) echo arm64 ;;
|
||||
esac
|
||||
)
|
||||
|
||||
@ -11,6 +11,7 @@ ipv4_gateway=$3
|
||||
ipv6_addr=$4
|
||||
ipv6_gateway=$5
|
||||
is_in_china=$6
|
||||
ipv6_extra_addrs=$7
|
||||
|
||||
DHCP_TIMEOUT=15
|
||||
DNS_FILE_TIMEOUT=5
|
||||
@ -171,6 +172,15 @@ add_missing_ipv6_config() {
|
||||
ip -6 route add default via "$ipv6_gateway" dev "$ethx" onlink
|
||||
fi
|
||||
fi
|
||||
|
||||
# 添加额外的 IPv6 地址(逗号分隔)
|
||||
if [ -n "$ipv6_extra_addrs" ]; then
|
||||
printf '%s\n' "$ipv6_extra_addrs" | tr ',' '\n' | while IFS= read -r addr; do
|
||||
if [ -n "$addr" ]; then
|
||||
ip -6 addr add "$addr" dev "$ethx" 2>/dev/null || true
|
||||
fi
|
||||
done
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
@ -240,11 +250,17 @@ test_connect() {
|
||||
test_internet() {
|
||||
for i in $(seq 5); do
|
||||
echo "Testing Internet Connection. Test $i... "
|
||||
if is_need_test_ipv4 && { local current_ipv4_addr; current_ipv4_addr="$(get_first_ipv4_addr | remove_netmask)"; test_connect "$current_ipv4_addr" "$ipv4_dns1" >/dev/null 2>&1 || test_connect "$current_ipv4_addr" "$ipv4_dns2" >/dev/null 2>&1; }; then
|
||||
if is_need_test_ipv4 &&
|
||||
current_ipv4_addr="$(get_first_ipv4_addr | remove_netmask)" &&
|
||||
{ test_connect "$current_ipv4_addr" "$ipv4_dns1" ||
|
||||
test_connect "$current_ipv4_addr" "$ipv4_dns2"; } >/dev/null 2>&1; then
|
||||
echo "IPv4 has internet."
|
||||
ipv4_has_internet=true
|
||||
fi
|
||||
if is_need_test_ipv6 && { local current_ipv6_addr; current_ipv6_addr="$(get_first_ipv6_addr | remove_netmask)"; test_connect "$current_ipv6_addr" "$ipv6_dns1" >/dev/null 2>&1 || test_connect "$current_ipv6_addr" "$ipv6_dns2" >/dev/null 2>&1; }; then
|
||||
if is_need_test_ipv6 &&
|
||||
current_ipv6_addr="$(get_first_ipv6_addr | remove_netmask)" &&
|
||||
{ test_connect "$current_ipv6_addr" "$ipv6_dns1" ||
|
||||
test_connect "$current_ipv6_addr" "$ipv6_dns2"; } >/dev/null 2>&1; then
|
||||
echo "IPv6 has internet."
|
||||
ipv6_has_internet=true
|
||||
fi
|
||||
@ -339,13 +355,14 @@ EOF
|
||||
db_progress INFO netcfg/link_detect_progress
|
||||
else
|
||||
# alpine
|
||||
# h3c 移动云电脑使用 udhcpc 会重复提示 sending select,无法获得 ipv6,因此使用 dhcpcd
|
||||
method=dhcpcd
|
||||
# h3c 移动云电脑使用 udhcpc 会重复提示 sending select,因此添加 timeout 强制结束进程
|
||||
# dhcpcd 会配置租约时间,过期会移除 IP,但我们的没有在后台运行 dhcpcd ,因此用 udhcpc
|
||||
method=udhcpc
|
||||
|
||||
case "$method" in
|
||||
udhcpc)
|
||||
udhcpc -i "$ethx" -f -q -n || true
|
||||
udhcpc6 -i "$ethx" -f -q -n || true
|
||||
timeout $DHCP_TIMEOUT udhcpc -i "$ethx" -f -q -n || true
|
||||
timeout $DHCP_TIMEOUT udhcpc6 -i "$ethx" -f -q -n || true
|
||||
sleep $DNS_FILE_TIMEOUT # 好像不用等待写入 dns,但是以防万一
|
||||
;;
|
||||
dhcpcd)
|
||||
@ -499,5 +516,6 @@ echo "$ipv4_addr" >"$netconf/ipv4_addr"
|
||||
echo "$ipv4_gateway" >"$netconf/ipv4_gateway"
|
||||
echo "$ipv6_addr" >"$netconf/ipv6_addr"
|
||||
echo "$ipv6_gateway" >"$netconf/ipv6_gateway"
|
||||
echo "$ipv6_extra_addrs" >"$netconf/ipv6_extra_addrs"
|
||||
$ipv4_has_internet && echo 1 >"$netconf/ipv4_has_internet" || echo 0 >"$netconf/ipv4_has_internet"
|
||||
$ipv6_has_internet && echo 1 >"$netconf/ipv6_has_internet" || echo 0 >"$netconf/ipv6_has_internet"
|
||||
|
||||
@ -66,6 +66,12 @@
|
||||
const scrollToBottomButton = document.getElementById('scroll-to-bottom');
|
||||
let shouldScrollToBottom = true;
|
||||
|
||||
// 缓冲区相关
|
||||
let messageBuffer = [];
|
||||
let flushScheduled = false;
|
||||
const BUFFER_FLUSH_INTERVAL = 100; // 毫秒
|
||||
const BUFFER_MAX_SIZE = 50; // 最大缓冲消息数
|
||||
|
||||
scrollToBottomButton.addEventListener('click', () => {
|
||||
logContainer.scrollTop = logContainer.scrollHeight;
|
||||
});
|
||||
@ -81,30 +87,71 @@
|
||||
shouldScrollToBottom = isAtBottom;
|
||||
});
|
||||
|
||||
var ws = new ReconnectingWebSocket('ws://' + location.host + '/');
|
||||
ws.onopen = function () {
|
||||
logContainer.textContent += '\nWebSocket Connected.';
|
||||
};
|
||||
ws.onclose = function () {
|
||||
logContainer.textContent += '\nWebSocket Disconnected.';
|
||||
};
|
||||
ws.onmessage = function (event) {
|
||||
logContainer.textContent += '\n' + event.data;
|
||||
// 刷新缓冲区到 DOM
|
||||
function flushBuffer() {
|
||||
if (messageBuffer.length === 0) {
|
||||
flushScheduled = false;
|
||||
return;
|
||||
}
|
||||
|
||||
// 批量更新文本内容
|
||||
const batchText = messageBuffer.join('\n');
|
||||
logContainer.textContent += '\n' + batchText;
|
||||
|
||||
// 检查状态变化(优先级:error > done > start)
|
||||
if (batchText.includes('***** ERROR *****')) {
|
||||
document.body.className = 'error';
|
||||
} else if (batchText.includes('***** DONE *****')) {
|
||||
document.body.className = 'done';
|
||||
} else if (batchText.includes('***** START TRANS *****')) {
|
||||
document.body.className = '';
|
||||
}
|
||||
|
||||
// 自动滚动
|
||||
if (shouldScrollToBottom) {
|
||||
logContainer.scrollTop = logContainer.scrollHeight;
|
||||
}
|
||||
// 开始/重新开始
|
||||
if (event.data.includes('***** START TRANS *****')) {
|
||||
document.body.className = ''
|
||||
|
||||
// 清空缓冲区
|
||||
messageBuffer = [];
|
||||
flushScheduled = false;
|
||||
}
|
||||
|
||||
// 调度刷新
|
||||
function scheduleFlush() {
|
||||
if (!flushScheduled) {
|
||||
flushScheduled = true;
|
||||
requestAnimationFrame(() => {
|
||||
setTimeout(flushBuffer, BUFFER_FLUSH_INTERVAL);
|
||||
});
|
||||
}
|
||||
// 错误
|
||||
else if (event.data.includes('***** ERROR *****')) {
|
||||
document.body.className = 'error'
|
||||
}
|
||||
// 完成
|
||||
else if (event.data.includes('***** DONE *****')) {
|
||||
document.body.className = 'done'
|
||||
}
|
||||
|
||||
// 添加消息到缓冲区
|
||||
function bufferMessage(message) {
|
||||
messageBuffer.push(message);
|
||||
|
||||
// 如果缓冲区满了,立即刷新
|
||||
if (messageBuffer.length >= BUFFER_MAX_SIZE) {
|
||||
if (flushScheduled) {
|
||||
// 取消之前的调度,立即刷新
|
||||
flushScheduled = false;
|
||||
}
|
||||
flushBuffer();
|
||||
} else {
|
||||
scheduleFlush();
|
||||
}
|
||||
}
|
||||
|
||||
var ws = new ReconnectingWebSocket('ws://' + location.host + '/');
|
||||
ws.onopen = function () {
|
||||
bufferMessage('WebSocket Connected.');
|
||||
};
|
||||
ws.onclose = function () {
|
||||
bufferMessage('WebSocket Disconnected.');
|
||||
};
|
||||
ws.onmessage = function (event) {
|
||||
bufferMessage(event.data);
|
||||
};
|
||||
</script>
|
||||
</body>
|
||||
|
||||
@ -131,6 +131,13 @@ call :check_cygwin_installed || (
|
||||
set dir=/sourceware/cygwin
|
||||
)
|
||||
|
||||
rem daocloud 加速有 90 天缓存,且不支持 IPv6
|
||||
rem https://github.com/DaoCloud/public-binary-files-mirror
|
||||
rem 无法用查询字符串强制刷新缓存
|
||||
rem https://files.m.daocloud.io/www.cloudflare.com/cdn-cgi/trace?a=1
|
||||
rem https://files.m.daocloud.io/www.cloudflare.com/cdn-cgi/trace?b=2
|
||||
rem 也就无法用 https://www.cygwin.com/setup-x86_64.exe?xxx=20250101 强制每天刷新缓存
|
||||
|
||||
rem 下载 Cygwin
|
||||
if not exist setup-!CygwinArch!.exe (
|
||||
call :download http://www.cygwin.com/setup-!CygwinArch!.exe %~dp0setup-!CygwinArch!.exe || goto :download_failed
|
||||
@ -195,7 +202,7 @@ rem bitsadmin /transfer "%~3" /priority foreground %~1 %~2
|
||||
:download
|
||||
rem certutil 会被 windows Defender 报毒
|
||||
rem windows server 2019 要用第二条 certutil 命令
|
||||
echo Download: %~1 %~2
|
||||
echo Downloading: %~1 %~2
|
||||
del /q "%~2" 2>nul
|
||||
if exist "%~2" (echo Cannot delete %~2 & exit /b 1)
|
||||
|
||||
|
||||
1506
reinstall.sh
1506
reinstall.sh
File diff suppressed because it is too large
Load Diff
BIN
windows-frpc.xml
BIN
windows-frpc.xml
Binary file not shown.
@ -12,56 +12,90 @@ rem set ipv6_dns2=::2
|
||||
|
||||
@echo off
|
||||
mode con cp select=437 >nul
|
||||
setlocal EnableDelayedExpansion
|
||||
|
||||
rem 禁用 IPv6 地址标识符的随机化,防止 IPv6 和后台面板不一致
|
||||
netsh interface ipv6 set global randomizeidentifiers=disabled
|
||||
|
||||
rem 检查是否定义了 MAC 地址
|
||||
if defined mac_addr (
|
||||
for /f %%a in ('wmic nic where "MACAddress='%mac_addr%'" get InterfaceIndex ^| findstr [0-9]') do set id=%%a
|
||||
if defined id (
|
||||
rem 配置静态 IPv4 地址和网关
|
||||
if defined ipv4_addr if defined ipv4_gateway (
|
||||
rem gwmetric 默认值为 1,自动跃点需设为 0
|
||||
netsh interface ipv4 set address !id! static !ipv4_addr! gateway=!ipv4_gateway! gwmetric=0
|
||||
)
|
||||
if not defined mac_addr goto :del
|
||||
|
||||
rem 配置静态 IPv4 DNS 服务器
|
||||
for %%i in (1, 2) do (
|
||||
if defined ipv4_dns%%i (
|
||||
netsh interface ipv4 add | findstr "dnsservers"
|
||||
if ErrorLevel 1 (
|
||||
rem vista
|
||||
netsh interface ipv4 add dnsserver !id! !ipv4_dns%%i! %%i
|
||||
) else (
|
||||
rem win7
|
||||
netsh interface ipv4 add dnsservers !id! !ipv4_dns%%i! %%i no
|
||||
)
|
||||
rem vista 没有自带 powershell
|
||||
rem win11 24h2 安装后有 wmic,但是过一段时间会自动删除,因此有的 dd 镜像没有 wmic
|
||||
if exist "%windir%\system32\wbem\wmic.exe" (
|
||||
rem wmic 换行符是 \r\r\n
|
||||
rem 虽然这里用了 findstr 全字匹配 ,但是结尾还是有 \r
|
||||
for /f "tokens=2 delims==" %%a in (
|
||||
'wmic nic where "MACAddress='%mac_addr%'" get InterfaceIndex /format:list ^| findstr "^InterfaceIndex=[0-9][0-9]*$"'
|
||||
) do set id=%%a
|
||||
)
|
||||
|
||||
if not defined id (
|
||||
for /f %%a in ('powershell -NoLogo -NoProfile -NonInteractive -ExecutionPolicy Bypass ^
|
||||
-Command "(Get-WmiObject Win32_NetworkAdapter | Where-Object { $_.MACAddress -eq '%mac_addr%' }).InterfaceIndex" ^| findstr "^[0-9][0-9]*$"'
|
||||
) do set id=%%a
|
||||
)
|
||||
|
||||
if not defined id (
|
||||
for /f %%a in ('powershell -NoLogo -NoProfile -NonInteractive -ExecutionPolicy Bypass ^
|
||||
-Command "(Get-CimInstance Win32_NetworkAdapter | Where-Object { $_.MACAddress -eq '%mac_addr%' }).InterfaceIndex" ^| findstr "^[0-9][0-9]*$"'
|
||||
) do set id=%%a
|
||||
)
|
||||
|
||||
if defined id (
|
||||
rem 配置静态 IPv4 地址和网关
|
||||
if defined ipv4_addr if defined ipv4_gateway (
|
||||
rem 如果使用了 setlocal EnableDelayedExpansion
|
||||
rem netsh interface ipv4 set address !id! static %ipv4_addr% gateway=%ipv4_gateway% gwmetric=0
|
||||
rem !id! 变量最后有 \r 会导致语句不正确
|
||||
rem %id% 变量则没有这个问题
|
||||
|
||||
rem gwmetric 默认值为 1,自动跃点需设为 0
|
||||
netsh interface ipv4 set address %id% static %ipv4_addr% gateway=%ipv4_gateway% gwmetric=0
|
||||
)
|
||||
|
||||
rem 配置静态 IPv4 DNS 服务器
|
||||
for %%i in (1, 2) do (
|
||||
if defined ipv4_dns%%i (
|
||||
netsh interface ipv4 add | findstr "dnsservers" >nul
|
||||
if ErrorLevel 1 (
|
||||
rem vista
|
||||
setlocal EnableDelayedExpansion
|
||||
netsh interface ipv4 add dnsserver %id% !ipv4_dns%%i! %%i
|
||||
endlocal
|
||||
) else (
|
||||
rem win7
|
||||
setlocal EnableDelayedExpansion
|
||||
netsh interface ipv4 add dnsservers %id% !ipv4_dns%%i! %%i no
|
||||
endlocal
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
rem 配置 IPv6 地址和网关
|
||||
if defined ipv6_addr if defined ipv6_gateway (
|
||||
netsh interface ipv6 set address !id! !ipv6_addr!
|
||||
netsh interface ipv6 add route prefix=::/0 !id! !ipv6_gateway!
|
||||
)
|
||||
rem 配置 IPv6 地址和网关
|
||||
if defined ipv6_addr if defined ipv6_gateway (
|
||||
netsh interface ipv6 set address %id% %ipv6_addr%
|
||||
netsh interface ipv6 add route prefix=::/0 %id% %ipv6_gateway%
|
||||
)
|
||||
|
||||
rem 配置 IPv6 DNS 服务器
|
||||
for %%i in (1, 2) do (
|
||||
if defined ipv6_dns%%i (
|
||||
netsh interface ipv6 add | findstr "dnsservers"
|
||||
if ErrorLevel 1 (
|
||||
rem vista
|
||||
netsh interface ipv6 add dnsserver !id! !ipv6_dns%%i! %%i
|
||||
) else (
|
||||
rem win7
|
||||
netsh interface ipv6 add dnsservers !id! !ipv6_dns%%i! %%i no
|
||||
)
|
||||
rem 配置 IPv6 DNS 服务器
|
||||
for %%i in (1, 2) do (
|
||||
if defined ipv6_dns%%i (
|
||||
netsh interface ipv6 add | findstr "dnsservers" >nul
|
||||
if ErrorLevel 1 (
|
||||
rem vista
|
||||
setlocal EnableDelayedExpansion
|
||||
netsh interface ipv6 add dnsserver %id% !ipv6_dns%%i! %%i
|
||||
endlocal
|
||||
) else (
|
||||
rem win7
|
||||
setlocal EnableDelayedExpansion
|
||||
netsh interface ipv6 add dnsservers %id% !ipv6_dns%%i! %%i no
|
||||
endlocal
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
:del
|
||||
rem 删除此脚本
|
||||
del "%~f0"
|
||||
|
||||
Reference in New Issue
Block a user