- Scripts: start-webdav.cmd, stop-webdav.cmd (echo messages, REM comments) - Server: server.js (console.log, HTTP error messages) - Token tools: token-test.js, token-refresh.js - Other: auth-poc.js, debug-name-decrypt.js, internxt-client.js, upload.js - Docs: README, .env.example, docs/*.md Made-with: Cursor
50 lines
1.6 KiB
Batchfile
50 lines
1.6 KiB
Batchfile
@echo off
|
|
REM Duplicati Pre-Start: Start WebDAV server
|
|
REM In Duplicati: Settings -> Advanced -> Scripts -> Run before backup
|
|
REM Path: C:\path\to\internxt-webdav\scripts\start-webdav.cmd
|
|
REM Optional: Port as argument (e.g. start-webdav.cmd 8080)
|
|
|
|
cd /d "%~dp0.."
|
|
if "%1"=="" (set PORT=3005) else (set PORT=%1)
|
|
for /f "tokens=2 delims==" %%a in ('findstr /B "PORT=" .env 2^>nul') do set PORT=%%a
|
|
|
|
REM Check .env and token
|
|
if not exist .env (
|
|
echo ERROR: .env missing. Copy from .env.example and add INXT_TOKEN.
|
|
exit /b 1
|
|
)
|
|
findstr /B "INXT_TOKEN=" .env 2>nul | findstr "INXT_TOKEN=." > nul 2>&1
|
|
if %errorlevel% neq 0 (
|
|
echo ERROR: INXT_TOKEN missing or empty in .env. Token expired? Run npm run token-refresh.
|
|
exit /b 1
|
|
)
|
|
|
|
REM Check if server already running (0.0.0.0:0 = Listening)
|
|
netstat -an | findstr /C:":%PORT% " | findstr /C:"0.0.0.0:0" > nul 2>&1
|
|
if %errorlevel% equ 0 (
|
|
echo WebDAV server already running.
|
|
exit /b 0
|
|
)
|
|
|
|
if not exist "%~dp0..\logs" mkdir "%~dp0..\logs"
|
|
set LOGFILE=%~dp0..\logs\webdav.log
|
|
echo [%date% %time%] Starting WebDAV server... >> "%LOGFILE%"
|
|
echo Starting WebDAV server... Log: %LOGFILE%
|
|
start /B node src/server.js >> "%LOGFILE%" 2>&1
|
|
|
|
REM Wait and check if server responds (OPTIONS does not require auth)
|
|
set RETRIES=0
|
|
:wait
|
|
timeout /t 2 /nobreak > nul
|
|
powershell -NoProfile -Command "try { (Invoke-WebRequest -Uri http://127.0.0.1:%PORT%/ -Method OPTIONS -UseBasicParsing -TimeoutSec 2).StatusCode -eq 200 } catch { exit 1 }" > nul 2>&1
|
|
if %errorlevel% equ 0 (
|
|
echo WebDAV server started.
|
|
exit /b 0
|
|
)
|
|
set /a RETRIES+=1
|
|
if %RETRIES% geq 5 (
|
|
echo ERROR: Server not responding. Check token: npm run token-test
|
|
exit /b 1
|
|
)
|
|
goto wait
|