-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·61 lines (52 loc) · 1.98 KB
/
Copy pathsetup.sh
File metadata and controls
executable file
·61 lines (52 loc) · 1.98 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
#!/bin/bash
# ============================================================
# HumWatch — Linux Setup
# ============================================================
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR"
echo "Setting up HumWatch for Linux..."
echo "Remote access uses https://localhost:9100 or an HTTPS peer URL."
echo "Keep /etc/humwatch and /var/lib/humwatch outside application updates."
# 1. Check Python
if ! command -v python3 &> /dev/null; then
echo "[X] python3 is required but not found. Please install python3 and python3-venv."
exit 1
fi
# 2. Select a venv outside the immutable application tree for root installs.
if [ "$(id -u)" -eq 0 ]; then
VENV_DIR="/usr/lib/humwatch/venv"
install -d -o root -g root -m 0755 /usr/lib/humwatch
else
VENV_DIR="$SCRIPT_DIR/venv"
fi
# 3. Create venv if not exists
if [ ! -d "$VENV_DIR" ]; then
echo "[+] Creating virtual environment..."
python3 -m venv "$VENV_DIR"
else
echo "[i] Virtual environment already exists."
fi
# 4. Install requirements
echo "[+] Installing dependencies..."
"$VENV_DIR/bin/python" -m pip install -r requirements.txt
if [ "$(id -u)" -eq 0 ]; then
"$SCRIPT_DIR/scripts/provision-security.sh" --app-dir "$SCRIPT_DIR"
chmod 0750 /etc/humwatch /etc/humwatch/tls
chown root:humwatch /etc/humwatch/auth-token
chmod 0640 /etc/humwatch/auth-token
chown root:humwatch /etc/humwatch/tls/humwatch-key.pem
chmod 0640 /etc/humwatch/tls/humwatch-key.pem
chown root:humwatch /etc/humwatch/environment
chmod 0640 /etc/humwatch/environment
else
echo "[i] Production service provisioning requires root. Run:"
echo " sudo $SCRIPT_DIR/scripts/provision-security.sh --app-dir $SCRIPT_DIR"
echo " Store the shared token and certificate trust material in protected paths."
fi
echo ""
if [ "$(id -u)" -eq 0 ]; then
echo "[+] Production setup complete. Runtime venv: $VENV_DIR"
else
echo "[+] Setup complete! Run ./run.sh to start."
fi