# bin456789/reinstall architecture

> Architecture diagram of the GitHub repository bin456789/reinstall, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-04-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/bin456789/reinstall
- Repository: https://github.com/bin456789/reinstall

## Overview

1. This repository is a script-driven OS reinstallation toolkit, not an application server. The top-level product is a single workflow that can reboot a machine into a temporary installer environment, reimage the disk, and then hand control to the new OS.

2. There are two primary entrypoints: `reinstall.sh` for Linux hosts and `reinstall.bat` for Windows hosts. They expose the same command surface so the same tool can be launched from either current OS.

3. The core control flow is: parse user intent and target OS, fetch the needed install media or boot artifacts, generate temporary network/storage configuration, write or patch the boot/install environment, then reboot into that environment. Most of the repository exists to support one of those stages.

4. The repo supports several provisioning modes, which are architecturally distinct:
   - Linux installation from distro images or cloud images
   - Raw image/DD deployment
   - Booting into Alpine Live OS for manual recovery
   - Booting into netboot.xyz for manual OS selection
   - Windows ISO installation with driver injection and unattended setup

5. Linux provisioning is built around config injection files such as `cloud-init.yaml`, `ubuntu.yaml`, `debian.cfg`, `redhat.cfg`, and helper scripts like `initrd-network.sh`, `cloud-init-fix-onlink.sh`, and `ubuntu-storage-early.sh`. These pieces adapt network and storage behavior so the temporary installer can reach mirrors and lay out disks correctly across many distro families.

6. Windows provisioning is a separate subsystem centered on `windows.xml` plus batch/PowerShell helpers like `windows-setup.bat`, `windows-set-netconf.bat`, `windows-resize.bat`, `windows-driver-utils.sh`, `wmic.ps1`, and the `windows-*.bat` utilities. This side handles ISO selection, image index selection, driver injection, RDP/ping tweaks, network setup, and post-install customization.

7. The repository also includes hardware-compatibility shims such as `fix-eth-name.*`, `resize.sh`, `ttys.sh`, `windows-change-rdp-port.bat`, and related scripts. These are focused on making the installer usable across cloud providers, BIOS/EFI variants, ARM hosts, and machines with unusual NIC naming or disk layouts.

8. Runtime observability is an explicit subsystem. `logviewer-nginx.conf` and `logviewer.html` indicate a small local web UI served during installation, complementing SSH access, serial console, VNC, and optional `frpc` tunneling. In other words, the install process is designed to be monitored and rescued remotely while it is running.

9. External dependencies are mostly fetched on demand rather than bundled. The scripts pull Linux mirrors, Windows ISO links, official driver packages, and cloud-init-style artifacts from upstream sources at runtime. That means the repo is more of an orchestrator than a content host.

10. The `frpc` files (`frpc-example.toml`, `frpc.service`, `windows-frpc.*`, `get-frpc-url.sh`) form an optional reverse-connect path that can expose the temporary installer or installed machine through an external tunnel. This is a separate communications channel from SSH/web logs and is meant for NATed VPS recovery.

11. `cloud-init.yaml`, `windows.xml`, and the various distro/OS-specific config files are the main boundary between generic orchestration and OS-specific provisioning logic. The orchestration scripts decide “which path,” while these assets define “how that OS boots and configures itself.”

12. The `.github/workflows` files are support infrastructure for distribution, not runtime behavior. They automate repository sync/mirroring and reinstall-related checks, which is consistent with a tool that is primarily consumed as a downloadable script rather than installed as a package.

Main entry points: [`initrd-network.sh`](https://github.com/bin456789/reinstall/blob/main/initrd-network.sh) (Boot prep), [`windows.xml`](https://github.com/bin456789/reinstall/blob/main/windows.xml) (Windows config), [`logviewer.html`](https://github.com/bin456789/reinstall/blob/main/logviewer.html) (Remote access), [`windows-setup.bat`](https://github.com/bin456789/reinstall/blob/main/windows-setup.bat) (Setup scripts)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_g1["Entry points"]
  node_n1["Reinstall SH<br/>entrypoint<br/>[reinstall.sh]"]
  node_n2["Reinstall BAT<br/>entrypoint<br/>[reinstall.bat]"]
end

subgraph group_g2["Orchestration"]
  node_n3{{"Main flow<br/>orchestrator"}}
  node_n4["Media fetch<br/>artifact fetcher"]
  node_n5["Boot prep<br/>boot/environment builder<br/>[initrd-network.sh]"]
end

subgraph group_g3["Linux provisioning"]
  node_n6["Linux config<br/>linux provisioning"]
  node_n7["Cloud-init<br/>linux config<br/>[cloud-init.yaml]"]
  node_n8["Distro configs<br/>linux config<br/>[debian.cfg]"]
  node_n9["Ubuntu storage<br/>linux helper"]
  node_n10(("Recovery modes<br/>linux recovery"))
end

subgraph group_g4["Windows provisioning"]
  node_n11["Windows config<br/>windows provisioning<br/>[windows.xml]"]
  node_n12["Setup scripts<br/>windows helpers<br/>[windows-setup.bat]"]
  node_n13["Driver tools"]
end

subgraph group_g5["Access and recovery"]
  node_n14["Remote access<br/>observability<br/>[logviewer.html]"]
  node_n15["Log viewer<br/>web ui"]
  node_n16["FRPC tunnel<br/>reverse tunnel<br/>[frpc-example.toml]"]
end

subgraph group_g6["Compatibility shims"]
  node_n17["NIC fixes<br/>compatibility shim<br/>[fix-eth-name.sh]"]
  node_n18["Resize tools<br/>compatibility shim<br/>[resize.sh]"]
  node_n19["TTY tools<br/>console helper<br/>[ttys.sh]"]
  node_n20["Windows tweaks<br/>windows compatibility"]
end

node_n1 -->|"launches"| node_n3
node_n2 -->|"launches"| node_n3
node_n3 -->|"fetches"| node_n4
node_n3 -->|"prepares"| node_n5
node_n3 -->|"selects"| node_n6
node_n3 -->|"selects"| node_n10
node_n3 -->|"selects"| node_n11
node_n5 -->|"applies"| node_n17
node_n5 -->|"applies"| node_n18
node_n5 -->|"exposes"| node_n19
node_n6 -->|"uses"| node_n7
node_n6 -->|"uses"| node_n8
node_n6 -->|"uses"| node_n9
node_n10 -->|"downloads"| node_n4
node_n11 -->|"driven by"| node_n12
node_n11 -->|"injects"| node_n13
node_n12 -->|"tunes"| node_n20
node_n14 -->|"served by"| node_n15
node_n3 -->|"monitors"| node_n14
node_n3 -->|"optionally tunnels"| node_n16
node_n16 -->|"complements"| node_n14
node_n17 -->|"supports"| node_n3
node_n20 -->|"supports"| node_n11

click node_n1 "https://github.com/bin456789/reinstall/blob/main/reinstall.sh"
click node_n2 "https://github.com/bin456789/reinstall/blob/main/reinstall.bat"
click node_n5 "https://github.com/bin456789/reinstall/blob/main/initrd-network.sh"
click node_n7 "https://github.com/bin456789/reinstall/blob/main/cloud-init.yaml"
click node_n8 "https://github.com/bin456789/reinstall/blob/main/debian.cfg"
click node_n9 "https://github.com/bin456789/reinstall/blob/main/ubuntu-storage-early.sh"
click node_n11 "https://github.com/bin456789/reinstall/blob/main/windows.xml"
click node_n12 "https://github.com/bin456789/reinstall/blob/main/windows-setup.bat"
click node_n13 "https://github.com/bin456789/reinstall/blob/main/windows-driver-utils.sh"
click node_n14 "https://github.com/bin456789/reinstall/blob/main/logviewer.html"
click node_n15 "https://github.com/bin456789/reinstall/blob/main/logviewer-nginx.conf"
click node_n16 "https://github.com/bin456789/reinstall/blob/main/frpc-example.toml"
click node_n17 "https://github.com/bin456789/reinstall/blob/main/fix-eth-name.sh"
click node_n18 "https://github.com/bin456789/reinstall/blob/main/resize.sh"
click node_n19 "https://github.com/bin456789/reinstall/blob/main/ttys.sh"
click node_n20 "https://github.com/bin456789/reinstall/blob/main/windows-change-rdp-port.bat"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_n1,node_n2 toneBlue
class node_n3,node_n4,node_n5 toneAmber
class node_n6,node_n7,node_n8,node_n9,node_n10 toneMint
class node_n11,node_n12,node_n13 toneRose
class node_n14,node_n15,node_n16 toneIndigo
class node_n17,node_n18,node_n19,node_n20 toneTeal
```

## Components

### Entry points

Primary launchers for Linux and Windows hosts.

- [Reinstall SH](https://github.com/bin456789/reinstall/blob/main/reinstall.sh): entrypoint · Linux-host launcher exposing the reinstall command surface. · `reinstall.sh`
- [Reinstall BAT](https://github.com/bin456789/reinstall/blob/main/reinstall.bat): entrypoint · Windows-host launcher exposing the same reinstall command surface. · `reinstall.bat`

### Orchestration

Cross-platform flow that selects mode, fetches media, prepares boot artifacts, and reboots.

- **Main flow**: orchestrator · Coordinates intent parsing, target OS selection, artifact fetch, boot prep, and reboot.
- **Media fetch**: artifact fetcher · Downloads distro images, Windows ISOs, drivers, and other upstream install inputs on demand.
- [Boot prep](https://github.com/bin456789/reinstall/blob/main/initrd-network.sh): boot/environment builder · Writes or patches temporary installer environments before rebooting into them. · `initrd-network.sh`

### Linux provisioning

Linux installer and recovery paths, plus distro-specific config injection.

- **Linux config**: linux provisioning · Linux-side OS-specific boot and storage/network configuration assets.
- [Cloud-init](https://github.com/bin456789/reinstall/blob/main/cloud-init.yaml): linux config · Cloud-init injection and on-link/network fixes for cloud and distro installs. · `cloud-init.yaml`
- [Distro configs](https://github.com/bin456789/reinstall/blob/main/debian.cfg): linux config · Distribution-specific installer settings for Debian, Red Hat, and Ubuntu flows. · `debian.cfg`
- [Ubuntu storage](https://github.com/bin456789/reinstall/blob/main/ubuntu-storage-early.sh): linux helper · Early storage layout adjustments for Ubuntu-style installation flows. · `ubuntu-storage-early.sh`
- **Recovery modes**: linux recovery · Manual recovery and alternative boot paths such as Alpine live and netboot selection.

### Windows provisioning

Windows ISO deployment, setup customization, and driver/network injection.

- [Windows config](https://github.com/bin456789/reinstall/blob/main/windows.xml): windows provisioning · Windows-specific unattended install, network, driver, and post-install configuration. · `windows.xml`
- [Setup scripts](https://github.com/bin456789/reinstall/blob/main/windows-setup.bat): windows helpers · Batch and PowerShell helpers that drive ISO setup, net configuration, and tuning. · `windows-setup.bat`
- [Driver tools](https://github.com/bin456789/reinstall/blob/main/windows-driver-utils.sh): windows driver tools · Driver injection and image-index related helper logic for Windows deployments. · `windows-driver-utils.sh`

### Access and recovery

Operator visibility and remote reachability during install or recovery.

- [Remote access](https://github.com/bin456789/reinstall/blob/main/logviewer.html): observability · Local logs, console access, and remote viewing paths used during installs. · `logviewer.html`
- [Log viewer](https://github.com/bin456789/reinstall/blob/main/logviewer-nginx.conf): web ui · Small local web UI for installer logs, typically served by nginx. · `logviewer-nginx.conf`
- [FRPC tunnel](https://github.com/bin456789/reinstall/blob/main/frpc-example.toml): reverse tunnel · Optional reverse-connect path for NAT traversal and remote rescue. · `frpc-example.toml`

### Compatibility shims

Host-specific fixes for NIC naming, storage layout, console access, and resizing.

- [NIC fixes](https://github.com/bin456789/reinstall/blob/main/fix-eth-name.sh): compatibility shim · Host adaptation for unusual NIC naming, init scripts, and service wiring. · `fix-eth-name.sh`
- [Resize tools](https://github.com/bin456789/reinstall/blob/main/resize.sh): compatibility shim · Disk and partition resize helpers for hosts with atypical layouts. · `resize.sh`
- [TTY tools](https://github.com/bin456789/reinstall/blob/main/ttys.sh): console helper · Console and terminal access helpers for installer visibility. · `ttys.sh`
- [Windows tweaks](https://github.com/bin456789/reinstall/blob/main/windows-change-rdp-port.bat): windows compatibility · Ping, RDP, and network-access adjustments for Windows recovery and post-install use. · `windows-change-rdp-port.bat`

## Connections

- Reinstall SH → Main flow: launches · Linux launcher enters the shared reinstall workflow.
- Reinstall BAT → Main flow: launches · Windows launcher enters the shared reinstall workflow.
- Main flow → Media fetch: fetches · Workflow retrieves install media and upstream artifacts as needed.
- Main flow → Boot prep: prepares · Workflow builds the temporary boot/install environment.
- Main flow → Linux config: selects · Workflow routes Linux targets into distro-specific provisioning.
- Main flow → Recovery modes: selects · Workflow can switch into manual recovery or netboot paths.
- Main flow → Windows config: selects · Workflow routes Windows targets into unattended deployment.
- Boot prep → NIC fixes: applies · Boot preparation incorporates compatibility shims where needed.
- Boot prep → Resize tools: applies · Boot preparation may resize or reshape storage before install.
- Boot prep → TTY tools: exposes · Temporary environment is made accessible over consoles or TTYs.
- Linux config → Cloud-init: uses · Linux provisioning uses cloud-init style injection and fixes.
- Linux config → Distro configs: uses · Linux provisioning branches into distro-specific configs.
- Linux config → Ubuntu storage: uses · Ubuntu flow uses early storage adjustments.
- Recovery modes → Media fetch: downloads · Recovery modes still rely on fetched live images or boot artifacts.
- Windows config → Setup scripts: driven by · Windows config is applied through setup and network helper scripts.
- Windows config → Driver tools: injects · Windows deployment injects drivers and aligns image selection.
- Setup scripts → Windows tweaks: tunes · Setup helpers adjust ping, RDP, and access settings.
- Remote access → Log viewer: served by · Log viewer UI is exposed through the nginx config.
- Main flow → Remote access: monitors · Workflow is designed to be observed and rescued remotely.
- Main flow → FRPC tunnel: optionally tunnels · Workflow can expose the installer through an external reverse tunnel.
- FRPC tunnel → Remote access: complements · Tunnel is a separate access path alongside local log viewing.
- NIC fixes → Main flow: supports · NIC fix shims support the shared workflow across hosts.
- Windows tweaks → Windows config: supports · Windows tweaks support the Windows provisioning subsystem.
