-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.bat
More file actions
99 lines (84 loc) · 3.15 KB
/
Copy pathrun.bat
File metadata and controls
99 lines (84 loc) · 3.15 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
@echo off
:: ============================================================
:: HumWatch — Run (with admin elevation for full sensor access)
:: Ctrl+C to stop.
:: ============================================================
:: Check for admin
net session >nul 2>&1
if %errorlevel% neq 0 (
echo Requesting administrator privileges...
powershell -Command "Start-Process -Verb RunAs -FilePath '%~f0'"
exit /b
)
setlocal EnableExtensions EnableDelayedExpansion
set "ROOT=%~dp0"
set "ROOT=%ROOT:~0,-1%"
:: Use venv if it exists, otherwise system Python
if exist "%ROOT%\venv\Scripts\activate.bat" (
call "%ROOT%\venv\Scripts\activate.bat"
) else (
echo [WARN] No venv found. Run setup.bat first, or using system Python.
)
:: A provisioned install keeps its credentials and certificate under
:: %ProgramData%\HumWatch (see installer\service-setup.ps1). If setup.bat
:: was declined for the Windows service, none of this exists yet and we
:: fall through to the development profile below.
set "PROV_ROOT=%ProgramData%\HumWatch"
set "PROV_DATA_DIR=%PROV_ROOT%\data"
set "PROV_TOKEN=%PROV_ROOT%\auth-token"
set "PROV_CERT=%PROV_ROOT%\tls\humwatch-cert.pem"
set "PROV_KEY=%PROV_ROOT%\tls\humwatch-key.pem"
set "PROV_CA=%PROV_ROOT%\tls\trusted-ca.pem"
if not exist "%PROV_TOKEN%" goto :dev_profile
if not exist "%PROV_CERT%" goto :dev_profile
if not exist "%PROV_KEY%" goto :dev_profile
goto :provisioned
:provisioned
set "HUMWATCH_DATA_DIR=%PROV_DATA_DIR%"
set "HUMWATCH_AUTH_TOKEN_FILE=%PROV_TOKEN%"
set "HUMWATCH_TLS_CERTFILE=%PROV_CERT%"
set "HUMWATCH_TLS_KEYFILE=%PROV_KEY%"
if exist "%PROV_CA%" set "HUMWATCH_TRUSTED_CA_FILE=%PROV_CA%"
set "PLAINTEXT_FALLBACK=0"
goto :startup
:dev_profile
:: Unprivileged source checkout, or the provisioned files simply are not
:: there yet. Provision a local development profile so the agent starts
:: with the same token requirement as a real install.
if not exist "%ROOT%\.humwatch" mkdir "%ROOT%\.humwatch"
set "DEV_TOKEN_FILE=%ROOT%\.humwatch\auth-token"
if not exist "%DEV_TOKEN_FILE%" python -c "import secrets; print(secrets.token_hex(32))" > "%DEV_TOKEN_FILE%"
set "HUMWATCH_DATA_DIR=%ROOT%\.humwatch"
set "HUMWATCH_LOG_DIR=%ROOT%\.humwatch\logs"
set "HUMWATCH_AUTH_TOKEN_FILE=%DEV_TOKEN_FILE%"
set "HUMWATCH_HOST=127.0.0.1"
:: The dev profile stays on the plaintext loopback exception. Provisioned installs get their certificate from scripts\generate_certificate.py.
set "HUMWATCH_ALLOW_INSECURE_LOCALHOST=1"
set "PLAINTEXT_FALLBACK=1"
echo [i] Development profile. Runtime state lives in "%ROOT%\.humwatch"
echo [i] Dashboard token (paste it when the dashboard asks):
type "%DEV_TOKEN_FILE%"
echo.
goto :startup
:startup
if "%PLAINTEXT_FALLBACK%"=="1" goto :startup_plaintext
goto :startup_https
:startup_plaintext
title HumWatch - 127.0.0.1:9100
echo.
echo HumWatch starting on the plaintext loopback exception at 127.0.0.1:9100
echo Press Ctrl+C to stop.
echo.
goto :run
:startup_https
title HumWatch - https://localhost:9100
echo.
echo HumWatch starting on https://localhost:9100
echo Trust the HumWatch certificate before opening the dashboard.
echo Press Ctrl+C to stop.
echo.
goto :run
:run
cd /d "%ROOT%"
python -m agent.main
pause