add swarmui to launcher.bat

+added swarmui installer, updater, uninstaller, launcher
This commit is contained in:
deffcolony
2025-09-10 19:45:28 +02:00
parent 36d2bfa49f
commit 3dc5392e32
4 changed files with 227 additions and 20 deletions

View File

@@ -0,0 +1,41 @@
@echo off
:install_swarmui
title STL [INSTALL SWARMUI]
cls
echo %blue_fg_strong%/ Home / Toolbox / App Installer / Image Generation / Install SwarmUI%reset%
echo -------------------------------------------------------------
echo %blue_bg%[%time%]%reset% %blue_fg_strong%[INFO]%reset% Installing SwarmUI...
REM Check if the folder exists
if not exist "%image_generation_dir%" (
mkdir "%image_generation_dir%"
echo %blue_bg%[%time%]%reset% %blue_fg_strong%[INFO]%reset% Created folder: "image-generation"
) else (
echo %blue_bg%[%time%]%reset% %blue_fg_strong%[INFO] "image-generation" folder already exists.%reset%
)
cd /d "%image_generation_dir%"
set max_retries=3
set retry_count=0
:retry_install_swarmui
echo %blue_bg%[%time%]%reset% %blue_fg_strong%[INFO]%reset% Cloning the SwarmUI repository...
git clone https://github.com/mcmonkeyprojects/SwarmUI.git
if %errorlevel% neq 0 (
set /A retry_count+=1
echo %yellow_bg%[%time%]%reset% %yellow_fg_strong%[WARN] Retry %retry_count% of %max_retries%%reset%
if %retry_count% lss %max_retries% goto :retry_install_swarmui
echo %red_bg%[%time%]%reset% %red_fg_strong%[ERROR] Failed to clone repository after %max_retries% retries.%reset%
pause
goto :app_installer_image_generation
)
cd /d "%swarmui_install_path%"
echo %blue_bg%[%time%]%reset% %blue_fg_strong%[INFO]%reset% Installing .NET SDK 8...
winget install -e --id Microsoft.DotNet.SDK.8
echo %blue_bg%[%time%]%reset% %blue_fg_strong%[INFO]%reset% %green_fg_strong%SwarmUI installed Successfully.%reset%
pause
goto :install_swarmui_menu

View File

@@ -0,0 +1,61 @@
@echo off
:start_swarmui
REM Force x64 to be read first
set PATH=C:\Program Files\dotnet;%PATH%
set DOTNET_CLI_TELEMETRY_OPTOUT=1
cd /d "%swarmui_install_path%"
REM Server settings option
if exist .\src\bin\always_pull (
echo %blue_bg%[%time%]%reset% %blue_fg_strong%[INFO] Pulling latest changes...
git pull
)
REM Check if a build is needed
for /f "delims=" %%i in ('git rev-parse HEAD') do set CUR_HEAD=%%i
set /p BUILT_HEAD=<src/bin/last_build
if not "!CUR_HEAD!"=="!BUILT_HEAD!" (
echo %yellow_bg%[%time%]%reset% %yellow_fg_strong%[WARN] No build detected. Building the app now...%reset%
echo. 2>.\src\bin\must_rebuild
)
if exist .\src\bin\must_rebuild (
echo %blue_bg%[%time%]%reset% %blue_fg_strong%[INFO]%reset% Building SwarmUI...
if exist .\src\bin\live_release (
rmdir /s /q .\src\bin\live_release_backup
move .\src\bin\live_release .\src\bin\live_release_backup
)
del .\src\bin\must_rebuild
)
REM Build the app if the executable is missing
if not exist src\bin\live_release\SwarmUI.exe (
REM Add microsoft nuget source just in case it isn't there
echo %blue_bg%[%time%]%reset% %blue_fg_strong%[INFO]%reset% Adding NuGet official package source...
dotnet nuget add source https://api.nuget.org/v3/index.json --name "NuGet official package source"
dotnet build src/SwarmUI.csproj --configuration Release -o src/bin/live_release
for /f "delims=" %%i in ('git rev-parse HEAD') do set CUR_HEAD2=%%i
echo !CUR_HEAD2!> src/bin/last_build
)
REM If the build failed and there is a backup, restore it
if not exist src\bin\live_release\SwarmUI.exe if exist src\bin\live_release_backup\SwarmUI.exe (
echo %yellow_bg%[%time%]%reset% %yellow_fg_strong%[WARN] Build failed, restoring last known good build...%reset%
timeout 5
echo %blue_bg%[%time%]%reset% %blue_fg_strong%[INFO]%reset% Restoring backup...
rmdir /s /q src\bin\live_release
move src\bin\live_release_backup src\bin\live_release
)
REM Default env configuration, gets overwritten by the C# code's settings handler
set ASPNETCORE_ENVIRONMENT="Production"
set ASPNETCORE_URLS="http://*:7801"
echo %blue_bg%[%time%]%reset% %blue_fg_strong%[INFO]%reset% Launching SwarmUI...
.\src\bin\live_release\SwarmUI.exe %*
goto :home

View File

@@ -0,0 +1,30 @@
@echo off
:uninstall_swarmui
title STL [UNINSTALL SWARMUI]
setlocal enabledelayedexpansion
chcp 65001 > nul
REM Confirm with the user before proceeding
echo.
echo %red_bg%╔════ DANGER ZONE ══════════════════════════════════════════════════════════════════════════════╗%reset%
echo %red_bg%║ WARNING: This will delete all data of SwarmUI ║%reset%
echo %red_bg%║ If you want to keep any data, make sure to create a backup before proceeding. ║%reset%
echo %red_bg%╚═══════════════════════════════════════════════════════════════════════════════════════════════╝%reset%
echo.
set /p "confirmation=Are you sure you want to proceed? [Y/N]: "
if /i "%confirmation%"=="Y" (
REM Remove the folder swarmui
echo %blue_bg%[%time%]%reset% %blue_fg_strong%[INFO]%reset% Removing the swarmui directory...
cd /d "%~dp0"
rmdir /s /q "%swarmui_install_path%"
echo %blue_bg%[%time%]%reset% %blue_fg_strong%[INFO]%reset% %green_fg_strong%SwarmUI has been uninstalled successfully.%reset%
pause
goto :app_uninstaller_image_generation
) else (
echo %blue_bg%[%time%]%reset% %blue_fg_strong%[INFO]%reset% Uninstall canceled.
pause
goto :app_uninstaller_image_generation
)