diff --git a/CheckList.md b/CheckList.md new file mode 100644 index 0000000..4059951 --- /dev/null +++ b/CheckList.md @@ -0,0 +1,62 @@ +# DTS Torque Vault — Mini PC Kiosk Commissioning & QA Checklist + +Use this checklist to verify and sign off each Mini PC after running `scripts\install.bat`. + +--- + +## Unit Information + +| Field | Details | +| :----------------------------- | :-------------------------------------------- | +| **Device Hostname / Serial #** | `________________________________________` | +| **Site / Location** | `________________________________________` | +| **Configured Kiosk Username** | `Torque Vault` _(or: `____________________`)_ | +| **Technician Name** | `________________________________________` | +| **Deployment Date** | `____ / ____ / ____` | + +--- + +## 1. Pre-Deployment & Package Verification + +- [ ] Deployment package extracted locally to `C:\Apps\mini-pc-setup\` (via `scripts\setup.bat` or manual archive extraction). +- [ ] All required files present: `scripts\install.bat`, `scripts\update.bat`, `scripts\uninstall.bat`, `templates\startup.html`, `compose.yml`, `.env`, `Readme.md`, and `CheckList.md`. +- [ ] BIOS Hardware Virtualization (`Intel VT-x` / `AMD-V`) verified as **Enabled**. +- [ ] Active LAN / Wi-Fi connection confirmed. + +--- + +## 2. WSL2 & Docker Backend Verification + +_(Sign in as **Administrator** via `Ctrl + Alt + Del` → **Switch user** to run these checks if needed)_ + +- [ ] `Ubuntu-22.04` WSL2 distribution is installed with `systemd=true` in `/etc/wsl.conf`. +- [ ] Docker Engine `28.3.2` and Docker Compose V2 are installed and pinned (`apt-mark hold`). +- [ ] All containers in `/opt/walmart` show status **`Up`** (`wsl -d Ubuntu-22.04 -u root bash -c "docker ps"`). +- [ ] Scheduled Task **`DTS_WSL_Docker_AutoStart`** exists, runs at startup (`AtStartup`), and executes under **`SYSTEM`**. + +--- + +## 3. Kiosk Mode, Auto-Logon & Session Persistence + +- [ ] **Cold Boot / Reboot Test:** Restart the Mini PC and verify it bypasses the Windows login screen and automatically signs into the Kiosk account. +- [ ] **UI Lockdown:** Windows Desktop, Start Menu, and Taskbar are completely hidden; Microsoft Edge launches full-screen on `C:\KioskApp\startup.html` and transitions smoothly into the main application. +- [ ] **Session Persistence Test:** Log into the web application inside Kiosk mode, reboot the Mini PC, and confirm the browser session/cookies in `C:\KioskBrowserData` remain intact (no forced re-login). +- [ ] **Admin Escape Hatch:** Pressing `Ctrl + Alt + Del` → **Switch user** allows signing into the **Administrator** account with a normal Windows Desktop intact. + +--- + +## 4. 24/7 Power, Peripherals & Update Hardening + +- [ ] Active Windows Power Plan is set to **High Performance**. +- [ ] **Turn off the display**, **Put the computer to sleep**, and **Hibernate** are all set to **Never** (`0`). +- [ ] **USB Selective Suspend** is **Disabled** (`0`). +- [ ] Connected peripherals (USB dongle, barcode scanner, touchscreen) respond immediately after sitting idle for 15+ minutes. +- [ ] **Power Loss Recovery Test:** Disconnect AC power (or perform a hard power cycle), reconnect power, and confirm the Mini PC boots directly back into the active Kiosk application without manual intervention. + +--- + +## Final Sign-Off + +- [ ] **PASS — Unit approved for production deployment.** + +**Technician Signature:** `___________________________`     **Date:** `____ / ____ / 2026` diff --git a/Readme.md b/Readme.md index be687ed..8d19a2f 100644 --- a/Readme.md +++ b/Readme.md @@ -1,41 +1,93 @@ -# Setup Project on Mini PC (Windows) +# DTS Torque Vault — Mini PC Kiosk Deployment & Maintenance Guide (24/7) -In the `scripts` folder there are several `.bat` files used to set up the environment on the mini PC. +Automated, idempotent deployment scripts to provision a fresh Windows Mini PC into a dedicated **24/7 Kiosk appliance** running WSL2 (`Ubuntu-22.04`), Docker Engine `28.3.2`, and full-screen Microsoft Edge with persistent session storage. -## Requirements +--- -- Create an `Apps` folder on the `C` drive. -- Clone this repository into the `Apps` directory. Note that should not rename the directory you have just cloned. +## 1. Repository & Deployment Structure -## Steps + mini-pc-setup/ + ├── .gitignore # Prevents committing real .env credentials + ├── .env.template # Environment variable template (copied to .env on setup) + ├── compose.yml # Docker Compose service definitions + ├── Readme.md # Technician deployment & maintenance guide + ├── CheckList.md # Unit commissioning & QA sign-off checklist + ├── templates/ + │ └── startup.html # Kiosk splash/health-check screen before app redirect + └── scripts/ + ├── setup.bat # 1-click Gitea Latest Release bootstrapper for technicians + ├── bootstrap.ps1 # Downloads Latest Release to C:\Apps\mini-pc-setup\ + ├── install.bat # Master all-in-one deployment script + ├── update.bat # Updates containers, configs, and startup.html + └── uninstall.bat # Reverts Kiosk mode and restores normal Windows -1. **Update and rename `.env.template` file to `.env`** +> **Critical Pre-Deployment Notes** +> +> - **Administrator & Internet:** Sign in using a local **Administrator** account with an active Internet connection. +> - **BIOS Virtualization:** Hardware Virtualization (`Intel VT-x` or `AMD-V`) must be enabled in BIOS. +> - **Local Execution:** All files are extracted to `C:\Apps\mini-pc-setup\` so installation survives the mandatory WSL2 reboot without requiring a USB drive to remain plugged in. -2. **Run `setup-wsl.bat`** - - This will install WSL with Ubuntu‑22.04. - - Follow the prompts to create a default UNIX user account inside WSL. +--- -3. **Run `setup-docker.bat`** - - This will install Docker Engine (v2) and Docker Compose V2 inside the Ubuntu WSL you just created. - - It also enables the Docker daemon to start automatically. +## 2. Fresh Mini PC Installation -4. **Run `setup-prj.bat`** - - Login docker to Gitea. - - Create `walmart` folder in WSL. - - Copy `.env` and `compose` files to `walmart` folder. - - Run docker compose file `docker compose up -d`. +### Option A: 1-Click Deployment via Gitea Latest Release _(Recommended)_ -5. **Run `update-prj.bat`** - - This will pull latest image from container registry. - - Restart all containers in compose file - - Remove unused images (old images) +1. Copy **`scripts\setup.bat`** onto the Mini PC (or download it from the Gitea Release Assets). +2. Double-click **`setup.bat`** and click **Yes** on the UAC Administrator prompt. + - If the repository is **Private**, enter your Gitea credentials once when prompted. +3. The bootstrapper downloads the Latest Release into `C:\Apps\mini-pc-setup\`, copies `.env.template` to `.env` (opening Notepad so you can configure site-specific values), and launches `scripts\install.bat`. -## Notes +### Option B: Manual Deployment from `C:\Apps\mini-pc-setup\` -- During these steps, you may be asked to enter your UNIX user password (for `sudo` commands). -- Make sure you reboot your PC after running `setup-wsl.bat` before continuing with the next scripts. -- Verify installation by running: - ```bash - docker --version - docker compose version - ``` +1. Extract the release package to `C:\Apps\mini-pc-setup\`. +2. Double-click **`scripts\install.bat`** (auto-creates `.env` from `.env.template` if missing). + +### Installation Phases (`scripts\install.bat`) + +1. **Pre-Flight Checks:** Verifies `templates\startup.html`, `compose.yml`, `.env`, Microsoft Edge, Internet access, and BIOS Virtualization. +2. **Phase 1 — WSL2 & Ubuntu-22.04 _(First-time setup only)_:** Installs WSL2 + `Ubuntu-22.04`, registers a `RunOnce` resume entry, and reboots. Sign back in as **Administrator** and the installer automatically resumes. +3. **Phase 2 — Docker, Containers & Kiosk Setup:** + - Logs into `gitea.digitoolsolutions.synology.me`, deploys containers to `/opt/walmart`, and registers the `DTS_WSL_Docker_AutoStart` (`SYSTEM`) boot task. + - Prompts for the Kiosk username (default: `Torque Vault`) and optional password _(avoid Batch special characters `&`, `|`, `<`, `>`, `^`, `%`)_. If switching to a new Kiosk username, the previous Kiosk user's normal Windows Desktop is automatically restored. + - Hardens 24/7 operation: activates **High Performance** power plan, disables **Sleep**, **Hibernate**, **Display Timeout**, and **USB Selective Suspend**, and blocks Windows Update auto-reboots while logged on. +4. **Final Reboot:** Type `Y` and press **Enter**. The Mini PC boots directly into the full-screen Kiosk application. + +--- + +## 3. Switching to Administrator for Maintenance + +While the Mini PC is running in full-screen Kiosk mode: + +1. Press **`Ctrl + Alt + Del`**. +2. Click **Switch user**. +3. Select the **Administrator** account in the bottom-left corner and sign in. + +--- + +## 4. Updating the Application (`scripts\update.bat`) + +1. Switch to the **Administrator** account (see [Section 3](#3-switching-to-administrator-for-maintenance)). +2. Update `compose.yml`, `.env`, or `templates\startup.html` in `C:\Apps\mini-pc-setup\` if changed. +3. Double-click **`scripts\update.bat`**. +4. **Verification:** Confirm all 4 steps complete and `docker ps` shows all containers in the `Up` state. Reboot to reload the Kiosk UI. + +--- + +## 5. Uninstalling / Restoring Normal Windows Mode (`scripts\uninstall.bat`) + +1. Switch to the **Administrator** account (see [Section 3](#3-switching-to-administrator-for-maintenance)). +2. Double-click **`scripts\uninstall.bat`**. +3. Answer the cleanup prompts (`Y`/`N`) for deleting the Kiosk user account, removing `C:\KioskApp` & `C:\KioskBrowserData`, and unregistering `Ubuntu-22.04`. +4. Type `Y` to reboot. Windows returns to the standard login screen with Auto-Logon disabled and the power plan reset to **Balanced**. + +--- + +## 6. Quick Troubleshooting + +| Symptom | Resolution | +| :------------------------------------------------ | :-------------------------------------------------------------------------------------------------------------------------- | ------------------------- | +| **`Hardware Virtualization is DISABLED in BIOS`** | Reboot into BIOS/UEFI, enable **Intel VT-x** or **AMD-V**, save, and re-run `scripts\install.bat`. | +| **Kiosk stays on `startup.html` for > 1 minute** | Verify LAN/Wi-Fi connectivity. Switch to Administrator and run `scripts\update.bat` to verify containers in `/opt/walmart`. | +| **Stops at Windows login screen (no Auto-Logon)** | Sign in as Administrator and re-run `scripts\install.bat`. Ensure the Kiosk password does not contain `&`, ` | `, `<`, `>`, `^`, or `%`. | +| **USB Dongle / Scanner disconnects when idle** | Re-run `scripts\install.bat` to ensure **High Performance** is active and **USB Selective Suspend** is **Disabled**. | diff --git a/scripts/bootstrap.ps1 b/scripts/bootstrap.ps1 new file mode 100644 index 0000000..0d40984 --- /dev/null +++ b/scripts/bootstrap.ps1 @@ -0,0 +1,74 @@ +param( + [string]$GiteaUrl = "https://gitea.digitoolsolutions.synology.me", + [string]$Owner = "lamtruong28", + [string]$Repo = "mini-pc-setup", + [object]$ReleaseJson =$null, + [pscredential]$Credential =$null +) + +$ErrorActionPreference = "Stop" +$GiteaUrl = $GiteaUrl.TrimEnd('/')$TargetDir = "C:\Apps\mini-pc-setup" +$TempZip = "$env:TEMP\mini-pc-setup-release.zip" +$TempExtract = "$env:TEMP\mini-pc-release-extract" + +Write-Host "========================================================" -ForegroundColor Cyan +Write-Host " DTS TORQUE VAULT - DOWNLOADING LATEST RELEASE" -ForegroundColor Cyan +Write-Host "========================================================" -ForegroundColor Cyan + +if ($null -eq$ReleaseJson) { + $apiUrl = "$GiteaUrl/api/v1/repos/$Owner/$Repo/releases/latest" + try { + $ReleaseJson = Invoke-RestMethod -Uri$apiUrl -UseBasicParsing + } catch { + Write-Host "[AUTH] Private repository detected. Please sign in to Gitea:" -ForegroundColor Yellow + $Credential = Get-Credential -Message "Enter Gitea Credentials" + $ReleaseJson = Invoke-RestMethod -Uri $apiUrl -Credential$Credential -UseBasicParsing + } +} + +$TagName =$ReleaseJson.tag_name +Write-Host "[INFO] Latest Release Tag: $TagName ($($ReleaseJson.name))" -ForegroundColor Green + +$ZipAsset = $ReleaseJson.assets \vert{} Where-Object {$_.name -like "*.zip" } | Select-Object -First 1 +if ($null -ne$ZipAsset) { + $DownloadUrl =$ZipAsset.browser_download_url + Write-Host "[1/3] Downloading attached release asset: $($ZipAsset.name)..." +} else { + $DownloadUrl =$ReleaseJson.zipball_url + Write-Host "[1/3] Downloading release archive ($TagName)..." +} + +if (-not (Test-Path $TargetDir)) { + New-Item -ItemType Directory -Path $TargetDir -Force | Out-Null +} + +if ($null -ne$Credential) { + Invoke-WebRequest -Uri $DownloadUrl -OutFile $TempZip -Credential$Credential -UseBasicParsing +} else { + Invoke-WebRequest -Uri $DownloadUrl -OutFile$TempZip -UseBasicParsing +} + +Write-Host "[2/3] Extracting files to $TargetDir..." +if (Test-Path $TempExtract) { Remove-Item$TempExtract -Recurse -Force } +Expand-Archive -Path $TempZip -DestinationPath$TempExtract -Force + +$TopDirs = Get-ChildItem -Path$TempExtract -Directory +$TopFiles = Get-ChildItem -Path$TempExtract -File +if ($TopFiles.Count -eq 0 -and$TopDirs.Count -eq 1) { + Copy-Item -Path "$($TopDirs[0].FullName)\*" -Destination $TargetDir -Recurse -Force +} else { + Copy-Item -Path "$TempExtract\*" -Destination $TargetDir -Recurse -Force +} + +Remove-Item $TempZip -Force -ErrorAction SilentlyContinue +Remove-Item $TempExtract -Recurse -Force -ErrorAction SilentlyContinue + +# Auto-create .env from .env.template if .env does not exist yet +if (-not (Test-Path "$TargetDir\.env") -and (Test-Path "$TargetDir\.env.template")) { + Copy-Item "$TargetDir\.env.template" "$TargetDir\.env" + Write-Host "[ACTION REQUIRED] Please configure '.env' in Notepad, save, and close it to continue..." -ForegroundColor Yellow + Start-Process notepad.exe "$TargetDir\.env" -Wait +} + +Write-Host "[3/3] Launching scripts\install.bat..." -ForegroundColor Green +Start-Process -FilePath "$TargetDir\scripts\install.bat" -WorkingDirectory "$TargetDir\scripts" \ No newline at end of file diff --git a/scripts/install.bat b/scripts/install.bat new file mode 100644 index 0000000..4738d57 --- /dev/null +++ b/scripts/install.bat @@ -0,0 +1,327 @@ +@echo off +setlocal EnableDelayedExpansion + +:: ============================================================================ +:: CONFIGURATION (RESOLVE PARENT ROOT DIRECTORY FROM /scripts) +:: ============================================================================ +set "SCRIPT_DIR=%~dp0" +for %%I in ("%SCRIPT_DIR%..") do set "ROOT_DIR=%%~fI\" + +set "WSL_DISTRO=Ubuntu-22.04" +set "PROJECT_DIR=/opt/walmart" +set "REGISTRY_URL=gitea.digitoolsolutions.synology.me" + +set "DEFAULT_KIOSK_USER=Torque Vault" +set "KIOSK_APP_DIR=C:\KioskApp" +set "KIOSK_DATA_DIR=C:\KioskBrowserData" +set "EDGE_EXE=C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe" +if not exist "%EDGE_EXE%" set "EDGE_EXE=C:\Program Files\Microsoft\Edge\Application\msedge.exe" + +:: ============================================================================ +:: 0. AUTO-ELEVATE TO ADMINISTRATOR +:: ============================================================================ +net session >nul 2>&1 +if %errorLevel% neq 0 ( + echo Requesting Administrator privileges... + powershell -NoProfile -Command "Start-Process -FilePath '%~f0' -Verb RunAs" + exit /b +) + +echo ============================================================================ +echo DTS TORQUE VAULT - MASTER MINI-PC DEPLOYMENT (24/7 PRODUCTION EDITION) +echo ============================================================================ +echo. + +:: ============================================================================ +:: PRE-FLIGHT CHECK: REQUIRED FILES, EDGE, INTERNET & BIOS VIRTUALIZATION +:: ============================================================================ +echo [PRE-CHECK] Verifying required files, Edge, Internet and CPU Virtualization... + +if not exist "%EDGE_EXE%" ( + echo [ERROR] Microsoft Edge not found at "%EDGE_EXE%". + pause + exit /b 1 +) + +:: Auto-generate .env from .env.template if missing +if not exist "%ROOT_DIR%.env" ( + if exist "%ROOT_DIR%.env.template" ( + copy /Y "%ROOT_DIR%.env.template" "%ROOT_DIR%.env" >nul + echo [ACTION REQUIRED] Created .env from .env.template. Configure it in Notepad, save, and close... + start /wait notepad.exe "%ROOT_DIR%.env" + ) +) + +for %%F in ("templates\startup.html" "compose.yml" ".env") do ( + if not exist "%ROOT_DIR%%%~F" ( + echo [ERROR] Missing required file: "%ROOT_DIR%%%~F" + pause + exit /b 1 + ) +) + +ping -n 1 8.8.8.8 >nul 2>&1 +if %errorLevel% neq 0 ( + echo [ERROR] No Internet connection detected! Connect LAN/Wi-Fi and run again. + pause + exit /b 1 +) + +powershell -NoProfile -Command "if ((Get-CimInstance Win32_Processor).VirtualizationFirmwareEnabled -eq $false) { exit 1 }" +if %errorLevel% neq 0 ( + echo [ERROR] Hardware Virtualization (VT-x / AMD-V) is DISABLED in BIOS! + echo Please reboot into BIOS, enable Virtualization, and run again. + pause + exit /b 1 +) + +echo - Pre-flight checks passed! +echo. + +:: ============================================================================ +:: PHASE 1: CHECK & INSTALL WSL2 + UBUNTU-22.04 (ENFORCES REQUIRED REBOOT) +:: ============================================================================ +wsl -d %WSL_DISTRO% -u root true >nul 2>&1 +if %errorLevel% neq 0 ( + wsl -l -q 2>nul | findstr /i "%WSL_DISTRO%" >nul + if !errorLevel! neq 0 ( + echo [PHASE 1] WSL2 / %WSL_DISTRO% not found. Installing now... + wsl --install -d %WSL_DISTRO% --no-launch + if !errorLevel! neq 0 ( + echo [ERROR] WSL installation failed. Ensure Virtualization is enabled in BIOS. + pause + exit /b 1 + ) + ) else ( + echo [PHASE 1] %WSL_DISTRO% is staged, but Windows has NOT rebooted yet! + ) + + :: Register RunOnce so this exact script resumes automatically after reboot + reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\RunOnce" /v "DTS_Master_Setup" /t REG_SZ /d "\"%~f0\"" /f >nul + + echo. + echo ============================================================================ + echo [REBOOT REQUIRED] Windows must restart to activate WSL2 kernel. + echo This installer will resume automatically after you log back in as Admin. + echo ============================================================================ + echo. + pause + shutdown /r /t 3 + exit /b +) + +:: ============================================================================ +:: PHASE 2: INITIALIZE UBUNTU USER & ENABLE SYSTEMD IN WSL2 +:: ============================================================================ +echo [1/7] Initializing Ubuntu-22.04 and enabling systemd... +wsl -d %WSL_DISTRO% -u root bash -c "if ! id -u dtsadmin >/dev/null 2>&1; then useradd -m -s /bin/bash -G sudo dtsadmin && echo 'dtsadmin ALL=(ALL) NOPASSWD:ALL' > /etc/sudoers.d/dtsadmin; fi" +wsl -d %WSL_DISTRO% -u root bash -c "printf '[user]\ndefault=dtsadmin\n[boot]\nsystemd=true\n' > /etc/wsl.conf" + +wsl --terminate %WSL_DISTRO% >nul 2>&1 +timeout /t 2 /nobreak >nul + +:: ============================================================================ +:: PHASE 3: INSTALL & PIN DOCKER ENGINE 28.3.2 + COMPOSE V2 (IDEMPOTENT) +:: ============================================================================ +echo [2/7] Installing Docker Engine 28.3.2 + Compose V2 (if not installed)... +wsl -d %WSL_DISTRO% -u root bash -c "if ! command -v docker >/dev/null 2>&1; then \ + apt-get update && apt-get install -y ca-certificates curl gnupg lsb-release && \ + install -m 0755 -d /etc/apt/keyrings && \ + curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor --yes -o /etc/apt/keyrings/docker.gpg && \ + echo \"deb [arch=\$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \$(lsb_release -cs) stable\" > /etc/apt/sources.list.d/docker.list && \ + apt-get update && \ + apt-get install -y docker-ce=5:28.3.2-1~ubuntu.22.04~jammy docker-ce-cli=5:28.3.2-1~ubuntu.22.04~jammy containerd.io docker-compose-plugin && \ + apt-mark hold docker-ce docker-ce-cli containerd.io; \ +fi && systemctl enable docker && systemctl start docker" + +if %errorLevel% neq 0 ( + echo [ERROR] Docker installation or startup failed inside WSL. + pause + exit /b 1 +) +wsl -d %WSL_DISTRO% -u root bash -c "usermod -aG docker dtsadmin" + +:: ============================================================================ +:: PHASE 4: DEPLOY DOCKER CONTAINERS & REGISTER WSL BOOT TASK +:: ============================================================================ +echo [3/7] Deploying Walmart containers to %PROJECT_DIR%... +echo Please log in to Docker registry (%REGISTRY_URL%) if prompted: +wsl -d %WSL_DISTRO% -u root bash -c "docker login %REGISTRY_URL%" +if %errorLevel% neq 0 ( + echo [ERROR] Docker registry login failed. + pause + exit /b 1 +) + +for /f "delims=" %%i in ('wsl -d %WSL_DISTRO% -u root wslpath -a "%ROOT_DIR%"') do set "WSL_ROOT_DIR=%%i" + +wsl -d %WSL_DISTRO% -u root bash -c "mkdir -p %PROJECT_DIR% && cp '%WSL_ROOT_DIR%/compose.yml' %PROJECT_DIR%/ && cp '%WSL_ROOT_DIR%/.env' %PROJECT_DIR%/ && cd %PROJECT_DIR% && docker compose pull && docker compose up -d" +if %errorLevel% neq 0 ( + echo [ERROR] Failed to start Docker containers. + pause + exit /b 1 +) + +echo [4/7] Configuring WSL + Docker to auto-start on Windows Boot... +powershell -NoProfile -ExecutionPolicy Bypass -Command ^ + "$action = New-ScheduledTaskAction -Execute 'wsl.exe' -Argument '-d %WSL_DISTRO% -u root -- service docker start';" ^ + "$trigger = New-ScheduledTaskTrigger -AtStartup;" ^ + "$principal = New-ScheduledTaskPrincipal -UserId 'SYSTEM' -LogonType ServiceAccount -RunLevel Highest;" ^ + "$settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries -ExecutionTimeLimit 0;" ^ + "Register-ScheduledTask -TaskName 'DTS_WSL_Docker_AutoStart' -Action $action -Trigger $trigger -Principal $principal -Settings $settings -Force | Out-Null" + +:: ============================================================================ +:: PHASE 5: INTERACTIVE KIOSK USER CREATION & AUTO-LOGON SETUP +:: ============================================================================ +echo. +echo [5/7] Configuring Kiosk Mode Account... +echo Existing local user accounts: +powershell -NoProfile -Command "Get-LocalUser | Where-Object { $_.Enabled -eq $true } | Select-Object -ExpandProperty Name" +echo. + +set "PREV_KIOSK_USER=" +for /f "tokens=2*" %%A in ('reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v "DefaultUserName" 2^>nul') do set "PREV_KIOSK_USER=%%B" + +set "KIOSK_USER=" +set /p KIOSK_USER="Enter Kiosk username to create/configure [Default: %DEFAULT_KIOSK_USER%]: " +if "%KIOSK_USER%"=="" set "KIOSK_USER=%DEFAULT_KIOSK_USER%" + +if /i "%KIOSK_USER%"=="%USERNAME%" ( + echo [ERROR] Cannot use current Administrator account "%KIOSK_USER%" for Kiosk! + pause + exit /b 1 +) + +set "KIOSK_PASS=" +set /p KIOSK_PASS="Enter password for '%KIOSK_USER%' (leave blank for no password): " + +if not "%PREV_KIOSK_USER%"=="" ( + if /i not "%PREV_KIOSK_USER%"=="%KIOSK_USER%" ( + if /i not "%PREV_KIOSK_USER%"=="%USERNAME%" ( + echo - Restoring normal Desktop shell for previous Kiosk user "%PREV_KIOSK_USER%"... + powershell -NoProfile -ExecutionPolicy Bypass -Command ^ + "$oldUser = '%PREV_KIOSK_USER%';" ^ + "$acc = Get-LocalUser -Name $oldUser -ErrorAction SilentlyContinue;" ^ + "if ($acc) {" ^ + " $sid = $acc.SID.Value;" ^ + " $profReg = \"HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\$sid\";" ^ + " $profilePath = (Get-ItemProperty $profReg -ErrorAction SilentlyContinue).ProfileImagePath;" ^ + " if ($profilePath -and (Test-Path (Join-Path $profilePath 'NTUSER.DAT'))) {" ^ + " $hivePath = Join-Path $profilePath 'NTUSER.DAT';" ^ + " $loaded = $false;" ^ + " if (-not (Test-Path \"Registry::HKEY_USERS\$sid\")) { reg load \"HKU\$sid\" \"$hivePath\" >$null 2>&1; if ($LASTEXITCODE -eq 0) { $loaded = $true; } }" ^ + " if (Test-Path \"Registry::HKEY_USERS\$sid\") {" ^ + " Remove-ItemProperty -Path \"Registry::HKEY_USERS\$sid\Software\Microsoft\Windows\CurrentVersion\Policies\System\" -Name 'Shell' -ErrorAction SilentlyContinue;" ^ + " }" ^ + " if ($loaded) { [gc]::Collect(); Start-Sleep -Milliseconds 300; reg unload \"HKU\$sid\" >$null 2>&1; }" ^ + " }" ^ + "}" + ) + ) +) + +net accounts /minpwlen:0 >nul 2>&1 +powershell -NoProfile -ExecutionPolicy Bypass -Command ^ + "$u = '%KIOSK_USER%'; $p = '%KIOSK_PASS%';" ^ + "$existing = Get-LocalUser -Name $u -ErrorAction SilentlyContinue;" ^ + "if (-not $existing) {" ^ + " if ([string]::IsNullOrEmpty($p)) { New-LocalUser -Name $u -NoPassword -PasswordNeverExpires | Out-Null }" ^ + " else { New-LocalUser -Name $u -Password (ConvertTo-SecureString $p -AsPlainText -Force) -PasswordNeverExpires | Out-Null }" ^ + " Add-LocalGroupMember -Group 'Users' -Member $u -ErrorAction SilentlyContinue;" ^ + "} else {" ^ + " Enable-LocalUser -Name $u | Out-Null;" ^ + " if ([string]::IsNullOrEmpty($p)) { Set-LocalUser -Name $u -Password ([securestring]::new()) -PasswordNeverExpires $true }" ^ + " else { Set-LocalUser -Name $u -Password (ConvertTo-SecureString $p -AsPlainText -Force) -PasswordNeverExpires $true }" ^ + "}" + +if %errorLevel% neq 0 ( + echo [ERROR] Failed to create or update user "%KIOSK_USER%". + pause + exit /b 1 +) + +echo [6/7] Applying Kiosk Shell, Auto-Logon & Persistent Browser Profile... +if not exist "%KIOSK_DATA_DIR%" mkdir "%KIOSK_DATA_DIR%" +if not exist "%KIOSK_APP_DIR%" mkdir "%KIOSK_APP_DIR%" +copy /Y "%ROOT_DIR%templates\startup.html" "%KIOSK_APP_DIR%\startup.html" >nul +icacls "%KIOSK_DATA_DIR%" /grant "%KIOSK_USER%:(OI)(CI)F" /T >nul +icacls "%KIOSK_APP_DIR%" /grant "Users:(OI)(CI)RX" /T >nul + +set "WINLOGON_KEY=HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" +reg add "%WINLOGON_KEY%" /v "AutoAdminLogon" /t REG_SZ /d "1" /f >nul +reg add "%WINLOGON_KEY%" /v "DefaultDomainName" /t REG_SZ /d "%COMPUTERNAME%" /f >nul +reg add "%WINLOGON_KEY%" /v "DefaultUserName" /t REG_SZ /d "%KIOSK_USER%" /f >nul +reg add "%WINLOGON_KEY%" /v "DefaultPassword" /t REG_SZ /d "%KIOSK_PASS%" /f >nul +reg delete "%WINLOGON_KEY%" /v "AutoLogonCount" /f >nul 2>&1 +reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" /v "HideFastUserSwitching" /t REG_DWORD /d 0 /f >nul +reg delete "HKCU\Software\Microsoft\Windows NT\CurrentVersion\Winlogon" /v "Shell" /f >nul 2>&1 + +set "EDGE_POL=HKLM\SOFTWARE\Policies\Microsoft\Edge" +reg add "%EDGE_POL%" /v "InPrivateModeAvailability" /t REG_DWORD /d 1 /f >nul +reg add "%EDGE_POL%" /v "ClearBrowsingDataOnExit" /t REG_DWORD /d 0 /f >nul +reg add "%EDGE_POL%" /v "RestoreOnStartup" /t REG_DWORD /d 4 /f >nul + +powershell -NoProfile -ExecutionPolicy Bypass -Command ^ + "$user = '%KIOSK_USER%';$edge = '%EDGE_EXE%';" ^ + "$sid = (New-Object System.Security.Principal.NTAccount($user)).Translate([System.Security.Principal.SecurityIdentifier]).Value;" ^ + "$profReg = \"HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\$sid\";" ^ + "if (-not (Test-Path $profReg)) {" ^ + " Add-Type -TypeDefinition 'using System; using System.Runtime.InteropServices; using System.Text; public class Prof { [DllImport(\"userenv.dll\", CharSet=CharSet.Unicode, SetLastError=true)] public static extern bool CreateProfile(string pszUserSid, string pszUserName, StringBuilder pszProfilePath, uint cchProfilePath); }';" ^ + " $sb = New-Object System.Text.StringBuilder 260;" ^ + " [Prof]::CreateProfile($sid,$user, $sb,$sb.Capacity) | Out-Null;" ^ + "}" ^ + "$profilePath = (Get-ItemProperty$profReg -ErrorAction SilentlyContinue).ProfileImagePath;" ^ + "if ($profilePath) {" ^ + " $hivePath = Join-Path$profilePath 'NTUSER.DAT';" ^ + " $edgeCmd = '\"' + $edge + '\" --kiosk \"file:///C:/KioskApp/startup.html\" --edge-kiosk-type=fullscreen --user-data-dir=\"C:\KioskBrowserData\" --no-first-run --disable-features=TranslateUI --allow-file-access-from-files';" ^ + " $loaded =$false;" ^ + " if (-not (Test-Path \"Registry::HKEY_USERS\$sid\")) { reg load \"HKU\$sid\" \"$hivePath\" >$null 2>&1; if ($LASTEXITCODE -eq 0) { $loaded =$true; } }" ^ + " if (Test-Path \"Registry::HKEY_USERS\$sid\") {" ^ + " [Microsoft.Win32.Registry]::SetValue(\"HKEY_USERS\$sid\Software\Microsoft\Windows\CurrentVersion\Policies\System\", 'Shell', $edgeCmd, [Microsoft.Win32.RegistryValueKind]::String);" ^ + " $stuckPath = \"Registry::HKEY_USERS\$sid\Software\Microsoft\Windows\CurrentVersion\Explorer\StuckRects3\";" ^ + " if (Test-Path $stuckPath) {" ^ + " $v = (Get-ItemProperty -Path$stuckPath -Name Settings).Settings;" ^ + " $v[8] = 3;" ^ + " Set-ItemProperty -Path $stuckPath -Name Settings -Value$v;" ^ + " }" ^ + " }" ^ + " if ($loaded) { [gc]::Collect(); Start-Sleep -Milliseconds 300; reg unload \"HKU\$sid\" >$null 2>&1; }" ^ + "}" + +schtasks /delete /tn "DTS_Torque_Vault_Kiosk" /f >nul 2>&1 + +:: ============================================================================ +:: PHASE 6: CONFIGURE 24/7 ALWAYS-ON POWER PLAN & BLOCK AUTO-REBOOT UPDATES +:: ============================================================================ +echo [7/7] Configuring 24/7 Always-On Power Plan and blocking Windows Update auto-reboots... +powercfg -setactive 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c >nul 2>&1 +powercfg -h off >nul 2>&1 + +powercfg -change -monitor-timeout-ac 0 >nul +powercfg -change -monitor-timeout-dc 0 >nul +powercfg -change -standby-timeout-ac 0 >nul +powercfg -change -standby-timeout-dc 0 >nul +powercfg -change -hibernate-timeout-ac 0 >nul +powercfg -change -hibernate-timeout-dc 0 >nul +powercfg -change -disk-timeout-ac 0 >nul +powercfg -change -disk-timeout-dc 0 >nul + +powercfg -setacvalueindex SCHEME_CURRENT 2a737441-1930-4402-8d77-b2bebba308a3 48e6b7a6-50f5-4782-a5d4-53bb8f07e226 0 >nul 2>&1 +powercfg -setdcvalueindex SCHEME_CURRENT 2a737441-1930-4402-8d77-b2bebba308a3 48e6b7a6-50f5-4782-a5d4-53bb8f07e226 0 >nul 2>&1 +powercfg -setactive SCHEME_CURRENT >nul 2>&1 + +reg add "HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" /v "NoAutoRebootWithLoggedOnUsers" /t REG_DWORD /d 1 /f >nul +reg add "HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" /v "AUOptions" /t REG_DWORD /d 3 /f >nul + +echo. +echo ============================================================================ +echo ALL-IN-ONE 24/7 KIOSK DEPLOYMENT COMPLETED! +echo - WSL2 + Docker 28.3.2 : Installed & Auto-Starting at Boot +echo - Walmart Containers : Running in %PROJECT_DIR% +echo - Kiosk User : %KIOSK_USER% (Auto-Logon + Persistent Data) +echo - Power & Updates : 24/7 Always-On (No Sleep / No Auto-Reboot) +echo ============================================================================ +echo. +set /p REBOOT_FINAL="Reboot now to enter full Kiosk Production mode? (Y/N): " +if /i "%REBOOT_FINAL%"=="Y" shutdown /r /t 3 +pause \ No newline at end of file diff --git a/scripts/setup-docker.bat b/scripts/setup-docker.bat deleted file mode 100644 index 8d26809..0000000 --- a/scripts/setup-docker.bat +++ /dev/null @@ -1,22 +0,0 @@ -@echo off -echo Adding official Docker repository... -wsl -d Ubuntu-22.04 bash -c "sudo apt-get update && sudo apt-get install -y ca-certificates curl gnupg lsb-release" -wsl -d Ubuntu-22.04 bash -c "sudo install -m 0755 -d /etc/apt/keyrings" -wsl -d Ubuntu-22.04 bash -c "curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg" -wsl -d Ubuntu-22.04 bash -c "echo 'deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable' | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null" - -echo Installing Docker Engine 28.3.2 + Docker Compose V2... -wsl -d Ubuntu-22.04 bash -c "sudo apt-get update && sudo apt-get install -y docker-ce=5:28.3.2-1~ubuntu.22.04~jammy docker-ce-cli=5:28.3.2-1~ubuntu.22.04~jammy containerd.io docker-compose-plugin" - -echo Holding Docker packages to prevent auto-upgrade... -wsl -d Ubuntu-22.04 bash -c "sudo apt-mark hold docker-ce docker-ce-cli containerd.io" - -echo Enabling Docker daemon... -wsl -d Ubuntu-22.04 bash -c "sudo systemctl enable docker && sudo systemctl start docker" - -echo ============================================ -echo Setup complete! Checking versions... -wsl -d Ubuntu-22.04 bash -c "docker --version" -wsl -d Ubuntu-22.04 bash -c "docker compose version" -echo ============================================ -pause diff --git a/scripts/setup-prj.bat b/scripts/setup-prj.bat deleted file mode 100644 index 7edae39..0000000 --- a/scripts/setup-prj.bat +++ /dev/null @@ -1,27 +0,0 @@ -@echo off -REM ============================================ -REM Clone source code and start Docker Compose -REM ============================================ - -echo Login docker -wsl -d Ubuntu-22.04 bash -c "sudo docker login gitea.digitoolsolutions.synology.me" - -echo [1/3] Copying files into WSL... -REM Create ~/walmart folder in WSL -wsl -d Ubuntu-22.04 bash -c "mkdir -p ~/walmart" - -REM Copy docker-compose.yml and .env from Windows to WSL -wsl -d Ubuntu-22.04 bash -c "cp /mnt/c/Apps/mini-pc-setup/compose.yml ~/walmart/" -wsl -d Ubuntu-22.04 bash -c "cp /mnt/c/Apps/mini-pc-setup/.env ~/walmart/" - -echo [2/3] Starting containers... -wsl -d Ubuntu-22.04 bash -c "cd ~/walmart && sudo docker compose up -d" - -echo [3/3] Showing running containers... -wsl -d Ubuntu-22.04 bash -c "sudo docker ps" - -echo ============================================ -echo Project 'walmart' is up and running! -echo ============================================ - -pause diff --git a/scripts/setup-wsl.bat b/scripts/setup-wsl.bat deleted file mode 100644 index f7cb784..0000000 --- a/scripts/setup-wsl.bat +++ /dev/null @@ -1,5 +0,0 @@ -@echo off -echo Installing WSL with Ubuntu-22.04... -wsl --install -d Ubuntu-22.04 -echo Please reboot your computer and create your Ubuntu user before continuing. -pause diff --git a/scripts/setup.bat b/scripts/setup.bat new file mode 100644 index 0000000..d81a449 --- /dev/null +++ b/scripts/setup.bat @@ -0,0 +1,53 @@ +@echo off +setlocal + +:: ============================================================================ +:: CONFIGURATION +:: ============================================================================ +set "GITEA_URL=https://gitea.digitoolsolutions.synology.me" +set "REPO_OWNER=lamtruong28" +set "REPO_NAME=mini-pc-setup" + +:: ============================================================================ +:: AUTO-ELEVATE TO ADMINISTRATOR +:: ============================================================================ +net session >nul 2>&1 +if %errorLevel% neq 0 ( + echo Requesting Administrator privileges... + powershell -NoProfile -Command "Start-Process -FilePath '%~f0' -Verb RunAs" + exit /b +) + +echo ============================================================================ +echo DTS TORQUE VAULT - ONE-CLICK LATEST RELEASE BOOTSTRAPPER +echo ============================================================================ +echo Repository : %GITEA_URL%/%REPO_OWNER%/%REPO_NAME% +echo. + +powershell -NoProfile -ExecutionPolicy Bypass -Command ^ + "$ErrorActionPreference = 'Stop';" ^ + "$base = '%GITEA_URL%'.TrimEnd('/'); $owner = '\%REPO_OWNER\%';$repo = '%REPO_NAME%';" ^ + "$apiUrl = \"$base/api/v1/repos/$owner/$repo/releases/latest\";" ^ + "$cred =$null;" ^ + "try {" ^ + " $rel = Invoke-RestMethod -Uri$apiUrl -UseBasicParsing;" ^ + "} catch {" ^ + " Write-Host '[AUTH] Private repository detected. Please sign in to Gitea:' -ForegroundColor Yellow;" ^ + " $cred = Get-Credential -Message 'Enter Gitea Credentials';" ^ + " $rel = Invoke-RestMethod -Uri $apiUrl -Credential$cred -UseBasicParsing;" ^ + "}" ^ + "$tag =$rel.tag_name;" ^ + "$rawUrl = \"$base/$owner/$repo/raw/tag/$tag/scripts/bootstrap.ps1\";" ^ + "if ($null -ne$cred) {" ^ + " $script = Invoke-RestMethod -Uri $rawUrl -Credential$cred -UseBasicParsing;" ^ + "} else {" ^ + " $script = Invoke-RestMethod -Uri$rawUrl -UseBasicParsing;" ^ + "}" ^ + "& ([scriptblock]::Create($script)) -GiteaUrl$base -Owner $owner -Repo$repo -ReleaseJson $rel -Credential$cred" + +if %errorLevel% neq 0 ( + echo. + echo [ERROR] Bootstrap failed. Verify that at least one Release exists on Gitea. + pause + exit /b 1 +) \ No newline at end of file diff --git a/scripts/uninstall.bat b/scripts/uninstall.bat new file mode 100644 index 0000000..35da7e4 --- /dev/null +++ b/scripts/uninstall.bat @@ -0,0 +1,127 @@ +@echo off +setlocal EnableDelayedExpansion + +:: ============================================================================ +:: 0. AUTO-ELEVATE TO ADMINISTRATOR +:: ============================================================================ +net session >nul 2>&1 +if %errorLevel% neq 0 ( + echo Requesting Administrator privileges... + powershell -NoProfile -Command "Start-Process -FilePath '%~f0' -Verb RunAs" + exit /b +) + +echo ============================================================================ +echo DTS TORQUE VAULT - UNINSTALL KIOSK & RESTORE WINDOWS NORMAL MODE +echo ============================================================================ +echo. + +:: Detect current Auto-Logon user automatically +set "DETECTED_USER=" +for /f "tokens=2*" %%A in ('reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v "DefaultUserName" 2^>nul') do set "DETECTED_USER=%%B" + +if not "%DETECTED_USER%"=="" ( + echo Detected configured Kiosk user: "%DETECTED_USER%" + set /p KIOSK_USER="Enter Kiosk username to restore/remove [Default: %DETECTED_USER%]: " + if "!KIOSK_USER!"=="" set "KIOSK_USER=%DETECTED_USER%" +) else ( + set /p KIOSK_USER="Enter Kiosk username to restore/remove (leave blank to skip user restore): " +) + +echo. +set /p DEL_USER="Do you want to DELETE the local user account '%KIOSK_USER%' completely? (Y/N) [N = Keep user & restore normal Desktop]: " +set /p DEL_DATA="Do you want to DELETE Kiosk app & browser data (C:\KioskApp, C:\KioskBrowserData)? (Y/N): " +set /p DEL_WSL="Do you want to REMOVE Docker containers and Ubuntu-22.04 WSL distro? (Y/N): " +echo. + +:: ============================================================================ +:: 1. DISABLE WINDOWS AUTO-LOGON & CLEAN RUNONCE +:: ============================================================================ +echo [1/5] Disabling Windows Auto-Logon... +set "WINLOGON_KEY=HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" +reg add "%WINLOGON_KEY%" /v "AutoAdminLogon" /t REG_SZ /d "0" /f >nul +reg delete "%WINLOGON_KEY%" /v "DefaultUserName" /f >nul 2>&1 +reg delete "%WINLOGON_KEY%" /v "DefaultPassword" /f >nul 2>&1 +reg delete "%WINLOGON_KEY%" /v "DefaultDomainName" /f >nul 2>&1 +reg delete "%WINLOGON_KEY%" /v "AutoLogonCount" /f >nul 2>&1 +reg delete "HKCU\Software\Microsoft\Windows\CurrentVersion\RunOnce" /v "DTS_Master_Setup" /f >nul 2>&1 + +:: ============================================================================ +:: 2. REMOVE EDGE KIOSK POLICIES +:: ============================================================================ +echo [2/5] Removing Microsoft Edge Kiosk policies... +set "EDGE_POL=HKLM\SOFTWARE\Policies\Microsoft\Edge" +reg delete "%EDGE_POL%" /v "InPrivateModeAvailability" /f >nul 2>&1 +reg delete "%EDGE_POL%" /v "ClearBrowsingDataOnExit" /f >nul 2>&1 +reg delete "%EDGE_POL%" /v "RestoreOnStartup" /f >nul 2>&1 + +:: ============================================================================ +:: 3. REMOVE SCHEDULED TASKS +:: ============================================================================ +echo [3/5] Removing Kiosk and WSL Auto-Start Scheduled Tasks... +schtasks /delete /tn "DTS_WSL_Docker_AutoStart" /f >nul 2>&1 +schtasks /delete /tn "DTS_Torque_Vault_Kiosk" /f >nul 2>&1 + +:: ============================================================================ +:: 4. RESTORE NORMAL DESKTOP SHELL OR DELETE KIOSK USER ACCOUNT +:: ============================================================================ +echo [4/5] Restoring or removing Kiosk user "%KIOSK_USER%"... +if not "%KIOSK_USER%"=="" ( + if /i not "%KIOSK_USER%"=="%USERNAME%" ( + powershell -NoProfile -ExecutionPolicy Bypass -Command ^ + "$user = '%KIOSK_USER%';" ^ + "$delUser = '%DEL_USER%';" ^ + "$acc = Get-LocalUser -Name $user -ErrorAction SilentlyContinue;" ^ + "if ($acc) {" ^ + " $sid = $acc.SID.Value;" ^ + " $profReg = \"HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\$sid\";" ^ + " $profilePath = (Get-ItemProperty $profReg -ErrorAction SilentlyContinue).ProfileImagePath;" ^ + " if ($profilePath -and (Test-Path (Join-Path $profilePath 'NTUSER.DAT'))) {" ^ + " $hivePath = Join-Path $profilePath 'NTUSER.DAT';" ^ + " $loaded = $false;" ^ + " if (-not (Test-Path \"Registry::HKEY_USERS\$sid\")) { reg load \"HKU\$sid\" \"$hivePath\" >$null 2>&1; if ($LASTEXITCODE -eq 0) { $loaded = $true; } }" ^ + " if (Test-Path \"Registry::HKEY_USERS\$sid\") {" ^ + " Remove-ItemProperty -Path \"Registry::HKEY_USERS\$sid\Software\Microsoft\Windows\CurrentVersion\Policies\System\" -Name 'Shell' -ErrorAction SilentlyContinue;" ^ + " }" ^ + " if ($loaded) { [gc]::Collect(); Start-Sleep -Milliseconds 300; reg unload \"HKU\$sid\" >$null 2>&1; }" ^ + " }" ^ + " if ($delUser -ieq 'Y') {" ^ + " Write-Host (' - Deleting user account and profile for ' + $user + '...');" ^ + " Get-CimInstance -ClassName Win32_UserProfile | Where-Object { $_.SID -eq $sid } | Remove-CimInstance -ErrorAction SilentlyContinue;" ^ + " Remove-LocalUser -Name $user -ErrorAction SilentlyContinue;" ^ + " } else {" ^ + " Write-Host (' - Normal Windows Desktop restored for ' + $user + '.');" ^ + " }" ^ + "}" + ) else ( + echo - Skipping current logged-in Administrator account for safety. + ) +) + +:: ============================================================================ +:: 5. CLEAN UP KIOSK FOLDERS, POWER PLAN & OPTIONAL WSL/DOCKER REMOVAL +:: ============================================================================ +echo [5/5] Restoring Power Plan and cleaning up files... +:: Restore Balanced Power Plan +powercfg -setactive 381b4222-f694-41f0-9685-ff5bb260df2e >nul 2>&1 + +if /i "%DEL_DATA%"=="Y" ( + echo - Removing C:\KioskApp and C:\KioskBrowserData... + rd /s /q "C:\KioskApp" >nul 2>&1 + rd /s /q "C:\KioskBrowserData" >nul 2>&1 +) + +if /i "%DEL_WSL%"=="Y" ( + echo - Stopping containers and unregistering Ubuntu-22.04 WSL... + wsl -d Ubuntu-22.04 -u root bash -c "cd /opt/walmart && docker compose down -v" >nul 2>&1 + wsl --unregister Ubuntu-22.04 >nul 2>&1 +) + +echo. +echo ============================================================================ +echo UNINSTALL COMPLETED! MINI PC RESTORED TO NORMAL WINDOWS MODE. +echo ============================================================================ +echo. +set /p REBOOT_NOW="Reboot now to apply changes? (Y/N): " +if /i "%REBOOT_NOW%"=="Y" shutdown /r /t 3 +pause \ No newline at end of file diff --git a/scripts/update-prj.bat b/scripts/update-prj.bat deleted file mode 100644 index 542150e..0000000 --- a/scripts/update-prj.bat +++ /dev/null @@ -1,26 +0,0 @@ -@echo off - -echo ============================================ -echo Updating Walmart containers... -echo ============================================ - -echo [1/4] Update config... -wsl -d Ubuntu-22.04 bash -c "cp /mnt/c/Apps/mini-pc-setup/compose.yml ~/walmart/" -wsl -d Ubuntu-22.04 bash -c "cp /mnt/c/Apps/mini-pc-setup/.env ~/walmart/" - -echo [2/4] Pull latest images... -wsl -d Ubuntu-22.04 bash -c "cd ~/walmart && sudo docker compose pull" - -echo [3/4] Restart containers... -wsl -d Ubuntu-22.04 bash -c "cd ~/walmart && sudo docker compose up -d" - -echo [4/4] Remove unused images... -wsl -d Ubuntu-22.04 bash -c "sudo docker image prune -af" - -pause -echo. -echo ============================================ -echo Walmart update completed! -echo ============================================ - -pause \ No newline at end of file diff --git a/scripts/update.bat b/scripts/update.bat new file mode 100644 index 0000000..2ab264e --- /dev/null +++ b/scripts/update.bat @@ -0,0 +1,63 @@ +@echo off +setlocal EnableDelayedExpansion + +:: 0. AUTO-ELEVATE TO ADMINISTRATOR +net session >nul 2>&1 +if %errorLevel% neq 0 ( + echo Requesting Administrator privileges... + powershell -NoProfile -Command "Start-Process -FilePath '%~f0' -Verb RunAs" + exit /b +) + +set "SCRIPT_DIR=%~dp0" +for %%I in ("%SCRIPT_DIR%..") do set "ROOT_DIR=%%~fI\" + +set "WSL_DISTRO=Ubuntu-22.04" +set "PROJECT_DIR=/opt/walmart" +set "KIOSK_APP_DIR=C:\KioskApp" + +echo ============================================ +echo Updating Walmart containers & Kiosk splash... +echo ============================================ + +for %%F in ("compose.yml" ".env" "templates\startup.html") do ( + if not exist "%ROOT_DIR%%%~F" ( + echo [ERROR] Missing required file: "%ROOT_DIR%%%~F" + pause + exit /b 1 + ) +) + +for /f "delims=" %%i in ('wsl -d %WSL_DISTRO% -u root wslpath -a "%ROOT_DIR%"') do set "WSL_ROOT_DIR=%%i" + +echo [1/4] Updating config files and Kiosk startup template... +if not exist "%KIOSK_APP_DIR%" mkdir "%KIOSK_APP_DIR%" +copy /Y "%ROOT_DIR%templates\startup.html" "%KIOSK_APP_DIR%\startup.html" >nul + +wsl -d %WSL_DISTRO% -u root bash -c "mkdir -p %PROJECT_DIR% && cp '%WSL_ROOT_DIR%/compose.yml' %PROJECT_DIR%/ && cp '%WSL_ROOT_DIR%/.env' %PROJECT_DIR%/" +if %errorLevel% neq 0 ( + echo [ERROR] Failed to copy config files into WSL. Is %WSL_DISTRO% installed? + pause + exit /b 1 +) + +echo [2/4] Pulling latest images... +wsl -d %WSL_DISTRO% -u root bash -c "cd %PROJECT_DIR% && docker compose pull" +if %errorLevel% neq 0 ( + echo [ERROR] Failed to pull Docker images. Check Internet or Docker login session. + pause + exit /b 1 +) + +echo [3/4] Restarting containers... +wsl -d %WSL_DISTRO% -u root bash -c "cd %PROJECT_DIR% && docker compose up -d" + +echo [4/4] Cleaning up unused images... +wsl -d %WSL_DISTRO% -u root bash -c "docker image prune -af" + +echo. +echo ============================================ +echo Walmart update completed! +echo ============================================ +wsl -d %WSL_DISTRO% -u root bash -c "docker ps" +pause \ No newline at end of file diff --git a/templates/startup-screen.html b/templates/startup.html similarity index 82% rename from templates/startup-screen.html rename to templates/startup.html index fb0c91a..41cc4bf 100644 --- a/templates/startup-screen.html +++ b/templates/startup.html @@ -102,17 +102,29 @@