forked from Special-K-s-Flightsim-Bots/DCSServerBot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.cmd
More file actions
76 lines (69 loc) · 1.88 KB
/
run.cmd
File metadata and controls
76 lines (69 loc) · 1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
@echo off
echo.
echo ___ ___ ___ ___ ___ _
echo ^| \ / __/ __/ __^| ___ _ ___ _____ _ _^| _ ) ___^| ^|_
echo ^| ^|) ^| (__\__ \__ \/ -_) '_\ V / -_) '_^| _ \/ _ \ _^|
echo ^|___/ \___^|___/___/\___^|_^| \_/\___^|_^| ^|___/\___/\__^|
echo.
python --version >NUL 2>&1
if errorlevel 9009 (
echo.
echo *** ERROR ***
echo python.exe was not found in your PATH.
echo Please run the Python installer and check "Add python to the environment".
exit /B 9009
)
python -c "import sys; sys.exit(0 if sys.version_info >= (3,10) else 1)" >NUL 2>&1
if errorlevel 1 (
echo.
echo *** ERROR ***
echo DCSServerBot requires Python >= 3.10.
exit /B 1
)
SETLOCAL ENABLEEXTENSIONS
SET "ARGS=%*"
SET "node_name=%computername%"
SET "restarted=false"
:loop1
if "%~1"=="-n" (
SET node_name=%~2
)
SHIFT
if NOT "%~1"=="" goto loop1
DEL dcssb_%node_name%.pid 2>NUL
SET VENV=%USERPROFILE%\.dcssb
if not exist "%VENV%" (
echo Creating the Python Virtual Environment ...
python -m venv "%VENV%"
"%VENV%\Scripts\python.exe" -m pip install --upgrade pip
"%VENV%\Scripts\pip" install -r requirements.txt
)
SET PROGRAM=run.py
:loop
"%VENV%\Scripts\python" %PROGRAM% %ARGS%
if %ERRORLEVEL% EQU -1 (
IF NOT %restarted% == true (
SET restarted=true
SET ARGS=%* --restarted
)
SET PROGRAM=run.py
goto loop
) else if %ERRORLEVEL% LSS -1000000000 (
echo A Windows error occured: %ERRORLEVEL%
IF NOT %restarted% == true (
SET restarted=true
SET ARGS=%* --restarted
)
SET PROGRAM=run.py
goto loop
) else if %ERRORLEVEL% EQU -3 (
SET PROGRAM=update.py
goto loop
) else if %ERRORLEVEL% EQU -2 (
echo Please press any key to continue...
pause > NUL
) else (
echo Unexpected return code: %ERRORLEVEL%
echo Please check the logs and press any key to continue...
pause > NUL
)