mirror of
https://github.com/bin456789/reinstall.git
synced 2026-02-21 10:27:50 +08:00
Merge branch 'bin456789:main' into main
This commit is contained in:
commit
f5f459a0cd
@ -8,9 +8,13 @@ charset = utf-8
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
|
||||
[windows.xml]
|
||||
[{windows.xml,windows-*.xml}]
|
||||
end_of_line = crlf
|
||||
|
||||
[windows-frpc.xml]
|
||||
charset = utf-16-le
|
||||
indent_size = 2
|
||||
|
||||
[*.{bat,cmd,ps1}]
|
||||
end_of_line = crlf
|
||||
|
||||
|
||||
15
.github/ISSUE_TEMPLATE/bug_report.md
vendored
15
.github/ISSUE_TEMPLATE/bug_report.md
vendored
@ -7,10 +7,13 @@ assignees: ''
|
||||
|
||||
---
|
||||
|
||||
原来的系统:
|
||||
要安装的系统:
|
||||
遇到的问题:截图或者登录 SSH 获取日志 /reinstall.log
|
||||
原来的系统 (Original system):
|
||||
|
||||
Original system:
|
||||
System to be installed:
|
||||
Issues encountered: Screenshot or log in via SSH to get the logs from /reinstall.log
|
||||
要安装的系统 (System to be installed):
|
||||
|
||||
遇到的问题 (Issue):
|
||||
|
||||
<!--
|
||||
请上传截图或者报错内容,注意删除 IP 地址和密码
|
||||
(Please Upload Screenshot or error message. Be sure to delete the IP address and password)
|
||||
-->
|
||||
|
||||
20
.github/workflows/run_reinstall.yml
vendored
20
.github/workflows/run_reinstall.yml
vendored
@ -8,7 +8,6 @@ jobs:
|
||||
run:
|
||||
name: 运行主程序
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [ubuntu-latest, windows-latest]
|
||||
include:
|
||||
@ -22,18 +21,19 @@ 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
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
name: 同步到 Gitlab
|
||||
name: 同步到 CNB
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
jobs:
|
||||
run:
|
||||
name: 同步到 Gitlab
|
||||
name: 同步到 CNB
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
@ -12,7 +12,7 @@ jobs:
|
||||
fetch-depth: 0
|
||||
- uses: yesolutions/mirror-action@master
|
||||
with:
|
||||
REMOTE: https://gitlab.com/bin456789/reinstall.git
|
||||
GIT_USERNAME: username
|
||||
GIT_PASSWORD: ${{ secrets.GITLAB_TOKEN }}
|
||||
REMOTE: https://cnb.cool/bin456789/reinstall.git
|
||||
GIT_USERNAME: cnb
|
||||
GIT_PASSWORD: ${{ secrets.CNB_TOKEN }}
|
||||
PUSH_ALL_REFS: false
|
||||
18
.github/workflows/sync_to_gitlabcn.yml
vendored
18
.github/workflows/sync_to_gitlabcn.yml
vendored
@ -1,18 +0,0 @@
|
||||
name: 同步到 Gitlab CN
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
jobs:
|
||||
run:
|
||||
name: 同步到 Gitlab CN
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- uses: yesolutions/mirror-action@master
|
||||
with:
|
||||
REMOTE: https://jihulab.com/bin456789/reinstall.git
|
||||
GIT_USERNAME: username
|
||||
GIT_PASSWORD: ${{ secrets.JIHULAB_TOKEN }}
|
||||
PUSH_ALL_REFS: false
|
||||
296
README.en.md
296
README.en.md
@ -4,26 +4,40 @@
|
||||
|
||||
[](https://app.codacy.com/gh/bin456789/reinstall/dashboard)
|
||||
[](https://www.codefactor.io/repository/github/bin456789/reinstall)
|
||||
[](https://github.com/XAMPPRocky/tokei)
|
||||
[](https://t.me/reinstall_os)
|
||||
[](https://github.com/sponsors/bin456789)
|
||||
<!-- [](https://github.com/aschey/vercel-tokei) -->
|
||||
[](https://github.com/XAMPPRocky/tokei_rs)
|
||||
|
||||
One-Click Script to Reinstall System [中文](README.md)
|
||||
One-Click system reinstallation script for VPS [中文](README.md)
|
||||
|
||||
[](https://github.com/sponsors/bin456789)
|
||||
## Introduction
|
||||
|
||||
## Highlights
|
||||
|
||||
- One-click Linux installation: Supports 19 common distributions.
|
||||
- One-click Windows installation: Uses the official ISO for installation instead of custom images. The script can automatically ~~retrieves the ISO link~~ and installs common drivers like `Virtio`.
|
||||
- Supports installation in any direction, i.e., `Linux to Linux`, `Linux to Windows`, `Windows to Windows`, `Windows to Linux`
|
||||
- No need to input IP parameters; automatically recognizes dynamic and static IPs, supports `/32`, `/128`, `gateway outside subnet`, `IPv6 only`, `dual NIC`
|
||||
- One-click reinstallation to Linux: Supports 19 common distributions.
|
||||
- One-click reinstallation to Windows: Uses the official original ISO instead of custom images. The script can automatically fetch the ISO link and installs public cloud drivers like `VirtIO`.
|
||||
- Supports reinstallation in any direction, i.e., `Linux to Linux`, `Linux to Windows`, `Windows to Windows`, `Windows to Linux`
|
||||
- Automatically configures IP and intelligently sets it as static or dynamic. Supports `/32`, `/128`, `gateway outside subnet`, `IPv6 only`, `IPv4/IPv6 on different NIC`
|
||||
- Specially optimized for low-spec servers, requires less memory than the official netboot
|
||||
- Uses partition table ID to identify hard drives throughout the process, ensuring no wrong disk is written
|
||||
- Supports BIOS and EFI boot, and ARM Server
|
||||
- No homemades image included, all resources are obtained in real-time from mirror sites
|
||||
|
||||
If this helped you, you can buy me a milk tea.
|
||||
[](https://github.com/sponsors/bin456789)
|
||||
|
||||
[](https://github.com/sponsors/bin456789)
|
||||
|
||||
### Feedback
|
||||
|
||||
[](https://github.com/bin456789/reinstall/issues)
|
||||
[](https://t.me/reinstall_os)
|
||||
|
||||
## Quick Start
|
||||
|
||||
- [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 4. One-click reboot to netboot.xyz](#feature-4-reboot-to--netbootxyz)
|
||||
- [Feature 5. One-click reinstallation to Windows](#feature-5-install--windows-iso)
|
||||
|
||||
## System Requirements
|
||||
|
||||
The original system can be any system listed in the table.
|
||||
@ -32,22 +46,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.18, 3.19, 3.20, 3.21 | 256 MB | 1 GB |
|
||||
| <img width="16" height="16" src="https://www.debian.org/favicon.ico" /> Debian | 9, 10, 11, 12 | 256 MB | 1 ~ 1.5 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://canonical-subiquity.readthedocs-hosted.com/en/latest/_static/favicon.png" /> Ubuntu | 16.04 LTS - 24.04 LTS, 24.10 | 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 | 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 | 9, 10 | 512 MB \* | 5 GB |
|
||||
| <img width="16" height="16" src="https://fedoraproject.org/favicon.ico" /> Fedora | 40, 41 | 512 MB \* | 5 GB |
|
||||
| <img width="16" height="16" src="https://www.openeuler.org/favicon.ico" /> openEuler | 20.03 LTS - 24.03 LTS, 24.09 | 512 MB \* | 5 GB |
|
||||
| <img width="16" height="16" src="https://static.opensuse.org/favicon.ico" /> openSUSE | 15.6, Tumbleweed (Rolling) | 512 MB \* | 5 GB |
|
||||
| <img width="16" height="16" src="https://github.com/user-attachments/assets/99a542b6-6482-4086-addf-f192c06fef73" /> NixOS | 24.11 | 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 | 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 |
|
||||
@ -57,6 +71,13 @@ The system requirements for the target system are as follows:
|
||||
^ Indicates requiring either 256 MB memory + 1.5 GB disk, or 512 MB memory + 1 GB disk
|
||||
|
||||
> [!WARNING]
|
||||
>
|
||||
> In theory it also supports dedicated servers and PCs
|
||||
>
|
||||
> but if you can use IPMI or a USB drive, this script is not recommended.
|
||||
|
||||
> [!WARNING]
|
||||
>
|
||||
> ❌ This script does not support OpenVZ or LXC virtual machines.
|
||||
>
|
||||
> Please use <https://github.com/LloydAsp/OsMutation> instead.
|
||||
@ -66,13 +87,13 @@ The system requirements for the target system are as follows:
|
||||
For server outside China:
|
||||
|
||||
```bash
|
||||
curl -O https://raw.githubusercontent.com/bin456789/reinstall/main/reinstall.sh || wget -O reinstall.sh $_
|
||||
curl -O https://raw.githubusercontent.com/bin456789/reinstall/main/reinstall.sh || wget -O ${_##*/} $_
|
||||
```
|
||||
|
||||
For server inside China:
|
||||
|
||||
```bash
|
||||
curl -O https://gitlab.com/bin456789/reinstall/-/raw/main/reinstall.sh || wget -O reinstall.sh $_
|
||||
curl -O https://cnb.cool/bin456789/reinstall/-/git/raw/main/reinstall.sh || wget -O ${_##*/} $_
|
||||
```
|
||||
|
||||
## 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)
|
||||
@ -105,7 +126,7 @@ certutil -urlcache -f -split https://raw.githubusercontent.com/bin456789/reinsta
|
||||
For server inside China:
|
||||
|
||||
```batch
|
||||
certutil -urlcache -f -split https://gitlab.com/bin456789/reinstall/-/raw/main/reinstall.bat
|
||||
certutil -urlcache -f -split https://cnb.cool/bin456789/reinstall/-/git/raw/main/reinstall.bat
|
||||
```
|
||||
|
||||
## Usage
|
||||
@ -118,7 +139,13 @@ certutil -urlcache -f -split https://gitlab.com/bin456789/reinstall/-/raw/main/r
|
||||
|
||||
### Feature 1: Install <img width="16" height="16" src="https://www.kernel.org/theme/images/logos/favicon.png" /> Linux
|
||||
|
||||
- The username is `root` with a default password of `123@@@`.
|
||||
> [!CAUTION]
|
||||
>
|
||||
> This feature will erase **the entire hard disk** of the current system (including other partitions)!
|
||||
>
|
||||
> Data is priceless — please think twice before proceeding!
|
||||
|
||||
- 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.
|
||||
@ -127,38 +154,43 @@ certutil -urlcache -f -split https://gitlab.com/bin456789/reinstall/-/raw/main/r
|
||||
|
||||
```bash
|
||||
bash reinstall.sh anolis 7|8|23
|
||||
rocky 8|9|10
|
||||
oracle 8|9|10
|
||||
almalinux 8|9|10
|
||||
opencloudos 8|9|23
|
||||
rocky 8|9
|
||||
redhat 8|9 --img="http://xxx.com/xxx.qcow2"
|
||||
oracle 8|9
|
||||
almalinux 8|9
|
||||
centos 9|10
|
||||
fedora 40|41
|
||||
nixos 24.11
|
||||
debian 9|10|11|12
|
||||
opensuse 15.6|tumbleweed
|
||||
alpine 3.18|3.19|3.20|3.21
|
||||
openeuler 20.03|22.03|24.03|24.09
|
||||
ubuntu 16.04|18.04|20.04|22.04|24.04|24.10 [--minimal]
|
||||
fnos 1
|
||||
nixos 25.11
|
||||
fedora 42|43
|
||||
debian 9|10|11|12|13
|
||||
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"
|
||||
```
|
||||
|
||||
#### Optional Parameters
|
||||
|
||||
- `--password PASSWORD` Set the password
|
||||
- `--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)
|
||||
- `--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).
|
||||
- `--web-port PORT` Change the Web port (for log observation during installation only)
|
||||
- `--frpc-toml PATH` Add frpc for intranet tunneling. Parameter can be local filepath or HTTP URL
|
||||
- `--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 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).
|
||||
> <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>
|
||||
|
||||
@ -192,9 +224,15 @@ bash reinstall.sh ubuntu --installer
|
||||
|
||||
</details>
|
||||
|
||||
### Feature 2: DD
|
||||
### Feature 2: DD RAW image to hard disk
|
||||
|
||||
- Supports `raw` and `vhd` image formats (either uncompressed or compressed as `.gz`, `.xz`, `.zst`, `.tar`, `.tar.gz`, `.tar.xz`, `.tar.zst`).
|
||||
> [!CAUTION]
|
||||
>
|
||||
> This feature will erase **the entire hard disk** of the current system (including other partitions)!
|
||||
>
|
||||
> Data is priceless — please think twice before proceeding!
|
||||
|
||||
- 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.
|
||||
|
||||
@ -202,37 +240,55 @@ bash reinstall.sh ubuntu --installer
|
||||
bash reinstall.sh dd --img "https://example.com/xxx.xz"
|
||||
```
|
||||
|
||||
#### Optional parameters
|
||||
#### Optional Parameters
|
||||
|
||||
- `--allow-ping` Allow ping responses (DD Windows only)
|
||||
- `--allow-ping` Configure Windows Firewall to Allow Ping Responses (DD Windows only)
|
||||
- `--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)
|
||||
- `--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-toml PATH` Add frpc for intranet tunneling (DD Windows only). Parameter can be local filepath or HTTP URL
|
||||
- `--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 in the background, 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.
|
||||
>
|
||||
> 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 (RAM OS)
|
||||
|
||||
- You can use SSH to backup/restore disk, manually perform DD operations, modify partitions, and manually install Alpine, Arch, Gentoo, and other systems.
|
||||
- Username `root`, Default password `123@@@`
|
||||
- If manual operations do not damage the original system, rebooting will return to the original system.
|
||||
- You can use SSH to backup/restore disk, manually perform DD operations, partition modifications, manual Alpine installation, and other operations.
|
||||
- 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
|
||||
#### Optional Parameters
|
||||
|
||||
- `--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` Add frpc for intranet tunneling. Parameter can be local filepath or HTTP URL
|
||||
|
||||
### Feature 4: Reboot to <img width="16" height="16" src="https://netboot.xyz/img/favicon.ico" /> netboot.xyz
|
||||
|
||||
- Can manually 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 manual operations do not damage the original system, rebooting will return to the original system.
|
||||
|
||||
> [!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 netboot.xyz
|
||||
@ -244,10 +300,17 @@ bash reinstall.sh netboot.xyz
|
||||
|
||||

|
||||
|
||||
- Username `administrator`, Default password `123@@@`
|
||||
> [!CAUTION]
|
||||
>
|
||||
> This feature will erase **the entire hard disk** of the current system (including other partitions)!
|
||||
>
|
||||
> Data is priceless — please think twice before proceeding!
|
||||
|
||||
- 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
|
||||
|
||||
@ -256,12 +319,9 @@ bash reinstall.sh netboot.xyz
|
||||
- Windows Server Essentials \*
|
||||
- Windows Server (Semi) Annual Channel \*
|
||||
- Hyper-V Server \*
|
||||
- Azure Stack HCI \*
|
||||
- Azure Local (Azure Stack HCI) \*
|
||||
|
||||
#### ~~Method 1: Let the Script Automatically Search for ISO~~
|
||||
|
||||
> [!CAUTION]
|
||||
> The ISO repository currently prohibits direct link downloads, so this method is no longer effective.
|
||||
#### 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.
|
||||
@ -325,7 +385,7 @@ zh-tw
|
||||
|
||||
```bash
|
||||
bash reinstall.sh windows \
|
||||
--image-name "Windows 11 Enterprise LTSC 2024" \
|
||||
--image-name "Windows 11 Enterprise LTSC 2024 Evaluation" \
|
||||
--iso "https://go.microsoft.com/fwlink/?linkid=2289029"
|
||||
```
|
||||
|
||||
@ -350,7 +410,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>
|
||||
@ -364,30 +423,58 @@ bash reinstall.sh windows \
|
||||
|
||||
</details>
|
||||
|
||||
#### Optional parameters
|
||||
#### Optional Parameters
|
||||
|
||||
- `--password PASSWORD` Set Password
|
||||
- `--allow-ping` Configures the Windows firewall to allow ping requests
|
||||
- `--allow-ping` Configure Windows Firewall to Allow Ping Responses
|
||||
- `--rdp-port PORT` Change RDP port
|
||||
- `--ssh-port PORT` Change SSH port (for log observation during installation)
|
||||
- `--web-port PORT` Change Web port (for log observation during installation)
|
||||
- `--ssh-port PORT` Change SSH port (for log observation during installation only)
|
||||
- `--web-port PORT` Change Web port (for log observation during installation only)
|
||||
- `--add-driver INF_OR_DIR` Add additional driver, specifying .inf path, or the folder contains .inf file.
|
||||
- The driver must be downloaded locally first.
|
||||
- The driver must be downloaded to current system first.
|
||||
- This parameter can be set multiple times to add different driver.
|
||||
- `--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-toml PATH` Add frpc for intranet tunneling. Parameter can be local filepath or HTTP URL
|
||||
- `--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
|
||||
|
||||
- Virtio ([Virtio](https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/), [Alibaba Cloud](https://www.alibabacloud.com/help/ecs/user-guide/update-red-hat-virtio-drivers-of-windows-instances))
|
||||
- XEN ([XEN](https://xenproject.org/resources/downloads/), [Citrix](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Upgrading_PV_drivers.html#win2008-citrix-upgrade), [AWS](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/xen-drivers-overview.html))
|
||||
- AWS ([ENA Network Adapter](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ena-driver-releases-windows.html), [NVMe Storage Controller](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/nvme-driver-version-history.html))
|
||||
- GCP ([gVNIC Network Adapter](https://cloud.google.com/compute/docs/networking/using-gvnic), [GGA Display Adapter](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))
|
||||
- Intel ([VMD Storage Controller](https://www.intel.com/content/www/us/en/download/720755/intel-rapid-storage-technology-driver-installation-software-with-intel-optane-memory-11th-up-to-13th-gen-platforms.html))
|
||||
- VirtIO ([Community][virtio-virtio], [Alibaba Cloud][virtio-aliyun], [Tencent Cloud][virtio-qcloud], [GCP][virtio-gcp])
|
||||
- XEN ([~~Community~~][xen-xen] (unsigned), [Citrix][xen-citrix], [AWS][xen-aws])
|
||||
- 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])
|
||||
|
||||
[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
|
||||
[virtio-qcloud]: https://cloud.tencent.com/document/product/213/17815#b84b2032-752c-43c4-a509-73530b8f82ff
|
||||
[virtio-gcp]: https://console.cloud.google.com/storage/browser/gce-windows-drivers-public
|
||||
[xen-xen]: https://xenproject.org/resources/downloads/
|
||||
[xen-aws]: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/xen-drivers-overview.html
|
||||
[xen-citrix]: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Upgrading_PV_drivers.html#win2008-citrix-upgrade
|
||||
[aws-ena]: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ena-driver-releases-windows.html
|
||||
[aws-nvme]: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/nvme-driver-version-history.html
|
||||
[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-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
|
||||
[intel-nic-2019]: https://www.intel.com/content/www/us/en/download/19372/intel-network-adapter-driver-for-windows-server-2019.html
|
||||
[intel-nic-2022]: https://www.intel.com/content/www/us/en/download/706171/intel-network-adapter-driver-for-windows-server-2022.html
|
||||
[intel-nic-2025]: https://www.intel.com/content/www/us/en/download/838943/intel-network-adapter-driver-for-windows-server-2025.html
|
||||
|
||||
#### How to Specify the Image Name `--image-name`
|
||||
|
||||
Typically, an ISO will contain multiple system versions, such as Home Edition and Professional Edition. The image name `--image-name` is used to specify the version to be installed, and it is case-insensitive when entered.
|
||||
An ISO usually contains multiple system editions, such as Home and Pro. Therefore, you need to use `--image-name` to specify the system edition (image name) to install, case-insensitive.
|
||||
|
||||
You can use tools like DISM, DISM++, or Wimlib to query the image names included in the ISO.
|
||||
|
||||
@ -410,18 +497,32 @@ 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 Windows 11 24H2.
|
||||
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.
|
||||
|
||||
@ -448,10 +549,33 @@ Log in to the server using Remote Desktop, open Device Manager, locate the graph
|
||||
|
||||
</details>
|
||||
|
||||
## Discussion
|
||||
## Parameter Format
|
||||
|
||||
[](https://github.com/bin456789/reinstall/issues)
|
||||
[](https://t.me/reinstall_os)
|
||||
### --ssh-key
|
||||
|
||||
- `--ssh-key "ssh-rsa ..."`
|
||||
- `--ssh-key "ssh-ed25519 ..."`
|
||||
- `--ssh-key "ecdsa-sha2-nistp256/384/521 ..."`
|
||||
- `--ssh-key http://path/to/public_key`
|
||||
- `--ssh-key github:your_username`
|
||||
- `--ssh-key gitlab:your_username`
|
||||
- `--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
|
||||
|
||||
@ -461,8 +585,6 @@ Log in to the server using Remote Desktop, open Device Manager, locate the graph
|
||||
|
||||
## Thanks
|
||||
|
||||
[](https://github.com/sponsors/bin456789)
|
||||
|
||||
Thanks to the following businesses for providing free servers.
|
||||
|
||||
[](https://www.oracle.com/cloud/)
|
||||
|
||||
288
README.md
288
README.md
@ -4,26 +4,40 @@
|
||||
|
||||
[](https://app.codacy.com/gh/bin456789/reinstall/dashboard)
|
||||
[](https://www.codefactor.io/repository/github/bin456789/reinstall)
|
||||
[](https://github.com/XAMPPRocky/tokei)
|
||||
[](https://t.me/reinstall_os)
|
||||
[](https://github.com/sponsors/bin456789)
|
||||
<!-- [](https://github.com/aschey/vercel-tokei) -->
|
||||
[](https://github.com/XAMPPRocky/tokei_rs)
|
||||
|
||||
一键重装脚本 [English](README.en.md)
|
||||
一键 VPS 系统重装脚本 [English](README.en.md)
|
||||
|
||||
[](https://github.com/sponsors/bin456789)
|
||||
## 介绍
|
||||
|
||||
## 亮点
|
||||
|
||||
- 一键安装 Linux,支持 19 种常见发行版
|
||||
- 一键安装 Windows,使用官方 ISO 安装而非自制镜像,~~脚本会自动获取 ISO 链接~~、自动安装 Virtio 等常见驱动
|
||||
- 一键重装到 Linux,支持 19 种常见发行版
|
||||
- 一键重装到 Windows,使用官方原版 ISO 而非自制镜像,脚本支持自动查找 ISO 链接、自动安装 `VirtIO` 等公有云驱动
|
||||
- 支持任意方向重装,即 `Linux to Linux`、`Linux to Windows`、`Windows to Windows`、`Windows to Linux`
|
||||
- 无需填写 IP 参数,自动识别动静态,支持 `/32`、`/128`、`网关不在子网范围内`、`纯 IPv6`、`双网卡`
|
||||
- 自动设置 IP,智能设置动静态,支持 `/32`、`/128`、`网关不在子网范围内`、`纯 IPv6`、`IPv4/IPv6 在不同的网卡`
|
||||
- 专门适配低配小鸡,比官方 netboot 需要更少的内存
|
||||
- 全程用分区表 ID 识别硬盘,确保不会写错硬盘
|
||||
- 支持 BIOS、EFI 引导,支持 ARM 服务器
|
||||
- 不含自制包,所有资源均实时从镜像源获得
|
||||
|
||||
如果帮到你,可以请我喝奶茶。
|
||||
[](https://github.com/sponsors/bin456789)
|
||||
|
||||
[](https://github.com/sponsors/bin456789)
|
||||
|
||||
### 反馈
|
||||
|
||||
[](https://github.com/bin456789/reinstall/issues)
|
||||
[](https://t.me/reinstall_os)
|
||||
|
||||
## 快速开始
|
||||
|
||||
- [下载](#下载当前系统是--linux)
|
||||
- [功能 1. 一键重装到 Linux](#功能-1-安装--linux)
|
||||
- [功能 2. 一键 DD Raw 镜像到硬盘](#功能-2-dd-raw-镜像到硬盘)
|
||||
- [功能 3. 一键引导到 Alpine Live OS 内存系统](#功能-3-重启到--alpine-live-os内存系统)
|
||||
- [功能 4. 一键引导到 netboot.xyz](#功能-4-重启到--netbootxyz)
|
||||
- [功能 5. 一键重装到 Windows](#功能-5-安装--windows-iso)
|
||||
|
||||
## 系统要求
|
||||
|
||||
原系统可以是表格中的任意系统
|
||||
@ -32,22 +46,22 @@
|
||||
|
||||
| 系统 | 版本 | 内存 | 硬盘 |
|
||||
| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------- | --------- | ------------ |
|
||||
| <img width="16" height="16" src="https://www.alpinelinux.org/alpine-logo.ico" /> Alpine | 3.18, 3.19, 3.20, 3.21 | 256 MB | 1 GB |
|
||||
| <img width="16" height="16" src="https://www.debian.org/favicon.ico" /> Debian | 9, 10, 11, 12 | 256 MB | 1 ~ 1.5 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://canonical-subiquity.readthedocs-hosted.com/en/latest/_static/favicon.png" /> Ubuntu | 16.04 LTS - 24.04 LTS, 24.10 | 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 | 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 | 9, 10 | 512 MB \* | 5 GB |
|
||||
| <img width="16" height="16" src="https://fedoraproject.org/favicon.ico" /> Fedora | 40, 41 | 512 MB \* | 5 GB |
|
||||
| <img width="16" height="16" src="https://www.openeuler.org/favicon.ico" /> openEuler | 20.03 LTS - 24.03 LTS, 24.09 | 512 MB \* | 5 GB |
|
||||
| <img width="16" height="16" src="https://static.opensuse.org/favicon.ico" /> openSUSE | 15.6, Tumbleweed (滚动) | 512 MB \* | 5 GB |
|
||||
| <img width="16" height="16" src="https://github.com/user-attachments/assets/99a542b6-6482-4086-addf-f192c06fef73" /> NixOS | 24.11 | 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 | 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 |
|
||||
@ -57,6 +71,13 @@
|
||||
^ 表示需要 256 MB 内存 + 1.5 GB 硬盘,或 512 MB 内存 + 1 GB 硬盘
|
||||
|
||||
> [!WARNING]
|
||||
>
|
||||
> 本脚本理论上支持独服和 PC
|
||||
>
|
||||
> 但如果能使用 IPMI 或 U 盘,则不建议使用本脚本
|
||||
|
||||
> [!WARNING]
|
||||
>
|
||||
> ❌ 本脚本不支持 OpenVZ、LXC 虚拟机
|
||||
>
|
||||
> 请改用 <https://github.com/LloydAsp/OsMutation>
|
||||
@ -66,13 +87,13 @@
|
||||
国外服务器:
|
||||
|
||||
```bash
|
||||
curl -O https://raw.githubusercontent.com/bin456789/reinstall/main/reinstall.sh || wget -O reinstall.sh $_
|
||||
curl -O https://raw.githubusercontent.com/bin456789/reinstall/main/reinstall.sh || wget -O ${_##*/} $_
|
||||
```
|
||||
|
||||
国内服务器:
|
||||
|
||||
```bash
|
||||
curl -O https://gitlab.com/bin456789/reinstall/-/raw/main/reinstall.sh || wget -O reinstall.sh $_
|
||||
curl -O https://cnb.cool/bin456789/reinstall/-/git/raw/main/reinstall.sh || wget -O ${_##*/} $_
|
||||
```
|
||||
|
||||
## 下载(当前系统是 <img width="20" height="20" src="https://blogs.windows.com/wp-content/uploads/prod/2022/09/cropped-Windows11IconTransparent512-32x32.png" /> Windows)
|
||||
@ -105,7 +126,7 @@ certutil -urlcache -f -split https://raw.githubusercontent.com/bin456789/reinsta
|
||||
国内服务器:
|
||||
|
||||
```batch
|
||||
certutil -urlcache -f -split https://gitlab.com/bin456789/reinstall/-/raw/main/reinstall.bat
|
||||
certutil -urlcache -f -split https://cnb.cool/bin456789/reinstall/-/git/raw/main/reinstall.bat
|
||||
```
|
||||
|
||||
## 使用
|
||||
@ -114,11 +135,17 @@ certutil -urlcache -f -split https://gitlab.com/bin456789/reinstall/-/raw/main/r
|
||||
|
||||
- Linux 下运行 `bash reinstall.sh ...`
|
||||
- Windows 下先运行 `cmd`,再运行 `reinstall.bat ...`
|
||||
- 如果参数中的链接包含特殊字符,要用 `""` 将链接包起来,不能用 `''`
|
||||
- 如果参数中的链接包含特殊字符,要用 `""` 将链接包裹起来,不能用 `''`
|
||||
|
||||
### 功能 1: 安装 <img width="16" height="16" src="https://www.kernel.org/theme/images/logos/favicon.png" /> Linux
|
||||
|
||||
- 用户名 `root` 默认密码 `123@@@`
|
||||
> [!CAUTION]
|
||||
>
|
||||
> 此功能会清除当前系统**整个硬盘**的全部数据(包含其它分区)!
|
||||
>
|
||||
> 数据无价,请三思而后行!
|
||||
|
||||
- 用户名为 `root`,脚本会提示输入密码,不输入则使用随机密码
|
||||
- 安装最新版可不输入版本号
|
||||
- 最大化利用磁盘空间:不含 boot 分区(Fedora 例外),不含 swap 分区
|
||||
- 自动根据机器类型选择不同的优化内核,例如 `Cloud`、`HWE` 内核
|
||||
@ -127,38 +154,43 @@ certutil -urlcache -f -split https://gitlab.com/bin456789/reinstall/-/raw/main/r
|
||||
|
||||
```bash
|
||||
bash reinstall.sh anolis 7|8|23
|
||||
rocky 8|9|10
|
||||
oracle 8|9|10
|
||||
almalinux 8|9|10
|
||||
opencloudos 8|9|23
|
||||
rocky 8|9
|
||||
redhat 8|9 --img="http://xxx.com/xxx.qcow2"
|
||||
oracle 8|9
|
||||
almalinux 8|9
|
||||
centos 9|10
|
||||
fedora 40|41
|
||||
nixos 24.11
|
||||
debian 9|10|11|12
|
||||
opensuse 15.6|tumbleweed
|
||||
alpine 3.18|3.19|3.20|3.21
|
||||
openeuler 20.03|22.03|24.03|24.09
|
||||
ubuntu 16.04|18.04|20.04|22.04|24.04|24.10 [--minimal]
|
||||
fnos 1
|
||||
nixos 25.11
|
||||
fedora 42|43
|
||||
debian 9|10|11|12|13
|
||||
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"
|
||||
```
|
||||
|
||||
#### 可选参数
|
||||
|
||||
- `--password PASSWORD` 设置密码
|
||||
- `--ssh-port PORT` 修改 SSH 端口(安装期间观察日志用,也用于新系统)
|
||||
- `--ssh-key KEY` 设置 SSH 登录公钥,[格式如下](#--ssh-key)。当使用公钥时,密码为空
|
||||
- `--ssh-port PORT` 修改 SSH 端口(安装期间观察日志用,也作用于新系统)
|
||||
- `--web-port PORT` 修改 Web 端口(安装期间观察日志用)
|
||||
- `--hold 2` 安装结束后不重启,此时可以 SSH 登录修改系统内容,系统挂载在 `/os` (此功能不支持 Debian/Kali)
|
||||
- `--frpc-toml 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>
|
||||
|
||||
@ -192,9 +224,15 @@ bash reinstall.sh ubuntu --installer
|
||||
|
||||
</details>
|
||||
|
||||
### 功能 2: DD
|
||||
### 功能 2: DD RAW 镜像到硬盘
|
||||
|
||||
- 支持 `raw` `vhd` 格式的镜像(未压缩,或者压缩成 `.gz` `.xz` `.zst` `.tar` `.tar.gz` `.tar.xz` `.tar.zst`)
|
||||
> [!CAUTION]
|
||||
>
|
||||
> 此功能会清除当前系统**整个硬盘**的全部数据(包含其它分区)!
|
||||
>
|
||||
> 数据无价,请三思而后行!
|
||||
|
||||
- 支持 `raw` 和固定大小的 `vhd` 镜像。未压缩或者压缩成 `.gz` `.xz` `.zst` `.tar` `.tar.gz` `.tar.xz` `.tar.zst`
|
||||
- DD Windows 镜像时,会自动扩展系统盘,静态 IP 的机器会配置好 IP,可能首次开机几分钟后才生效
|
||||
- DD Linux 镜像时,**不会**修改镜像的任何内容
|
||||
|
||||
@ -204,35 +242,53 @@ bash reinstall.sh dd --img "https://example.com/xxx.xz"
|
||||
|
||||
#### 可选参数
|
||||
|
||||
- `--allow-ping` 允许被 Ping (仅限 DD Windows)
|
||||
- `--allow-ping` 设置 Windows 防火墙允许被 Ping (仅限 DD Windows)
|
||||
- `--rdp-port PORT` 修改 RDP 端口 (仅限 DD Windows)
|
||||
- `--ssh-port PORT` 修改 SSH 端口(安装期间观察日志用)
|
||||
- `--web-port PORT` 修改 Web 端口(安装期间观察日志用)
|
||||
- `--hold 2` DD 结束后不重启,此时可以 SSH 登录修改系统内容,Windows 系统会挂载在 `/os`,Linux 系统**不会**自动挂载
|
||||
- `--frpc-toml PATH` 添加 frpc 内网穿透(仅限 DD Windows),参数填本地路径或 HTTP 链接
|
||||
- `--hold 1` 仅重启到安装环境,不运行安装,用于 SSH 登录验证网络连通性
|
||||
- `--hold 2` DD 结束后不重启,用于 SSH 登录修改系统内容,Windows 系统会挂载在 `/os`,Linux 系统**不会**自动挂载
|
||||
|
||||
> [!TIP]
|
||||
> 可通过多种方式(SSH、HTTP 80 端口、后台 VNC、串行控制台)查看安装进度。
|
||||
> <br />即使安装过程出错,也能通过 SSH 运行 `/trans.sh alpine` 安装到 Alpine。
|
||||
>
|
||||
> 可通过多种方式(SSH、HTTP 80 端口、商家后台 VNC、串行控制台)查看安装进度。
|
||||
>
|
||||
> 即使安装过程出错,也能连接 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/Arch/Gentoo 等操作
|
||||
- 用户名 `root` 默认密码 `123@@@`
|
||||
- 如果手动操作没有破坏原系统,再次重启将回到原系统
|
||||
- 可用 ssh 连接,进行备份/恢复硬盘、手动 DD、修改分区、手动安装 Alpine 等操作
|
||||
- 用户名为 `root`,脚本会提示输入密码,不输入则使用随机密码
|
||||
|
||||
> [!TIP]
|
||||
>
|
||||
> 虽然运行的脚本叫 `reinstall`,但是此功能**不会**删除任何数据和进行自动重装,而是要用户手动操作
|
||||
>
|
||||
> 如果用户手动操作没有破坏原系统,再次重启将回到原系统
|
||||
|
||||
```bash
|
||||
bash reinstall.sh alpine --hold=1
|
||||
bash reinstall.sh alpine --hold 1
|
||||
```
|
||||
|
||||
#### 可选参数
|
||||
|
||||
- `--password PASSWORD` 设置密码
|
||||
- `--ssh-port PORT` 修改 SSH 端口
|
||||
- `--ssh-key KEY` 设置 SSH 登录公钥,[格式如下](#--ssh-key)。当使用公钥时,密码为空
|
||||
- `--frpc-toml PATH` 添加 frpc 内网穿透,参数填本地路径或 HTTP 链接
|
||||
|
||||
### 功能 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)
|
||||
- 如果手动操作没有破坏原系统,再次重启将回到原系统
|
||||
|
||||
> [!TIP]
|
||||
>
|
||||
> 虽然运行的脚本叫 `reinstall`,但是此功能**不会**删除任何数据和进行自动重装,而是要用户手动操作
|
||||
>
|
||||
> 如果用户手动操作没有破坏原系统,再次重启将回到原系统
|
||||
|
||||
```bash
|
||||
bash reinstall.sh netboot.xyz
|
||||
@ -244,10 +300,17 @@ bash reinstall.sh netboot.xyz
|
||||
|
||||

|
||||
|
||||
- 用户名 `administrator` 默认密码 `123@@@`
|
||||
> [!CAUTION]
|
||||
>
|
||||
> 此功能会清除当前系统**整个硬盘**的全部数据(包含其它分区)!
|
||||
>
|
||||
> 数据无价,请三思而后行!
|
||||
|
||||
- 用户名为 `administrator`,脚本会提示输入密码,不输入则使用随机密码
|
||||
- 如果远程登录失败,可以尝试使用用户名 `.\administrator`
|
||||
- 静态机器会自动配置好 IP,可能首次开机几分钟后才生效
|
||||
- 支持所有语言
|
||||
- 支持任意语言的 ISO
|
||||
- 支持绕过 Windows 11 硬件限制
|
||||
|
||||
#### 支持的系统
|
||||
|
||||
@ -256,12 +319,9 @@ bash reinstall.sh netboot.xyz
|
||||
- Windows Server Essentials \*
|
||||
- Windows Server (Semi) Annual Channel \*
|
||||
- Hyper-V Server \*
|
||||
- Azure Stack HCI \*
|
||||
- Azure Local (Azure Stack HCI) \*
|
||||
|
||||
#### ~~方法 1: 让脚本自动查找 ISO~~
|
||||
|
||||
> [!CAUTION]
|
||||
> 目前该 ISO 仓库禁止了直链下载,因此该方法已失效
|
||||
#### 方法 1: 让脚本自动查找 ISO
|
||||
|
||||
- 脚本会从 <https://massgrave.dev/genuine-installation-media> 查找 ISO,该网站专门提供官方 ISO 下载
|
||||
- 上面带 \* 的系统不支持自动查找 ISO
|
||||
@ -325,7 +385,7 @@ zh-tw
|
||||
|
||||
```bash
|
||||
bash reinstall.sh windows \
|
||||
--image-name "Windows 11 Enterprise LTSC 2024" \
|
||||
--image-name "Windows 11 Enterprise LTSC 2024 Evaluation" \
|
||||
--iso "https://go.microsoft.com/fwlink/?linkid=2289029"
|
||||
```
|
||||
|
||||
@ -350,7 +410,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>
|
||||
@ -369,25 +428,53 @@ bash reinstall.sh windows \
|
||||
- `--password PASSWORD` 设置密码
|
||||
- `--allow-ping` 设置 Windows 防火墙允许被 Ping
|
||||
- `--rdp-port PORT` 更改 RDP 端口
|
||||
- `--ssh-port PORT` 修改 SSH 端口(安装期间观察日志用)
|
||||
- `--web-port PORT` 修改 Web 端口(安装期间观察日志用)
|
||||
- `--ssh-port PORT` 修改 SSH 端口(仅安装期间观察日志用)
|
||||
- `--web-port PORT` 修改 Web 端口(仅安装期间观察日志用)
|
||||
- `--add-driver INF_OR_DIR` 添加额外驱动,填写 .inf 路径,或者 .inf 所在的文件夹
|
||||
- 需先下载驱动到本地
|
||||
- 需先下载驱动到当前系统
|
||||
- 可多次设置该参数以添加不同的驱动
|
||||
- `--hold 2` 在进入 Windows 官方安装程序之前,可以 SSH 登录修改硬盘内容,硬盘挂载在 `/os`
|
||||
- `--frpc-toml PATH` 添加 frpc 内网穿透,参数填本地路径或 HTTP 链接
|
||||
- `--hold 1` 仅重启到安装环境,不运行安装,用于 SSH 登录验证网络连通性
|
||||
- `--hold 2` 用于在进入 Windows 官方安装程序之前,SSH 登录修改 `boot.wim`、`install.wim` 或者其它内容,硬盘挂载在 `/os`
|
||||
|
||||
#### 以下驱动会自动按需下载安装,无需手动添加
|
||||
|
||||
- Virtio ([Virtio](https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/)、[阿里云](https://www.alibabacloud.com/help/ecs/user-guide/update-red-hat-virtio-drivers-of-windows-instances))
|
||||
- XEN ([XEN](https://xenproject.org/resources/downloads/)、[Citrix](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Upgrading_PV_drivers.html#win2008-citrix-upgrade)、[AWS](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/xen-drivers-overview.html))
|
||||
- AWS ([ENA 网卡](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ena-driver-releases-windows.html)、[NVME 存储控制器](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/nvme-driver-version-history.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))
|
||||
- Intel ([VMD 存储控制器](https://www.intel.com/content/www/us/en/download/720755/intel-rapid-storage-technology-driver-installation-software-with-intel-optane-memory-11th-up-to-13th-gen-platforms.html))
|
||||
- VirtIO ([社区版][virtio-virtio], [阿里云][virtio-aliyun], [腾讯云][virtio-qcloud], [GCP][virtio-gcp])
|
||||
- XEN ([~~社区版~~][xen-xen] (未签名), [Citrix][xen-citrix], [AWS][xen-aws])
|
||||
- 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])
|
||||
|
||||
[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
|
||||
[virtio-qcloud]: https://cloud.tencent.com/document/product/213/17815#b84b2032-752c-43c4-a509-73530b8f82ff
|
||||
[virtio-gcp]: https://console.cloud.google.com/storage/browser/gce-windows-drivers-public
|
||||
[xen-xen]: https://xenproject.org/resources/downloads/
|
||||
[xen-aws]: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/xen-drivers-overview.html
|
||||
[xen-citrix]: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Upgrading_PV_drivers.html#win2008-citrix-upgrade
|
||||
[aws-ena]: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ena-driver-releases-windows.html
|
||||
[aws-nvme]: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/nvme-driver-version-history.html
|
||||
[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-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
|
||||
[intel-nic-2019]: https://www.intel.com/content/www/us/en/download/19372/intel-network-adapter-driver-for-windows-server-2019.html
|
||||
[intel-nic-2022]: https://www.intel.com/content/www/us/en/download/706171/intel-network-adapter-driver-for-windows-server-2022.html
|
||||
[intel-nic-2025]: https://www.intel.com/content/www/us/en/download/838943/intel-network-adapter-driver-for-windows-server-2025.html
|
||||
|
||||
#### 如何填写映像名称 `--image-name`
|
||||
|
||||
通常一个 ISO 会包含多个系统版本,例如家庭版、专业版。映像名称 `--image-name` 就是用来指定要安装的版本,填写时不区分大小写
|
||||
一个 ISO 通常包含多个系统版本,例如家庭版、专业版。因此需要用 `--image-name` 指定要安装的系统版本(映像名称),不区分大小写
|
||||
|
||||
可以用 DISM、DISM++、Wimlib 等工具查询 ISO 包含的映像名称
|
||||
|
||||
@ -410,18 +497,32 @@ 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 24H2
|
||||
大部分 ARM 机器都支持安装最新版 Windows 11
|
||||
|
||||
安装过程可能会黑屏,串行控制台可能会显示 `ConvertPages: failed to find range`,均不影响正常安装
|
||||
|
||||
@ -448,10 +549,33 @@ Windows Server 2025 SERVERDATACENTER
|
||||
|
||||
</details>
|
||||
|
||||
## 讨论
|
||||
## 参数格式
|
||||
|
||||
[](https://github.com/bin456789/reinstall/issues)
|
||||
[](https://t.me/reinstall_os)
|
||||
### --ssh-key
|
||||
|
||||
- `--ssh-key "ssh-rsa ..."`
|
||||
- `--ssh-key "ssh-ed25519 ..."`
|
||||
- `--ssh-key "ecdsa-sha2-nistp256/384/521 ..."`
|
||||
- `--ssh-key http://path/to/public_key`
|
||||
- `--ssh-key github:your_username`
|
||||
- `--ssh-key gitlab:your_username`
|
||||
- `--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 ...
|
||||
```
|
||||
|
||||
## 如何修改脚本自用
|
||||
|
||||
@ -461,8 +585,6 @@ Windows Server 2025 SERVERDATACENTER
|
||||
|
||||
## 感谢
|
||||
|
||||
[](https://github.com/sponsors/bin456789)
|
||||
|
||||
感谢以下商家提供白嫖机器
|
||||
|
||||
[](https://www.oracle.com/cloud/)
|
||||
|
||||
168
debian.cfg
168
debian.cfg
@ -2,14 +2,14 @@
|
||||
# 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
|
||||
# https://preseed.debian.net/debian-preseed/trixie/amd64-main-full.txt
|
||||
# 需要留意 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,9 +25,10 @@ d-i mirror/country string manual
|
||||
|
||||
# B.4.5. 帐号设置
|
||||
d-i passwd/make-user boolean false
|
||||
# 单纯为了跳过设置,实际上是在 partman/early_command 里设置密码,preseed/early_command 无法设置密码
|
||||
d-i passwd/root-password password ''
|
||||
d-i passwd/root-password-again password ''
|
||||
# 注意如果用 ssh key 后面还要删除密码
|
||||
# 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
|
||||
|
||||
@ -62,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
|
||||
@ -72,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 \
|
||||
@ -95,29 +100,130 @@ d-i pkgsel/upgrade select none
|
||||
|
||||
# B.4.11. 安装 bootloader
|
||||
# 添加 bootx64.efi
|
||||
d-i grub2/force_efi_extra_removable boolean true
|
||||
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 [ -s /configs/frpc.toml ]; 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.toml /usr/local/etc/frpc/; \
|
||||
run_as_service_with_screen /usr/local/bin/frpc -c /usr/local/etc/frpc/frpc.toml; \
|
||||
fi; \
|
||||
|
||||
if [ -d /cdrom/simple-cdd ]; then \
|
||||
anna-install simple-cdd-profiles; \
|
||||
fi
|
||||
|
||||
# debian 11 initrd 没有 xargs awk
|
||||
# debian 12 initrd 没有 xargs
|
||||
@ -131,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; \
|
||||
@ -151,18 +258,22 @@ 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
|
||||
|
||||
# kali ssh 默认关闭
|
||||
# 另一种方法处理 cloudcone
|
||||
# if [ "$link_grub_dir" = 1 ]; then mkdir /target/boot/grub2; echo 'chainloader (hd0)+1' >/target/boot/grub2/grub.cfg; fi; \
|
||||
# debian 9 tar 不支持 --strip-components
|
||||
d-i preseed/late_command string true; \
|
||||
for str in $(grep -wo "extra_[^ ]*" /proc/cmdline | sed 's/^extra_//'); do eval "$str"; done; \
|
||||
|
||||
@ -172,14 +283,29 @@ 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; \
|
||||
if [ -s /configs/ssh_keys ]; then \
|
||||
(umask 077; mkdir -p /target/root/.ssh; cat /configs/ssh_keys >/target/root/.ssh/authorized_keys); \
|
||||
in-target passwd -d root; \
|
||||
else \
|
||||
echo "PermitRootLogin yes" >/target/etc/ssh/sshd_config.d/01-permitrootlogin.conf || \
|
||||
echo "PermitRootLogin yes" >>/target/etc/ssh/sshd_config; \
|
||||
fi; \
|
||||
|
||||
if [ -n "$ssh_port" ] && ! [ "$ssh_port" = 22 ]; then \
|
||||
echo "Port $ssh_port" >/target/etc/ssh/sshd_config.d/01-change-ssh-port.conf || \
|
||||
echo "Port $ssh_port" >>/target/etc/ssh/sshd_config; \
|
||||
fi; \
|
||||
|
||||
if [ -s /configs/frpc.toml ]; then \
|
||||
mkdir -p /target/usr/local/bin; \
|
||||
mkdir -p /target/usr/local/etc/frpc; \
|
||||
cp /usr/local/bin/frpc /target/usr/local/bin/; \
|
||||
cp /usr/local/etc/frpc/frpc.toml /target/usr/local/etc/frpc/; \
|
||||
chmod a+x /target/usr/local/bin/frpc; \
|
||||
cp /frpc.service /target/etc/systemd/system/; \
|
||||
in-target systemctl enable frpc; \
|
||||
fi; \
|
||||
|
||||
cp /fix-eth-name.sh /target/; \
|
||||
cp /fix-eth-name.service /target/etc/systemd/system/; \
|
||||
in-target systemctl enable fix-eth-name
|
||||
|
||||
@ -22,6 +22,7 @@ ExecStart=/usr/bin/env bash /fix-eth-name.sh
|
||||
ExecStart=/usr/bin/env rm -f /fix-eth-name.sh
|
||||
ExecStart=/usr/bin/env rm -f /etc/systemd/system/fix-eth-name.service
|
||||
ExecStart=/usr/bin/env rm -f /etc/systemd/system/multi-user.target.wants/fix-eth-name.service
|
||||
ExecStart=/usr/bin/env rm -f /lib/systemd/system-preset/01-fix-eth-name.preset
|
||||
ExecStart=/usr/bin/env rm -f /usr/lib/systemd/system-preset/01-fix-eth-name.preset
|
||||
|
||||
[Install]
|
||||
|
||||
@ -7,6 +7,13 @@ set -eE
|
||||
|
||||
# openeuler 需等待 udev 将网卡名从 eth0 改为 enp3s0
|
||||
sleep 10
|
||||
# 不知道有没有用
|
||||
if command -v udevadm >/dev/null; then
|
||||
# udevadm trigger
|
||||
udevadm settle
|
||||
elif command -v mdev >/dev/null; then
|
||||
mdev -sf
|
||||
fi
|
||||
|
||||
# 本脚本在首次进入新系统后运行
|
||||
# 将 trans 阶段生成的网络配置中的网卡名(eth0) 改为正确的网卡名,也适用于以下情况
|
||||
@ -41,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
|
||||
@ -131,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
|
||||
}
|
||||
|
||||
|
||||
24
frpc-example.toml
Normal file
24
frpc-example.toml
Normal file
@ -0,0 +1,24 @@
|
||||
serverAddr = "11.22.33.44"
|
||||
serverPort = 7000
|
||||
auth.token = "123456"
|
||||
|
||||
[[proxies]]
|
||||
name = "ssh"
|
||||
type = "tcp"
|
||||
localIP = "127.0.0.1"
|
||||
localPort = 22
|
||||
remotePort = 2222
|
||||
|
||||
[[proxies]]
|
||||
name = "rdp_tcp"
|
||||
type = "tcp"
|
||||
localIP = "127.0.0.1"
|
||||
localPort = 3389
|
||||
remotePort = 33890
|
||||
|
||||
[[proxies]]
|
||||
name = "rdp_udp"
|
||||
type = "udp"
|
||||
localIP = "127.0.0.1"
|
||||
localPort = 3389
|
||||
remotePort = 33890
|
||||
17
frpc.service
Normal file
17
frpc.service
Normal file
@ -0,0 +1,17 @@
|
||||
# https://github.com/archlinuxcn/repo/blob/master/archlinuxcn/frp/frpc.service
|
||||
|
||||
[Unit]
|
||||
Description=Frp Client Service
|
||||
After=network-online.target
|
||||
Wants=network-online.target
|
||||
|
||||
[Service]
|
||||
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
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
97
get-frpc-url.sh
Normal file
97
get-frpc-url.sh
Normal file
@ -0,0 +1,97 @@
|
||||
#!/bin/ash
|
||||
# shellcheck shell=dash
|
||||
# trans.sh/debian.cfg 共用此脚本
|
||||
|
||||
# debian 9 不支持 set -E
|
||||
set -e
|
||||
|
||||
is_in_china() {
|
||||
grep -q 1 /dev/netconf/*/is_in_china
|
||||
}
|
||||
|
||||
is_ipv6_only() {
|
||||
! grep -q 1 /dev/netconf/*/ipv4_has_internet
|
||||
}
|
||||
|
||||
get_frpc_url() {
|
||||
# 传入 windows 或者 linux
|
||||
local os_type=$1
|
||||
local nt_ver=$2
|
||||
|
||||
is_need_old_version() {
|
||||
[ "$nt_ver" = "6.0" ] || [ "$nt_ver" = "6.1" ]
|
||||
}
|
||||
|
||||
version=$(
|
||||
if is_need_old_version; then
|
||||
echo 0.54.0
|
||||
else
|
||||
# debian 11 initrd 没有 xargs awk
|
||||
# debian 12 initrd 没有 xargs
|
||||
# github 不支持 ipv6
|
||||
if is_in_china || is_ipv6_only; then
|
||||
wget -O- https://mirrors.nju.edu.cn/github-release/fatedier/frp/LatestRelease/frp_sha256_checksums.txt |
|
||||
grep -m1 frp_ | cut -d_ -f2
|
||||
else
|
||||
# https://api.github.com/repos/fatedier/frp/releases/latest 有请求次数限制
|
||||
|
||||
# root@localhost:~# wget --spider -S https://github.com/fatedier/frp/releases/latest 2>&1 | grep Location:
|
||||
# Location: https://github.com/fatedier/frp/releases/tag/v0.62.0
|
||||
# Location: https://github.com/fatedier/frp/releases/tag/v0.62.0 [following] # 原版 wget 多了这行
|
||||
|
||||
wget --spider -S https://github.com/fatedier/frp/releases/latest 2>&1 |
|
||||
grep -m1 '^ Location:' | sed 's,.*/tag/v,,'
|
||||
fi
|
||||
fi
|
||||
)
|
||||
|
||||
if [ -z "$version" ]; then
|
||||
echo 'cannot find version'
|
||||
return 1
|
||||
fi
|
||||
|
||||
suffix=$(
|
||||
case "$os_type" in
|
||||
linux) echo tar.gz ;;
|
||||
windows) echo zip ;;
|
||||
esac
|
||||
)
|
||||
|
||||
mirror=$(
|
||||
# nju 没有 win7 用的旧版
|
||||
# github 不支持 ipv6
|
||||
# daocloud 加速不支持 ipv6
|
||||
# jsdelivr 不支持 github releases 文件
|
||||
if is_ipv6_only; then
|
||||
if is_need_old_version; then
|
||||
echo 'NOT_SUPPORT'
|
||||
return 1
|
||||
else
|
||||
echo https://mirrors.nju.edu.cn/github-release/fatedier/frp
|
||||
fi
|
||||
else
|
||||
if is_in_china; then
|
||||
if is_need_old_version; then
|
||||
echo https://files.m.daocloud.io/github.com/fatedier/frp/releases/download
|
||||
else
|
||||
echo https://mirrors.nju.edu.cn/github-release/fatedier/frp
|
||||
fi
|
||||
else
|
||||
echo https://github.com/fatedier/frp/releases/download
|
||||
fi
|
||||
fi
|
||||
)
|
||||
|
||||
arch=$(
|
||||
case "$(uname -m)" in
|
||||
x86_64) echo amd64 ;;
|
||||
aarch64) echo arm64 ;;
|
||||
esac
|
||||
)
|
||||
|
||||
filename=frp_${version}_${os_type}_${arch}.$suffix
|
||||
|
||||
echo "${mirror}/v${version}/${filename}"
|
||||
}
|
||||
|
||||
get_frpc_url "$@"
|
||||
@ -1,6 +1,6 @@
|
||||
#!/bin/ash
|
||||
# shellcheck shell=dash
|
||||
# alpine / debian initrd 共用此脚本
|
||||
# alpine/debian initrd 共用此脚本
|
||||
|
||||
# accept_ra 接收 RA + 自动配置网关
|
||||
# autoconf 自动配置地址,依赖 accept_ra
|
||||
@ -42,9 +42,9 @@ get_ethx() {
|
||||
# 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000\ link/ether 60:45:bd:21:8a:51 brd ff:ff:ff:ff:ff:ff
|
||||
# 3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP800> mtu 1500 qdisc mq master eth0 state UP qlen 1000\ link/ether 60:45:bd:21:8a:51 brd ff:ff:ff
|
||||
if false; then
|
||||
ip -o link | grep -i "$mac_addr" | grep -v master | awk '{print $2}' | cut -d: -f1
|
||||
ip -o link | grep -i "$mac_addr" | grep -v master | awk '{print $2}' | cut -d: -f1 | grep .
|
||||
else
|
||||
ip -o link | grep -i "$mac_addr" | grep -v master | cut -d' ' -f2 | cut -d: -f1
|
||||
ip -o link | grep -i "$mac_addr" | grep -v master | cut -d' ' -f2 | cut -d: -f1 | grep .
|
||||
fi
|
||||
}
|
||||
|
||||
@ -240,11 +240,17 @@ test_connect() {
|
||||
test_internet() {
|
||||
for i in $(seq 5); do
|
||||
echo "Testing Internet Connection. Test $i... "
|
||||
if is_need_test_ipv4 && test_connect "$(get_first_ipv4_addr | remove_netmask)" "$ipv4_dns1" >/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 && test_connect "$(get_first_ipv6_addr | remove_netmask)" "$ipv6_dns1" >/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
|
||||
@ -258,8 +264,11 @@ test_internet() {
|
||||
flush_ipv4_config() {
|
||||
ip -4 addr flush scope global dev "$ethx"
|
||||
ip -4 route flush dev "$ethx"
|
||||
# DHCP 获取的 IP 不是重装前的 IP 时,一并删除 DHCP 获取的 DNS,以防 DNS 无效
|
||||
sed -i "/\./d" /etc/resolv.conf
|
||||
}
|
||||
|
||||
should_disable_dhcpv4=false
|
||||
should_disable_accept_ra=false
|
||||
should_disable_autoconf=false
|
||||
|
||||
@ -272,9 +281,17 @@ flush_ipv6_config() {
|
||||
fi
|
||||
ip -6 addr flush scope global dev "$ethx"
|
||||
ip -6 route flush dev "$ethx"
|
||||
# DHCP 获取的 IP 不是重装前的 IP 时,一并删除 DHCP 获取的 DNS,以防 DNS 无效
|
||||
sed -i "/:/d" /etc/resolv.conf
|
||||
}
|
||||
|
||||
ethx=$(get_ethx)
|
||||
for i in $(seq 20); do
|
||||
if ethx=$(get_ethx); then
|
||||
break
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
|
||||
if [ -z "$ethx" ]; then
|
||||
echo "Not found network card: $mac_addr"
|
||||
exit
|
||||
@ -282,6 +299,9 @@ fi
|
||||
|
||||
echo "Configuring $ethx ($mac_addr)..."
|
||||
|
||||
# 不开启 lo 则 frp 无法连接 127.0.0.1 22
|
||||
ip link set dev lo up
|
||||
|
||||
# 开启 ethx
|
||||
ip link set dev "$ethx" up
|
||||
sleep 1
|
||||
@ -325,8 +345,9 @@ EOF
|
||||
db_progress INFO netcfg/link_detect_progress
|
||||
else
|
||||
# alpine
|
||||
# h3c 移动云电脑使用 udhcpc 会重复提示 sending select,无法获得 ipv6,因此使用 dhcpcd
|
||||
method=dhcpcd
|
||||
# h3c 移动云电脑使用 udhcpc 会重复提示 sending select,无法获得 ipv6
|
||||
# dhcpcd 会配置租约时间,过期会移除 IP,但我们的没有在后台运行 dhcpcd ,因此用 udhcpc
|
||||
method=udhcpc
|
||||
|
||||
case "$method" in
|
||||
udhcpc)
|
||||
@ -355,6 +376,10 @@ else
|
||||
sleep $DNS_FILE_TIMEOUT # 需要等待写入 dns
|
||||
dhcpcd -x "$ethx" # 终止
|
||||
fi
|
||||
# autoconf 和 accept_ra 会被 dhcpcd 自动关闭,因此需要重新打开
|
||||
# 如果没重新打开,重新运行 dhcpcd 命令依然可以正常生成 slaac 地址和路由
|
||||
sysctl -w "net.ipv6.conf.$ethx.autoconf=1"
|
||||
sysctl -w "net.ipv6.conf.$ethx.accept_ra=1"
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
@ -373,12 +398,7 @@ done
|
||||
# 由于还没设置静态ip,所以有条目表示有动态地址
|
||||
is_have_ipv4_addr && dhcpv4=true || dhcpv4=false
|
||||
is_have_ipv6_addr && dhcpv6_or_slaac=true || dhcpv6_or_slaac=false
|
||||
if is_have_ipv6_gateway; then
|
||||
ra_has_gateway=true
|
||||
ipv6_gateway_from_ra=$(get_ipv6_gateway)
|
||||
else
|
||||
ra_has_gateway=false
|
||||
fi
|
||||
is_have_ipv6_gateway && ra_has_gateway=true || ra_has_gateway=false
|
||||
|
||||
# 如果自动获取的 IP 不是重装前的,则改成静态,使用之前的 IP
|
||||
# 只比较 IP,不比较掩码/网关,因为
|
||||
@ -387,13 +407,12 @@ fi
|
||||
if $dhcpv4 && [ -n "$ipv4_addr" ] && [ -n "$ipv4_gateway" ] &&
|
||||
! [ "$(echo "$ipv4_addr" | cut -d/ -f1)" = "$(get_first_ipv4_addr | cut -d/ -f1)" ]; then
|
||||
echo "IPv4 address obtained from DHCP is different from old system."
|
||||
dhcpv4=false
|
||||
should_disable_dhcpv4=true
|
||||
flush_ipv4_config
|
||||
fi
|
||||
if $dhcpv6_or_slaac && [ -n "$ipv6_addr" ] && [ -n "$ipv6_gateway" ] &&
|
||||
! [ "$(echo "$ipv6_addr" | cut -d/ -f1)" = "$(get_first_ipv6_addr | cut -d/ -f1)" ]; then
|
||||
echo "IPv6 address obtained from SLAAC/DHCPv6 is different from old system."
|
||||
dhcpv6_or_slaac=false
|
||||
should_disable_accept_ra=true
|
||||
should_disable_autoconf=true
|
||||
flush_ipv6_config
|
||||
@ -413,18 +432,19 @@ test_internet
|
||||
# IP 不同的情况在前面已经改成静态了
|
||||
if ! $ipv4_has_internet &&
|
||||
$dhcpv4 && [ -n "$ipv4_addr" ] && [ -n "$ipv4_gateway" ] &&
|
||||
! { [ "$ipv4_addr" = "$(get_first_ipv4_addr)" ] || [ "$ipv4_gateway" = "$(get_first_ipv4_gateway)" ]; }; then
|
||||
! { [ "$ipv4_addr" = "$(get_first_ipv4_addr)" ] && [ "$ipv4_gateway" = "$(get_first_ipv4_gateway)" ]; }; then
|
||||
echo "IPv4 netmask/gateway obtained from DHCP is different from old system."
|
||||
dhcpv4=false
|
||||
should_disable_dhcpv4=true
|
||||
flush_ipv4_config
|
||||
add_missing_ipv4_config
|
||||
test_internet
|
||||
fi
|
||||
# 有可能是静态 IPv6 但能从 RA 获取到网关,因此加上 || $ra_has_gateway
|
||||
if ! $ipv6_has_internet &&
|
||||
$dhcpv6_or_slaac && [ -n "$ipv6_addr" ] && [ -n "$ipv6_gateway" ] &&
|
||||
! { [ "$ipv6_addr" = "$(get_first_ipv6_addr)" ] || [ "$ipv6_gateway" = "$(get_first_ipv6_gateway)" ]; }; then
|
||||
{ $dhcpv6_or_slaac || $ra_has_gateway; } &&
|
||||
[ -n "$ipv6_addr" ] && [ -n "$ipv6_gateway" ] &&
|
||||
! { [ "$ipv6_addr" = "$(get_first_ipv6_addr)" ] && [ "$ipv6_gateway" = "$(get_first_ipv6_gateway)" ]; }; then
|
||||
echo "IPv6 netmask/gateway obtained from SLAAC/DHCPv6 is different from old system."
|
||||
dhcpv6_or_slaac=false
|
||||
should_disable_accept_ra=true
|
||||
should_disable_autoconf=true
|
||||
flush_ipv6_config
|
||||
@ -432,31 +452,41 @@ if ! $ipv6_has_internet &&
|
||||
test_internet
|
||||
fi
|
||||
|
||||
# 如果是静态地址(包括动态无法上网而改成静态的),但是 RA 有网关且和正确的网关不同,要关闭 RA,避免自动设置网关
|
||||
# TODO: 测试 RA 给的网关和静态设置的网关的优先级
|
||||
if $ipv6_has_internet && ! $dhcpv6_or_slaac && $ra_has_gateway &&
|
||||
! [ "$(get_first_ipv6_gateway)" = "$ipv6_gateway_from_ra" ]; then
|
||||
echo "Ignore IPv6 gateway from RA."
|
||||
should_disable_accept_ra=true
|
||||
fi
|
||||
|
||||
# 要删除不联网协议的ip,因为
|
||||
# 1 甲骨文云管理面板添加ipv6地址然后取消
|
||||
# 依然会分配ipv6地址,但ipv6没网络
|
||||
# 此时alpine只会用ipv6下载apk,而不用会ipv4下载
|
||||
# 2 有ipv4地址但没有ipv4网关的情况(vultr),aria2会用ipv4下载
|
||||
if $ipv4_has_internet && ! $ipv6_has_internet; then
|
||||
flush_ipv6_config
|
||||
elif ! $ipv4_has_internet && $ipv6_has_internet; then
|
||||
# 2 有ipv4地址但没有ipv4网关的情况(vultr $2.5 ipv6 only),aria2会用ipv4下载
|
||||
|
||||
# 假设 ipv4 ipv6 在不同网卡,ipv4 能上网但 ipv6 不能上网,这时也要删除 ipv6
|
||||
# 不能用 ipv4_has_internet && ! ipv6_has_internet 判断,因为它判断的是同一个网卡
|
||||
if ! $ipv4_has_internet; then
|
||||
if $dhcpv4; then
|
||||
should_disable_dhcpv4=true
|
||||
fi
|
||||
flush_ipv4_config
|
||||
fi
|
||||
if ! $ipv6_has_internet; then
|
||||
# 防止删除 IPv6 后再次通过 SLAAC 获得
|
||||
# 不用判断 || $ra_has_gateway ,因为没有 IPv6 地址但有 IPv6 网关时,不会出现下载问题
|
||||
if $dhcpv6_or_slaac; then
|
||||
should_disable_accept_ra=true
|
||||
should_disable_autoconf=true
|
||||
fi
|
||||
flush_ipv6_config
|
||||
fi
|
||||
|
||||
# 如果联网了,但没获取到默认 DNS,则添加我们的 DNS
|
||||
if $ipv4_has_internet && ! { [ -e /etc/resolv.conf ] && is_have_ipv4_dns; }; then
|
||||
|
||||
# 有一种情况是,多网卡,且能上网的网卡先完成了这个脚本,不能上网的网卡后完成
|
||||
# 无法上网的网卡通过 flush_ipv4_config 删除了不能上网的 IP 和 dns
|
||||
# (原计划是删除无法上网的网卡 dhcp4 获取的 dns,但实际上无法区分)
|
||||
# 因此这里直接添加 dns,不判断是否联网
|
||||
if ! is_have_ipv4_dns; then
|
||||
echo "nameserver $ipv4_dns1" >>/etc/resolv.conf
|
||||
echo "nameserver $ipv4_dns2" >>/etc/resolv.conf
|
||||
fi
|
||||
if $ipv6_has_internet && ! { [ -e /etc/resolv.conf ] && is_have_ipv6_dns; }; then
|
||||
if ! is_have_ipv6_dns; then
|
||||
echo "nameserver $ipv6_dns1" >>/etc/resolv.conf
|
||||
echo "nameserver $ipv6_dns2" >>/etc/resolv.conf
|
||||
fi
|
||||
@ -466,6 +496,7 @@ netconf="/dev/netconf/$ethx"
|
||||
mkdir -p "$netconf"
|
||||
$dhcpv4 && echo 1 >"$netconf/dhcpv4" || echo 0 >"$netconf/dhcpv4"
|
||||
$dhcpv6_or_slaac && echo 1 >"$netconf/dhcpv6_or_slaac" || echo 0 >"$netconf/dhcpv6_or_slaac"
|
||||
$should_disable_dhcpv4 && echo 1 >"$netconf/should_disable_dhcpv4" || echo 0 >"$netconf/should_disable_dhcpv4"
|
||||
$should_disable_accept_ra && echo 1 >"$netconf/should_disable_accept_ra" || echo 0 >"$netconf/should_disable_accept_ra"
|
||||
$should_disable_autoconf && echo 1 >"$netconf/should_disable_autoconf" || echo 0 >"$netconf/should_disable_autoconf"
|
||||
$is_in_china && echo 1 >"$netconf/is_in_china" || echo 0 >"$netconf/is_in_china"
|
||||
|
||||
@ -58,7 +58,7 @@
|
||||
</button>
|
||||
|
||||
<script
|
||||
src="https://lf3-cdn-tos.bytecdntp.com/cdn/expire-1-d/reconnecting-websocket/1.0.0/reconnecting-websocket.min.js"
|
||||
src="https://mirrors.sustech.edu.cn/cdnjs/ajax/libs/reconnecting-websocket/1.0.0/reconnecting-websocket.min.js"
|
||||
type="application/javascript"></script>
|
||||
|
||||
<script>
|
||||
@ -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>
|
||||
|
||||
113
reinstall.bat
113
reinstall.bat
@ -3,7 +3,7 @@ mode con cp select=437 >nul
|
||||
setlocal EnableDelayedExpansion
|
||||
|
||||
set confhome=https://raw.githubusercontent.com/bin456789/reinstall/main
|
||||
set confhome_cn=https://gitlab.com/bin456789/reinstall/-/raw/main
|
||||
set confhome_cn=https://cnb.cool/bin456789/reinstall/-/git/raw/main
|
||||
rem set confhome_cn=https://www.ghproxy.cc/https://raw.githubusercontent.com/bin456789/reinstall/main
|
||||
|
||||
set pkgs=curl,cpio,p7zip,dos2unix,jq,xz,gzip,zstd,openssl,bind-utils,libiconv,binutils
|
||||
@ -30,15 +30,25 @@ if errorlevel 1 (
|
||||
|
||||
rem 有时 %tmp% 带会话 id,且文件夹不存在
|
||||
rem https://learn.microsoft.com/troubleshoot/windows-server/shell-experience/temp-folder-with-logon-session-id-deleted
|
||||
if not exist %tmp% (
|
||||
md %tmp%
|
||||
rem if not exist %tmp% (
|
||||
rem md %tmp%
|
||||
rem )
|
||||
|
||||
rem 下载 geoip
|
||||
if not exist geoip (
|
||||
rem www.cloudflare.com/dash.cloudflare.com 国内访问的是美国服务器,而且部分地区被墙
|
||||
call :download http://www.qualcomm.cn/cdn-cgi/trace %~dp0geoip || goto :download_failed
|
||||
)
|
||||
|
||||
rem 判断是否有 loc=
|
||||
findstr /c:"loc=" geoip >nul
|
||||
if errorlevel 1 (
|
||||
echo Invalid geoip file
|
||||
del geoip
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
rem 检查是否国内
|
||||
if not exist geoip (
|
||||
rem www.cloudflare.com/dash.cloudflare.com 国内访问的是美国服务器,而且部分地区被墙
|
||||
call :download http://www.visa.cn/cdn-cgi/trace %~dp0geoip || goto :download_failed
|
||||
)
|
||||
findstr /c:"loc=CN" geoip >nul
|
||||
if not errorlevel 1 (
|
||||
rem mirrors.tuna.tsinghua.edu.cn 会强制跳转 https
|
||||
@ -60,37 +70,49 @@ if not errorlevel 1 (
|
||||
call :check_cygwin_installed || (
|
||||
rem win10 arm 支持运行 x86 软件
|
||||
rem win11 arm 支持运行 x86 和 x86_64 软件
|
||||
rem wmic os get osarchitecture 显示中文
|
||||
rem wmic ComputerSystem get SystemType 显示英文
|
||||
|
||||
rem SystemType
|
||||
rem windows 11 24h2 没有 wmic
|
||||
rem wmic os get osarchitecture 显示中文,即使设置了 mode con cp select=437
|
||||
rem wmic ComputerSystem get SystemType 显示英文
|
||||
rem for /f "tokens=*" %%a in ('wmic ComputerSystem get SystemType ^| find /i "based"') do (
|
||||
rem set "SystemType=%%a"
|
||||
rem )
|
||||
|
||||
rem 有的系统精简了 powershell
|
||||
where wmic >nul 2>&1
|
||||
if not errorlevel 1 (
|
||||
for /f "tokens=*" %%a in ('wmic ComputerSystem get SystemType ^| find /i "based"') do (
|
||||
set "SystemType=%%a"
|
||||
)
|
||||
) else (
|
||||
for /f "delims=" %%a in ('powershell -NoLogo -NoProfile -NonInteractive -Command "(Get-WmiObject win32_computersystem).SystemType"') do (
|
||||
set "SystemType=%%a"
|
||||
)
|
||||
rem for /f "delims=" %%a in ('powershell -NoLogo -NoProfile -NonInteractive -Command "(Get-WmiObject win32_computersystem).SystemType"') do (
|
||||
rem set "SystemType=%%a"
|
||||
rem )
|
||||
|
||||
rem SystemArch
|
||||
for /f "tokens=3" %%a in ('reg query "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v PROCESSOR_ARCHITECTURE') do (
|
||||
set SystemArch=%%a
|
||||
)
|
||||
|
||||
rem 也可以用 PROCESSOR_ARCHITEW6432 和 PROCESSOR_ARCHITECTURE 判断
|
||||
rem ARM64 win11 PROCESSOR_ARCHITEW6432 PROCESSOR_ARCHITECTURE
|
||||
rem 原生cmd 未定义 ARM64
|
||||
rem 32位cmd ARM64 x86
|
||||
|
||||
rem if defined PROCESSOR_ARCHITEW6432 (
|
||||
rem set "SystemArch=%PROCESSOR_ARCHITEW6432%"
|
||||
rem ) else (
|
||||
rem set "SystemArch=%PROCESSOR_ARCHITECTURE%"
|
||||
rem )
|
||||
|
||||
rem BuildNumber
|
||||
for /f "tokens=3" %%a in ('reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v CurrentBuildNumber') do (
|
||||
set /a BuildNumber=%%a
|
||||
set /a BuildNumber=%%a
|
||||
)
|
||||
|
||||
set CygwinEOL=1
|
||||
|
||||
echo !SystemType! | find "ARM" > nul
|
||||
echo !SystemArch! | find "ARM" > nul
|
||||
if not errorlevel 1 (
|
||||
if !BuildNumber! GEQ 22000 (
|
||||
set CygwinEOL=0
|
||||
)
|
||||
) else (
|
||||
echo !SystemType! | find "x64" > nul
|
||||
echo !SystemArch! | find "AMD64" > nul
|
||||
if not errorlevel 1 (
|
||||
if !BuildNumber! GEQ 9600 (
|
||||
set CygwinEOL=0
|
||||
@ -109,11 +131,26 @@ 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
|
||||
)
|
||||
|
||||
rem 少于 1M 视为无效
|
||||
rem 有的 IP 被官网拉黑,无法下载 exe,下载得到 html
|
||||
for %%A in (setup-!CygwinArch!.exe) do if %%~zA LSS 1048576 (
|
||||
echo Invalid Cgywin installer
|
||||
del setup-!CygwinArch!.exe
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
rem 安装 Cygwin
|
||||
set site=!mirror!!dir!
|
||||
start /wait setup-!CygwinArch!.exe ^
|
||||
@ -126,11 +163,8 @@ call :check_cygwin_installed || (
|
||||
--packages %pkgs%
|
||||
|
||||
rem 检查 Cygwin 是否成功安装
|
||||
if errorlevel 1 (
|
||||
goto :install_cygwin_failed
|
||||
) else (
|
||||
call :check_cygwin_installed || goto :install_cygwin_failed
|
||||
)
|
||||
if errorlevel 1 goto :install_cygwin_failed
|
||||
call :check_cygwin_installed || goto :install_cygwin_failed
|
||||
)
|
||||
|
||||
rem 在c盘根目录下执行 cygpath -ua . 会得到 /cygdrive/c,因此末尾要有 /
|
||||
@ -159,23 +193,28 @@ rem 或者添加 export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/
|
||||
%SystemDrive%\cygwin\bin\bash %thisdir%reinstall.sh %*
|
||||
exit /b
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
:download
|
||||
rem bits 要求有 Content-Length 才能下载
|
||||
rem cloudflare 的 cdn-cgi/trace 没有 Content-Length
|
||||
rem 据说如果网络设为“按流量计费” bits 也无法下载
|
||||
rem https://learn.microsoft.com/en-us/windows/win32/bits/http-requirements-for-bits-downloads
|
||||
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)
|
||||
if not exist "%~2" certutil -urlcache -f -split "%~1" "%~2" >nul
|
||||
if not exist "%~2" certutil -urlcache -split "%~1" "%~2" >nul
|
||||
if not exist "%~2" exit /b 1
|
||||
exit /b
|
||||
|
||||
certutil -urlcache -f -split "%~1" "%~2" >nul
|
||||
if not errorlevel 1 if exist "%~2" exit /b 0
|
||||
|
||||
certutil -urlcache -split "%~1" "%~2" >nul
|
||||
if not errorlevel 1 if exist "%~2" exit /b 0
|
||||
|
||||
rem 下载失败时删除文件,防止下载了一部分导致下次运行时跳过了下载
|
||||
del /q "%~2" 2>nul
|
||||
exit /b 1
|
||||
|
||||
:download_with_curl
|
||||
rem 加 --insecure 防止以下错误
|
||||
|
||||
898
reinstall.sh
898
reinstall.sh
File diff suppressed because it is too large
Load Diff
@ -1,14 +1,42 @@
|
||||
#!/bin/ash
|
||||
# shellcheck shell=dash
|
||||
# shellcheck disable=SC3001,SC3010
|
||||
# shellcheck disable=SC3001,SC3003,SC3010
|
||||
# reinstall.sh / trans.sh 共用此文件
|
||||
|
||||
# grep 无法处理 UTF-16LE 编码的 inf,有以下几种解决方法
|
||||
# 1. 使用 ripgrep (rg) 或者 ugrep,但 cygwin 没有
|
||||
# 2. grep -a a.b.c.d
|
||||
# 3. iconv -f UTF-16 -t UTF-8
|
||||
|
||||
del_inf_comment() {
|
||||
sed 's/;.*//'
|
||||
}
|
||||
|
||||
simply_inf() {
|
||||
del_cr | del_inf_comment | trim | del_empty_lines
|
||||
convert_file_to_utf8 "$1" | del_cr | del_inf_comment | trim | del_empty_lines
|
||||
}
|
||||
|
||||
convert_file_to_utf8() {
|
||||
# ash 用 * 比较字符串有问题
|
||||
# [[ $'\xEF\xBB' = $'\xEF\xBB*' ]] && echo 1
|
||||
|
||||
# UTF-16LE without BOM 要处理吗? windows 支持这种编码的 inf?
|
||||
|
||||
# UTF-16LE with BOM
|
||||
if [ "$(head -c2 "$1")" = $'\xFF\xFE' ]; then
|
||||
# -f UTF-16LE -t UTF-8 会添加 UTF-8 BOM
|
||||
iconv -f UTF-16 -t UTF-8 "$1"
|
||||
|
||||
# UTF-8 with BOM
|
||||
elif [ "$(head -c3 "$1")" = $'\xEF\xBB\xBF' ]; then
|
||||
# busybox sed 不支持
|
||||
# sed '1s/^\xEF\xBB\xBF//' "$1"
|
||||
tail -c +4 "$1"
|
||||
|
||||
# 其它
|
||||
else
|
||||
cat "$1"
|
||||
fi
|
||||
}
|
||||
|
||||
simply_inf_word() {
|
||||
@ -33,7 +61,7 @@ list_files_from_inf() {
|
||||
local mix_x86_x86_64=$3
|
||||
|
||||
# 所有字段不区分大小写
|
||||
inf_txts=$(simply_inf <"$inf" | to_lower)
|
||||
inf_txts=$(simply_inf "$inf" | to_lower)
|
||||
|
||||
is_match_section() {
|
||||
local section=$1
|
||||
@ -79,6 +107,19 @@ list_files_from_inf() {
|
||||
# 0. 检测 inf 是否适合当前架构
|
||||
# 目前没有对比版本号
|
||||
|
||||
##############################################
|
||||
# 注意这种情况, NTamd64.6.0 为空,表示不支持 6.0
|
||||
|
||||
# [Manufacturer]
|
||||
# %V_INTEL% = Intel, NTamd64.6.0, NTamd64.6.1.1
|
||||
|
||||
# [Intel.NTamd64.6.0]
|
||||
# ; Empty section.
|
||||
|
||||
# 如果后期改成不从 Manufacturer 获取支持的架构,而是从[]获取支持的架构,注意这种情况
|
||||
# [Intel.NTamd64.10.0.1..22000]
|
||||
##############################################
|
||||
|
||||
# 例子1
|
||||
# [Manufacturer]
|
||||
# %Amazon% = AWSNVME, NTamd64, NTARM64
|
||||
@ -163,12 +204,12 @@ list_files_from_inf() {
|
||||
# 注意可能有空格和引号
|
||||
|
||||
if $in_section; then
|
||||
local num dir
|
||||
num=$(echo "$line" | awk -F= '{print $1}' | simply_inf_word)
|
||||
dir=$(echo "$line" | awk -F, '{print $4}' | simply_inf_word)
|
||||
# 每行一条记录
|
||||
if [ -n "$SourceDisksNames" ]; then
|
||||
SourceDisksNames="$SourceDisksNames
|
||||
"
|
||||
SourceDisksNames=$SourceDisksNames$'\n'
|
||||
fi
|
||||
SourceDisksNames="$SourceDisksNames$num:$dir"
|
||||
fi
|
||||
@ -198,7 +239,11 @@ list_files_from_inf() {
|
||||
done < <(echo "$inf_txts")
|
||||
}
|
||||
|
||||
find_file_ignore_case() {
|
||||
# windows 安装驱动时,只会安装相同架构的驱动文件到系统,即使 inf 里有列出其它架构的驱动
|
||||
# 因此 DISM 导出驱动时,也就没有包含其它架构的驱动文件
|
||||
|
||||
# 用于尽可能匹配路径大小写
|
||||
get_path_in_correct_case() {
|
||||
# 同时支持参数和管道
|
||||
local path
|
||||
path=$({ if [ -n "$1" ]; then echo "$1"; else cat; fi; })
|
||||
@ -208,42 +253,66 @@ find_file_ignore_case() {
|
||||
# shellcheck disable=SC2046
|
||||
set -- $(echo "$path" | grep -o '[^/]*')
|
||||
(
|
||||
# windows 安装驱动时,只会安装相同架构的驱动文件到系统,即使 inf 里有列出其它架构的驱动
|
||||
# 因此导出驱动时,也就不会包含其它架构的驱动文件
|
||||
# 因此这里只警告,不中断脚本
|
||||
|
||||
local output=
|
||||
if is_absolute_path "$path"; then
|
||||
cd /
|
||||
output=/
|
||||
fi
|
||||
|
||||
stop_find=false
|
||||
|
||||
while [ $# -gt 0 ]; do
|
||||
local part=$1
|
||||
local tmp
|
||||
# shellcheck disable=SC2010
|
||||
if part=$(ls -1 | grep -Fix "$part"); then
|
||||
# 大于 1 表示当前 part 是目录
|
||||
if [ $# -gt 1 ]; then
|
||||
if cd "$part"; then
|
||||
output="$output$part/"
|
||||
else
|
||||
warn "Can't cd $path"
|
||||
return 1
|
||||
if ! $stop_find; then
|
||||
if tmp=$(ls -1 | grep -Fix "$part"); then
|
||||
part=$tmp
|
||||
# 大于 1 表示当前 part 是目录
|
||||
if [ $# -gt 1 ]; then
|
||||
if ! cd "$part" 2>/dev/null; then
|
||||
warn "Can't cd $path"
|
||||
stop_find=true
|
||||
fi
|
||||
fi
|
||||
else
|
||||
# 最后 part
|
||||
output="$output$part"
|
||||
stop_find=true
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ $# -gt 1 ]; then
|
||||
output="$output$part/"
|
||||
else
|
||||
warn "Can't find $path" >&2
|
||||
return 1
|
||||
# 最后 part
|
||||
output="$output$part"
|
||||
fi
|
||||
shift
|
||||
done
|
||||
|
||||
echo "$output"
|
||||
)
|
||||
}
|
||||
|
||||
is_file_or_link() {
|
||||
# -e / -f 坏软连接,返回 false
|
||||
# -L 坏软连接,返回 true
|
||||
[ -f "$1" ] || [ -L "$1" ]
|
||||
}
|
||||
|
||||
find_file_ignore_case() {
|
||||
# 同时支持参数和管道
|
||||
local path
|
||||
path=$({ if [ -n "$1" ]; then echo "$1"; else cat; fi; })
|
||||
|
||||
path=$(get_path_in_correct_case "$path")
|
||||
if is_file_or_link "$path"; then
|
||||
echo "$path"
|
||||
else
|
||||
warn "Can't find $path" >&2
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
parse_inf_and_cp_driever() {
|
||||
local inf=$1
|
||||
local dst=$2
|
||||
@ -276,3 +345,22 @@ parse_inf_and_cp_driever() {
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
get_sys_dir_for_eth() {
|
||||
(
|
||||
cd "$(readlink -f "/sys/class/net/$1")" || error_and_exit "Can't cd to $1"
|
||||
while ! [ "$(pwd)" = / ]; do
|
||||
# DRIVER=virtio-pci
|
||||
# PCI_CLASS=20000 # 2 开头表示网络设备
|
||||
# PCI_ID=1AF4:1041
|
||||
# PCI_SUBSYS_ID=1AF4:1100
|
||||
# PCI_SLOT_NAME=0000:03:00.0
|
||||
if [ -f uevent ] && grep -q 'PCI_CLASS=2' uevent && grep -q 'PCI_ID' uevent; then
|
||||
pwd
|
||||
return
|
||||
fi
|
||||
cd ..
|
||||
done
|
||||
return 1
|
||||
)
|
||||
}
|
||||
|
||||
39
windows-frpc.bat
Normal file
39
windows-frpc.bat
Normal file
@ -0,0 +1,39 @@
|
||||
@echo off
|
||||
mode con cp select=437 >nul
|
||||
|
||||
rem Windows Deferder 会误报,因此要添加白名单
|
||||
powershell -ExecutionPolicy Bypass -Command "Add-MpPreference -ExclusionPath '%SystemDrive%\frpc\frpc.exe'"
|
||||
|
||||
rem 启用日志
|
||||
rem wevtutil set-log Microsoft-Windows-TaskScheduler/Operational /enabled:true
|
||||
|
||||
rem 创建计划任务并立即运行
|
||||
schtasks /Create /TN "frpc" /XML "%SystemDrive%\frpc\frpc.xml"
|
||||
schtasks /Run /TN "frpc"
|
||||
del "%SystemDrive%\frpc\frpc.xml"
|
||||
|
||||
rem win10+ 在用户首次登录后,用 LocalService 用户运行的计划任务才会生效
|
||||
rem 即使手动重启,计划任务也没有运行
|
||||
|
||||
rem 如果 10 秒内有 frpc 进程,则代表计划任务已经生效,不需要首次登录
|
||||
rem 如果 10 秒后也没有 frpc 进程,则需要临时改用 SYSTEM 用户运行计划任务
|
||||
for /L %%i in (1,1,10) do (
|
||||
timeout 1
|
||||
tasklist /FI "IMAGENAME eq frpc.exe" | find /I "frpc.exe" && (
|
||||
goto :end
|
||||
)
|
||||
)
|
||||
|
||||
rem 临时改用 SYSTEM 用户运行计划任务
|
||||
schtasks /Change /TN frpc /RU S-1-5-18
|
||||
schtasks /Run /TN frpc
|
||||
|
||||
rem 用户登录后改回用 LocalService 运行
|
||||
reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce" /f ^
|
||||
/v FrpcRunAsLocalService ^
|
||||
/t REG_SZ ^
|
||||
/d "schtasks /Change /TN frpc /RU S-1-5-19"
|
||||
|
||||
:end
|
||||
rem 删除此脚本
|
||||
del "%~f0"
|
||||
BIN
windows-frpc.xml
Normal file
BIN
windows-frpc.xml
Normal file
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"
|
||||
|
||||
@ -19,7 +19,7 @@ rem echo a | find "a"
|
||||
rem 使用高性能模式
|
||||
rem https://learn.microsoft.com/windows-hardware/manufacture/desktop/capture-and-apply-windows-using-a-single-wim
|
||||
rem win8 pe 没有 powercfg
|
||||
call powercfg /s 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c 2>nul
|
||||
powercfg /s SCHEME_MIN 2>nul
|
||||
|
||||
rem 安装 SCSI 驱动
|
||||
if exist X:\drivers\ (
|
||||
@ -93,6 +93,14 @@ for /f "tokens=3" %%a in (X:\disk.txt) do (
|
||||
)
|
||||
del X:\disk.txt
|
||||
|
||||
rem 这个变量会被 trans.sh 修改
|
||||
set is4kn=0
|
||||
if "%is4kn%"=="1" (
|
||||
set EFISize=260
|
||||
) else (
|
||||
set EFISize=100
|
||||
)
|
||||
|
||||
rem 重新分区/格式化
|
||||
(if "%BootType%"=="efi" (
|
||||
echo select disk %DiskIndex%
|
||||
@ -104,7 +112,7 @@ rem 重新分区/格式化
|
||||
echo select part 3
|
||||
echo delete part override
|
||||
|
||||
echo create part efi size=100
|
||||
echo create part efi size=%EFISize%
|
||||
echo format fs=fat32 quick
|
||||
|
||||
echo create part msr size=16
|
||||
|
||||
21
windows.xml
21
windows.xml
@ -64,24 +64,31 @@
|
||||
<settings pass="specialize">
|
||||
<component name="Microsoft-Windows-Deployment" processorArchitecture="%arch%" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<RunSynchronous>
|
||||
<!-- aws和华为云都要求设置为从不关闭显示器
|
||||
<!-- 大厂都要求设置高性能和从不关闭显示器
|
||||
https://learn.microsoft.com/en-us/azure/virtual-machines/windows/prepare-for-upload-vhd-image#set-windows-configurations-for-azure
|
||||
https://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/migrating-latest-types.html
|
||||
https://support.huaweicloud.com/usermanual-ims/zh-cn_topic_0047501112.html -->
|
||||
https://support.huaweicloud.com/usermanual-ims/zh-cn_topic_0047501112.html
|
||||
powercfg /aliases 能显示 GUID/名称 的对应关系,vista 也能使用名称 -->
|
||||
<RunSynchronousCommand wcm:action="add">
|
||||
<Order>1</Order>
|
||||
<Path>powercfg /setacvalueindex 381b4222-f694-41f0-9685-ff5bb260df2e 7516b95f-f776-4464-8c53-06167f40cc99 3c0bc021-c8a8-4e07-a973-6b14cbcb2b7e 0</Path>
|
||||
<Path>powercfg /setacvalueindex SCHEME_BALANCED SUB_VIDEO VIDEOIDLE 0</Path>
|
||||
</RunSynchronousCommand>
|
||||
<RunSynchronousCommand wcm:action="add">
|
||||
<Order>2</Order>
|
||||
<Path>powercfg /setacvalueindex 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c 7516b95f-f776-4464-8c53-06167f40cc99 3c0bc021-c8a8-4e07-a973-6b14cbcb2b7e 0</Path>
|
||||
<Path>powercfg /setacvalueindex SCHEME_MIN SUB_VIDEO VIDEOIDLE 0</Path>
|
||||
</RunSynchronousCommand>
|
||||
<RunSynchronousCommand wcm:action="add">
|
||||
<Order>3</Order>
|
||||
<Path>powercfg /setacvalueindex a1841308-3541-4fab-bc81-f71556f20b4a 7516b95f-f776-4464-8c53-06167f40cc99 3c0bc021-c8a8-4e07-a973-6b14cbcb2b7e 0</Path>
|
||||
<Path>powercfg /setacvalueindex SCHEME_MAX SUB_VIDEO VIDEOIDLE 0</Path>
|
||||
</RunSynchronousCommand>
|
||||
<!-- 设为高性能 -->
|
||||
<RunSynchronousCommand wcm:action="add">
|
||||
<Order>4</Order>
|
||||
<Path>powercfg /setactive SCHEME_MIN</Path>
|
||||
</RunSynchronousCommand>
|
||||
<!-- 启用 administrator 账户 -->
|
||||
<RunSynchronousCommand wcm:action="add">
|
||||
<Order>4</Order>
|
||||
<Order>5</Order>
|
||||
<!-- vista 没有自带 powershell -->
|
||||
<!-- <Path>powershell "$User = Get-WmiObject Win32_UserAccount | where SID -like *-500; $User.Disabled = $False; $User.Put()"</Path> -->
|
||||
<!-- win7 此时无法用 wmic useraccount -->
|
||||
@ -91,7 +98,7 @@
|
||||
</RunSynchronousCommand>
|
||||
<!-- 禁用保留空间 -->
|
||||
<RunSynchronousCommand wcm:action="add">
|
||||
<Order>5</Order>
|
||||
<Order>6</Order>
|
||||
<Path>reg add HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\ReserveManager /v ShippedWithReserves /t REG_DWORD /d 0 /f</Path>
|
||||
<!-- 此时以下命令无效 -->
|
||||
<!-- <Path>DISM /Online /Set-ReservedStorageState /State:Disabled</Path> -->
|
||||
|
||||
Loading…
Reference in New Issue
Block a user