feat: add autostart scripts and fix port configuration in launchers
Some checks failed
Build Release / create-release (push) Successful in 1s
Build Release / build-windows (push) Successful in 1m16s
Build Release / build-docker (push) Failing after 8s
Build Release / build-linux (push) Successful in 59s
Lint & Test / test (push) Successful in 1m52s
Some checks failed
Build Release / create-release (push) Successful in 1s
Build Release / build-windows (push) Successful in 1m16s
Build Release / build-docker (push) Failing after 8s
Build Release / build-linux (push) Successful in 59s
Lint & Test / test (push) Successful in 1m52s
Windows: install-autostart.bat (Startup folder shortcut), uninstall-autostart.bat. Linux: install-service.sh (systemd unit), uninstall-service.sh. Both launchers now use python -m wled_controller.main so port is read from config/env instead of being hardcoded to 8080.
This commit is contained in:
@@ -243,6 +243,9 @@ cd /d "%~dp0"
|
||||
set PYTHONPATH=%~dp0app\src
|
||||
set WLED_CONFIG_PATH=%~dp0app\config\default_config.yaml
|
||||
|
||||
:: Read port from env var or use default
|
||||
if "%WLED_SERVER__PORT%"=="" set WLED_SERVER__PORT=8080
|
||||
|
||||
:: Create data directory if missing
|
||||
if not exist "%~dp0data" mkdir "%~dp0data"
|
||||
if not exist "%~dp0logs" mkdir "%~dp0logs"
|
||||
@@ -250,13 +253,13 @@ if not exist "%~dp0logs" mkdir "%~dp0logs"
|
||||
echo.
|
||||
echo =============================================
|
||||
echo LedGrab v${VERSION_CLEAN}
|
||||
echo Open http://localhost:8080 in your browser
|
||||
echo Open http://localhost:%WLED_SERVER__PORT% in your browser
|
||||
echo =============================================
|
||||
echo.
|
||||
|
||||
:: Start the server (open browser after short delay)
|
||||
start "" /b cmd /c "timeout /t 2 /nobreak >nul && start http://localhost:8080"
|
||||
"%~dp0python\python.exe" -m uvicorn wled_controller.main:app --host 0.0.0.0 --port 8080
|
||||
:: Start the server — uses config from WLED_CONFIG_PATH, port from config or env
|
||||
start "" /b cmd /c "timeout /t 2 /nobreak >nul && start http://localhost:%WLED_SERVER__PORT%"
|
||||
"%~dp0python\python.exe" -m wled_controller.main
|
||||
|
||||
pause
|
||||
LAUNCHER
|
||||
@@ -264,6 +267,64 @@ LAUNCHER
|
||||
# Convert launcher to Windows line endings
|
||||
sed -i 's/$/\r/' "$DIST_DIR/LedGrab.bat"
|
||||
|
||||
# ── Create autostart scripts ─────────────────────────────────
|
||||
|
||||
cat > "$DIST_DIR/install-autostart.bat" << 'AUTOSTART'
|
||||
@echo off
|
||||
:: Install LedGrab to start automatically on Windows login
|
||||
:: Creates a shortcut in the Startup folder
|
||||
|
||||
set SHORTCUT_NAME=LedGrab
|
||||
set STARTUP_DIR=%APPDATA%\Microsoft\Windows\Start Menu\Programs\Startup
|
||||
set TARGET=%~dp0LedGrab.bat
|
||||
set SHORTCUT=%STARTUP_DIR%\%SHORTCUT_NAME%.lnk
|
||||
|
||||
echo Installing LedGrab autostart...
|
||||
|
||||
:: Use PowerShell to create a proper shortcut
|
||||
powershell -NoProfile -Command ^
|
||||
"$ws = New-Object -ComObject WScript.Shell; ^
|
||||
$sc = $ws.CreateShortcut('%SHORTCUT%'); ^
|
||||
$sc.TargetPath = '%TARGET%'; ^
|
||||
$sc.WorkingDirectory = '%~dp0'; ^
|
||||
$sc.WindowStyle = 7; ^
|
||||
$sc.Description = 'LedGrab ambient lighting server'; ^
|
||||
$sc.Save()"
|
||||
|
||||
if exist "%SHORTCUT%" (
|
||||
echo.
|
||||
echo [OK] LedGrab will start automatically on login.
|
||||
echo Shortcut: %SHORTCUT%
|
||||
echo.
|
||||
echo To remove: run uninstall-autostart.bat
|
||||
) else (
|
||||
echo.
|
||||
echo [ERROR] Failed to create shortcut.
|
||||
)
|
||||
|
||||
pause
|
||||
AUTOSTART
|
||||
sed -i 's/$/\r/' "$DIST_DIR/install-autostart.bat"
|
||||
|
||||
cat > "$DIST_DIR/uninstall-autostart.bat" << 'UNAUTOSTART'
|
||||
@echo off
|
||||
:: Remove LedGrab from Windows startup
|
||||
|
||||
set SHORTCUT=%APPDATA%\Microsoft\Windows\Start Menu\Programs\Startup\LedGrab.lnk
|
||||
|
||||
if exist "%SHORTCUT%" (
|
||||
del "%SHORTCUT%"
|
||||
echo.
|
||||
echo [OK] LedGrab autostart removed.
|
||||
) else (
|
||||
echo.
|
||||
echo LedGrab autostart was not installed.
|
||||
)
|
||||
|
||||
pause
|
||||
UNAUTOSTART
|
||||
sed -i 's/$/\r/' "$DIST_DIR/uninstall-autostart.bat"
|
||||
|
||||
# ── Create ZIP ───────────────────────────────────────────────
|
||||
|
||||
ZIP_PATH="$BUILD_DIR/$ZIP_NAME"
|
||||
|
||||
Reference in New Issue
Block a user