# Image Repository — Tencent Lighthouse Windows Install

Repo ini dipakai `reinstall.sh` di target VPS sebagai sumber ISO + driver.
Tidak perlu download ulang dari internet setiap reinstall.

**Base URL:** `http://rdp.gracexz.my.id`

---

## Peringatan utama

**Tencent Lighthouse DHCP tidak melayani Windows.** `trans.sh` fungsi
`create_win_set_netconf_script()` (line 6465) hanya menulis config IP kalau:

```
is_staticv4 || is_staticv6 || should_add_ipv4_static_dns || should_add_ipv6_static_dns
```

Di VPS DHCP tidak ada yang fire → `windows-set-netconf.bat` kena
`if not defined mac_addr goto :del` → exit tanpa aksi → **Windows boot tanpa IP → box gelap**.

**Solusi wajib:** `--hold 2` + inject `fixnet.bat` manual. Detail di bawah.

---

## ISO

**`iso/WIN10_SUPERLITE_VIRTIO.iso`** — 4545 MB

Ghost Spectre W10 PRO AIO U31, build 19045.6332.
VirtIO driver sudah **permanent** di `install.wim` index 3 + `boot.wim`.

Index edition dalam WIM:

- 1 = WINDOWS 10 PRO - COMPACT
- 2 = COMPACT + DEFENDER
- 3 = **WINDOWS 10 PRO - SUPERLITE**  ← pakai ini
- 4 = SUPERLITE + DEFENDER
- 5 = SUPERLITE SE
- 6 = SUPERLITE SE + DEFENDER

Checksum:
- SHA256: `23ad2fef2d91d812722d016af36c4c8a067c98053a86676a08601d2075a9caa4`
- MD5: `a8f8cbd0c898540392b184a9c00e8a59`

---

## Driver (`drivers/`)

VirtIO driver Tencent Cloud, sumber `mirrors.cloud.tencent.com/install/cts/windows/Drivers.zip`.
130 file, 23 MB.

- `VioStor/Win10_2016_2019/amd64/` — storage (WAJIB, boot-critical)
- `NetKVM/Win10_2016_2019/amd64/` — network
- `qxldod/w10/amd64/` — display

---

## Script

- `scripts/reinstall.sh` — bin456789/reinstall terbaru (UA bypass Tencent sudah ada)
- `scripts/install-windows.sh` — wrapper otomatis: preflight → catat jaringan → generate `fixnet.bat` → install `--hold 2`

---

## Cara install

### Otomatis (rekomendasi)

```bash
curl -fsSL http://rdp.gracexz.my.id/scripts/install-windows.sh -o /root/iw.sh
bash /root/iw.sh
```

Script akan:
1. Preflight (virtio, DMI, disk, RAM)
2. Catat IP/mask/gateway/MAC/DNS → convert ke netmask
3. Cek repo + Range support
4. Konfirmasi `WIPE`
5. Install `--hold 2` (TIDAK boot)
6. Generate `/root/fixnet.bat` + print langkah inject

### Manual

```bash
curl -fsSL http://rdp.gracexz.my.id/scripts/reinstall.sh -o /tmp/r.sh

bash /tmp/r.sh windows \
  --image-name "WINDOWS 10 PRO - SUPERLITE" \
  --iso "http://rdp.gracexz.my.id/iso/WIN10_SUPERLITE_VIRTIO.iso" \
  --lang en-us \
  --username administrator \
  --password 'Masuk123!' \
  --rdp-port 3389 \
  --allow-ping \
  --no-lockout-threshold \
  --hold 2
```

> `--image-name` **tidak perlu** suffix edition terpisah — field `Name:` di WIM Ghost Spectre
> sudah bernilai `WINDOWS 10 PRO - SUPERLITE`, dan `trans.sh` pakai `grep -Fix` exact match.

---

## Setelah install selesai (FASE 5 — JANGAN SKIP)

Installer berhenti di Alpine dengan disk Windows ter-mount di `/os`.

**SSH ke Alpine pakai kredensial Windows**, bukan `root`/`alpine` — `trans.sh:9101` memanggil
`change_user_password /` dengan `$username` (username Windows), jadi user Alpine = `administrator`
dan password = password Windows.

Fixnet harus di **dua** tempat:

**A. `SetupComplete.cmd` (UTAMA)** — jalan otomatis saat OOBE selesai, **sebelum login**, sebagai SYSTEM.

```bash
SETUP_DIR="/os/Windows/Setup/Scripts"
mkdir -p "$SETUP_DIR" "/os/Setup/Scripts"

cat > "$SETUP_DIR/fixnet.bat" <<'BAT'
@echo off
powershell -NoProfile -ExecutionPolicy Bypass -Command "..."
BAT

SC="$SETUP_DIR/SetupComplete.cmd"
[ -f "$SC" ] && cp "$SC" "$SC.orig"
{ echo 'if exist %SystemDrive%\Setup\Scripts\fixnet.bat (call %SystemDrive%\Setup\Scripts\fixnet.bat)';
  [ -f "$SC.orig" ] && cat "$SC.orig"; } > "$SC"
```

**B. `StartUp` (backup)** — jalan saat user login, untuk kasus SetupComplete gagal.

```bash
mkdir -p "/os/ProgramData/Microsoft/Windows/Start Menu/Programs/StartUp"
cp "$SETUP_DIR/fixnet.bat" \
   "/os/ProgramData/Microsoft/Windows/Start Menu/Programs/StartUp/fixnet.bat"
```

> **Kenapa `StartUp` saja tidak cukup:** folder Startup baru dieksekusi setelah ada user login.
> Kalau Windows belum punya IP, tidak ada yang bisa login → fixnet tidak pernah jalan → box gelap.
> `SetupComplete.cmd` jalan sebagai SYSTEM saat OOBE, jadi tidak butuh login.

Isi `fixnet.bat` (pakai **PowerShell**, bukan `netsh` — nama interface bisa `Ethernet 2` berspasi):

```bat
@echo off
powershell -NoProfile -ExecutionPolicy Bypass -Command "$nic=Get-NetAdapter | Where-Object {$_.Status -eq 'Up'} | Select-Object -First 1; Remove-NetIPAddress -InterfaceIndex $nic.ifIndex -Confirm:$false -ErrorAction SilentlyContinue; Remove-NetRoute -InterfaceIndex $nic.ifIndex -Confirm:$false -ErrorAction SilentlyContinue; New-NetIPAddress -InterfaceIndex $nic.ifIndex -IPAddress '<IP>' -PrefixLength <PREFIX> -DefaultGateway '<GW>'; Set-DnsClientServerAddress -InterfaceIndex $nic.ifIndex -ServerAddresses ('<DNS>','8.8.8.8'); Set-NetFirewallProfile -All -Enabled False; Set-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server' -Name fDenyTSConnections -Value 0; Get-NetIPConfiguration | Out-File C:\fixnet-result.txt"
```

Script `install-windows.sh` sudah generate file ini otomatis ke `/root/fixnet.bat` + print
langkah injeksi lengkap.

---

## Verifikasi

```bash
ping -c 3 <IP>          # ttl=125 → Windows, ttl=64 → masih Linux
timeout 4 bash -c 'cat </dev/null >/dev/tcp/<IP>/3389' && echo RDP-OPEN
```

RDP: `<IP>:3389`, user `administrator`, password sesuai `--password`.

---

## Firewall Lighthouse — WAJIB dicek dulu

Lighthouse punya firewall per-instance, **bukan** security group CVM.
Default mengikuti OS image saat instance dibuat:

- Image Ubuntu → `22`, `80`, `ICMP` (3389 **tidak ada**)
- Image Windows → `3389 TCP+UDP`, `80`, `ICMP`

Instance dari Ubuntu → 3389 harus ditambah manual di panel:
Console → Lighthouse → instance → tab **防火墙/Firewall** → Add Rule →
Custom, `0.0.0.0/0`, TCP, `3389`, Allow.

Efek **seketika**, tanpa reboot.

Kalau butuh SMB/WinRM: tambah `135, 139, 445, 5985`.

---

## Catatan driver

`add_driver_qcloud_virtio()` di `trans.sh` (line 7911) inject driver ke
**WinPE/setup phase**, BUKAN permanent ke Windows final.

Gate yang harus lolos:
1. `is_virt_contains virtio` — ada device di `/sys/bus/virtio/devices/`
2. `get_cloud_vendor` = `qcloud` — DMI `Tencent Cloud`

Karena itu ISO di repo ini sudah punya driver **permanent di registry**
(`viostor Start=0` + `CriticalDeviceDatabase` PCI ven_1af4), supaya tidak
bergantung pada driver injection saat install.

Kalau pakai ISO Ghost Spectre asli (tanpa driver), wajib tambah:

```bash
--add-driver "/path/ke/drivers/VioStor/Win10_2016_2019/amd64"
```

> **Catatan:** `--add-driver` di versi ini scan folder dan pasang ke
> `$initrd_dir/custom_drivers` untuk WinPE. Ini **tidak** menjamin driver
> permanent di Windows final. Pakai ISO ber-driver untuk hasil pasti.

---

## Infrastruktur

- Nginx service (`systemctl enable --now nginx`), auto-start saat reboot
- Support **Range request (206)** → aria2 multi-connection
- `sendfile` + `aio threads` + `directio 8m` → streaming 4.5 GB tanpa buffer disk
- Autoindex → bisa browse via browser
- Root: `/srv/images`, config: `/etc/nginx/sites-available/images`
