diff --git a/AUTORUN_README.md b/AUTORUN_README.md new file mode 100644 index 0000000000..b211f461dd --- /dev/null +++ b/AUTORUN_README.md @@ -0,0 +1,24 @@ +Install and autorun for text-generation-webui (Windows) + +This folder contains helper scripts to install the web UI as an autorun service on your Windows user account. + +Files: +- `start_webui_minimized.ps1` — PowerShell script that launches the web UI server using the venv Python; starts minimized. +- `install_autostart.bat` — Creates a shortcut in your Windows Startup folder to run the PowerShell script at login. + +How to install (one-time): +1. Double-click `install_autostart.bat` and allow it to run. This will create a shortcut named `TextGenWebUI.lnk` in your Startup folder. +2. The next time you log into Windows, the web UI will start automatically minimized using the project's venv. + +Start now (manual): +- To start immediately without waiting for login, run the PowerShell script manually (right-click and select "Run with PowerShell") or run: + powershell -NoProfile -ExecutionPolicy Bypass -File "start_webui_minimized.ps1" + +Stop/remove autorun: +- Delete `TextGenWebUI.lnk` from your Startup folder. You can open the Startup folder with: + explorer.exe shell:startup + +Notes & troubleshooting: +- The scripts assume the project is at `D:\AI_ML_Development\text-generation-webui` and the venv exists at `venv` inside the project. If you move the project, edit `start_webui_minimized.ps1`. +- Ensure your PowerShell ExecutionPolicy allows running scripts. `install_autostart.bat` sets `-ExecutionPolicy Bypass` when launching the script. +- Logs: by default the script starts the server without redirecting output. To capture logs, edit `start_webui_minimized.ps1` and use the `-RedirectStandardOutput` / `-RedirectStandardError` options (commented in file). diff --git a/clone_merwel_repos.ps1 b/clone_merwel_repos.ps1 new file mode 100644 index 0000000000..e6baf936bc --- /dev/null +++ b/clone_merwel_repos.ps1 @@ -0,0 +1,40 @@ +# Clone or update all repositories for MerwelLabs into the specified destination +$dest = 'D:\OneDrive_Merwel\OneDrive\Github' +$gh = 'C:\Program Files\GitHub CLI\gh.exe' + +if (!(Test-Path $gh)) { + Write-Error "gh not found at $gh. Ensure GitHub CLI is installed and on PATH." + exit 1 +} + +New-Item -ItemType Directory -Path $dest -Force | Out-Null + +Write-Output "Listing repositories for MerwelLabs..." +$reposJson = & $gh repo list MerwelLabs --limit 1000 --json name,sshUrl,visibility +if (-not $reposJson) { + Write-Output "No repos found or gh returned nothing." + exit 0 +} + +$repos = $reposJson | ConvertFrom-Json + +foreach ($r in $repos) { + $dir = Join-Path $dest $r.name + if (Test-Path $dir) { + Write-Output "Updating $($r.name)..." + try { + git -C $dir pull --rebase + } catch { + Write-Warning "Failed to pull $($r.name): $_" + } + } else { + Write-Output "Cloning $($r.name)..." + try { + git clone $r.sshUrl $dir + } catch { + Write-Warning "Failed to clone $($r.name): $_" + } + } +} + +Write-Output "Done. Repositories are in: $dest" diff --git a/install_autostart.bat b/install_autostart.bat new file mode 100644 index 0000000000..d6b1375636 --- /dev/null +++ b/install_autostart.bat @@ -0,0 +1,8 @@ +@echo off +REM Creates a shortcut in the current user's Startup folder to run the web UI minimized at login. +set SCRIPT_PATH=%~dp0start_webui_minimized.ps1 +necho Creating startup shortcut... +powershell -NoProfile -ExecutionPolicy Bypass -Command "$WshShell = New-Object -ComObject WScript.Shell; $startup = [Environment]::GetFolderPath('Startup'); $sc = $WshShell.CreateShortcut((Join-Path $startup 'TextGenWebUI.lnk')); $sc.TargetPath = 'powershell.exe'; $sc.Arguments = '-NoProfile -ExecutionPolicy Bypass -File "' + '%SCRIPT_PATH%' + '"'; $sc.IconLocation = '%~dp0venv\Scripts\python.exe'; $sc.WindowStyle = 7; $sc.Save()" +echo Shortcut created in your Startup folder. +echo To remove it, delete the file 'TextGenWebUI.lnk' from the Startup folder. +pause \ No newline at end of file diff --git a/start_webui_minimized.ps1 b/start_webui_minimized.ps1 new file mode 100644 index 0000000000..b49defd563 --- /dev/null +++ b/start_webui_minimized.ps1 @@ -0,0 +1,14 @@ +# Start text-generation-webui in the project's venv, minimized. +# Created by automation. To edit, update this file in the project folder. + +$ProjectPath = 'D:\AI_ML_Development\text-generation-webui' +$Python = Join-Path $ProjectPath 'venv\Scripts\python.exe' + +# Launch the server in portable mode with API enabled. +# Use Minimized window style so the console doesn't pop up. +Start-Process -FilePath $Python -ArgumentList 'server.py','--portable','--api' -WorkingDirectory $ProjectPath -WindowStyle Minimized + +# Optional: redirect output to a log file instead of showing console. +# To enable logging, uncomment the following lines and edit the log path. +# $log = Join-Path $ProjectPath 'autorun.log' +# Start-Process -FilePath $Python -ArgumentList 'server.py','--portable','--api' -WorkingDirectory $ProjectPath -WindowStyle Minimized -RedirectStandardOutput $log -RedirectStandardError $log diff --git a/sync_merwel_repos.ps1 b/sync_merwel_repos.ps1 new file mode 100644 index 0000000000..0db440d2f2 --- /dev/null +++ b/sync_merwel_repos.ps1 @@ -0,0 +1,57 @@ +<# +PowerShell script to sync MerwelLabs GitHub repositories into the OneDrive folder. +Writes logs to D:\OneDrive_Merwel\OneDrive\Github\sync_logs and keeps the last 30 logs. +#> + +$dest = 'D:\OneDrive_Merwel\OneDrive\Github' +$gh = 'C:\Program Files\GitHub CLI\gh.exe' +$logDir = Join-Path $dest 'sync_logs' +New-Item -ItemType Directory -Path $logDir -Force | Out-Null + +$timestamp = (Get-Date).ToString('yyyy-MM-dd_HHmmss') +$logFile = Join-Path $logDir "sync_$timestamp.log" + +Start-Transcript -Path $logFile -Force + +Write-Output "=== MerwelLabs repo sync started: $(Get-Date -Format o) ===" + +if (!(Test-Path $gh)) { + Write-Error "gh not found at $gh. Exiting." + Stop-Transcript + exit 1 +} + +Write-Output "Listing repositories for MerwelLabs..." +$reposJson = & $gh repo list MerwelLabs --limit 1000 --json name,sshUrl,visibility +if (-not $reposJson) { + Write-Output "No repos found or gh returned nothing." + Stop-Transcript + exit 0 +} + +$repos = $reposJson | ConvertFrom-Json + +foreach ($r in $repos) { + $dir = Join-Path $dest $r.name + if (Test-Path $dir) { + Write-Output "Updating $($r.name)..." + try { + git -C $dir pull --rebase 2>&1 | ForEach-Object { Write-Output $_ } + } catch { + Write-Warning "Failed to pull $($r.name): $_" + } + } else { + Write-Output "Cloning $($r.name)..." + try { + git clone $r.sshUrl $dir 2>&1 | ForEach-Object { Write-Output $_ } + } catch { + Write-Warning "Failed to clone $($r.name): $_" + } + } +} + +Write-Output "=== MerwelLabs repo sync finished: $(Get-Date -Format o) ===" +Stop-Transcript + +# Rotate logs: keep last 30 log files +Get-ChildItem -Path $logDir -Filter 'sync_*.log' | Sort-Object LastWriteTime -Descending | Select-Object -Skip 30 | Remove-Item -Force -ErrorAction SilentlyContinue