Files
aza/AzA march 2026 - Kopie (6)/RUN_AZA_ONECLICK.bat

121 lines
2.4 KiB
Batchfile
Raw Normal View History

2026-04-16 13:32:32 +02:00
@echo off
setlocal EnableExtensions DisableDelayedExpansion
cd /d "%~dp0"
set "URLFILE=%~dp0backend_url.txt"
set "TOKENFILE=%~dp0backend_token.txt"
set "CLIENT=%~dp0basis14.py"
set "TIMEOUT_SEC=15"
echo.
echo ==========================================
echo AZA ONE-CLICK START (Backend -> AZA)
echo Ordner: %~dp0
echo ==========================================
echo.
set "BACKEND_START=%~dp0start_backend_autoport.bat"
if not exist "%BACKEND_START%" (
for %%F in ("%~dp0start_backend*.bat") do (
set "BACKEND_START=%%~fF"
goto FOUND_BACKEND
)
)
:FOUND_BACKEND
if not exist "%BACKEND_START%" (
echo FEHLER: Kein Backend-Startscript gefunden.
echo Erwartet: start_backend_autoport.bat ODER start_backend*.bat
echo.
dir /b "%~dp0*.bat"
echo.
pause
exit /b 1
)
if not exist "%CLIENT%" (
echo FEHLER: basis14.py nicht gefunden:
echo %CLIENT%
echo.
pause
exit /b 1
)
if not exist "%TOKENFILE%" (
echo dev-secret-2026> "%TOKENFILE%"
)
echo [1/4] Starte Backend...
echo %BACKEND_START%
call "%BACKEND_START%"
if errorlevel 1 (
echo FEHLER: Backend-Start fehlgeschlagen.
echo Siehe ggf. logs\backend.log
pause
exit /b 6
)
echo [2/4] Warte auf backend_url.txt (max %TIMEOUT_SEC%s)...
set /a "i=0"
:wait_backend_url
if exist "%URLFILE%" goto backend_url_ready
set /a "i+=1"
if %i% GEQ %TIMEOUT_SEC% goto backend_url_timeout
timeout /t 1 /nobreak >nul
goto wait_backend_url
:backend_url_timeout
echo FEHLER: backend_url.txt nicht gefunden nach %TIMEOUT_SEC%s.
echo Pfad: %URLFILE%
echo Siehe ggf. logs\backend.log
pause
exit /b 2
:backend_url_ready
set "BURL="
for /f "usebackq delims=" %%U in ("%URLFILE%") do if not defined BURL set "BURL=%%U"
set "BTOK="
for /f "usebackq delims=" %%T in ("%TOKENFILE%") do if not defined BTOK set "BTOK=%%T"
if "%BURL%"=="" (
echo FEHLER: backend_url.txt ist leer.
pause
exit /b 3
)
if "%BTOK%"=="" (
echo FEHLER: backend_token.txt ist leer.
pause
exit /b 4
)
set "MEDWORK_BACKEND_URL=%BURL%"
set "MEDWORK_API_TOKEN=%BTOK%"
echo [3/4] ENV gesetzt:
echo MEDWORK_BACKEND_URL=%MEDWORK_BACKEND_URL%
echo MEDWORK_API_TOKEN=(gesetzt)
echo [4/4] Starte AZA...
echo.
where python >nul 2>&1
if errorlevel 1 goto TRY_PY
python "%CLIENT%"
goto DONE
:TRY_PY
where py >nul 2>&1
if errorlevel 1 goto NO_PY
py -3 "%CLIENT%"
goto DONE
:NO_PY
echo FEHLER: Weder python noch py gefunden.
pause
exit /b 5
:DONE
endlocal
exit /b 0