forked from vektort13/MITMVpn
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy_dashboard.sh
More file actions
executable file
·71 lines (59 loc) · 2.35 KB
/
Copy pathdeploy_dashboard.sh
File metadata and controls
executable file
·71 lines (59 loc) · 2.35 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
#!/usr/bin/env bash
# Maps the rich dashboard files (shipped to /root) into the Apache web root
# under the names the live SPA expects. Run on the VPN server after
# provision_openvpn_lab.sh and setup_passive_detection.sh.
set -euo pipefail
WEB_ROOT="/var/www/html"
STUDENT_ROOT="/var/www/openvpn-student"
SRC_DIR="${1:-/root}"
declare -A FILES=(
[dashboard_live.php]="index.php" # live polling SPA -> default page
[dashboard_api.php]="api.php" # JSON feed consumed by index.php
[dashboard_logs.php]="logs.php" # export / report / clear-logs endpoint
[dashboard_favicon.php]="favicon.php" # favicon proxy used by the SPA
[dashboard_index.php]="classic.php" # server-rendered no-JS fallback page
)
install -d -m 755 "$WEB_ROOT"
install -d -m 755 "$STUDENT_ROOT"
for src in "${!FILES[@]}"; do
dst="${FILES[$src]}"
if [ ! -f "$SRC_DIR/$src" ]; then
echo "MISSING: $SRC_DIR/$src" >&2
exit 1
fi
install -m 644 -o root -g root "$SRC_DIR/$src" "$WEB_ROOT/$dst"
echo "installed $src -> $WEB_ROOT/$dst"
done
# Public read-only student view. It uses the same dashboard in read-only mode
# when served below /student/, plus public read-only data/favicon endpoints.
install -m 644 -o root -g root "$SRC_DIR/dashboard_live.php" "$STUDENT_ROOT/index.php"
install -m 644 -o root -g root "$SRC_DIR/dashboard_api.php" "$STUDENT_ROOT/api.php"
install -m 644 -o root -g root "$SRC_DIR/dashboard_favicon.php" "$STUDENT_ROOT/favicon.php"
cat > /etc/apache2/conf-available/openvpn-student.conf <<EOF
RedirectMatch 302 ^/student$ /student/
Alias /student/ $STUDENT_ROOT/
<Directory $STUDENT_ROOT>
Options -Indexes
AllowOverride None
DirectoryIndex index.php
Require all granted
</Directory>
EOF
if command -v a2enconf >/dev/null 2>&1; then
a2enconf openvpn-student >/dev/null
fi
# The simple inline index.php written by provision_openvpn_lab.sh is now
# replaced by the live SPA above; drop any stale static index.
rm -f "$WEB_ROOT/index.html"
# favicon.php caches into this dir as www-data.
install -d -m 755 -o www-data -g www-data /var/cache/openvpn-lab-favicons 2>/dev/null || \
install -d -m 755 /var/cache/openvpn-lab-favicons
if command -v apache2ctl >/dev/null 2>&1; then
apache2ctl configtest
fi
systemctl reload apache2.service
echo "=== web root ==="
ls -l "$WEB_ROOT"
echo
echo "=== public student view ==="
ls -l "$STUDENT_ROOT"