UI delivery, stage B: single CSP with optional connect-src origins (OVPMON_CSP_CONNECT_EXTRA)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
ayurishchevandClaude Sonnet 5.5 committed 2026-10-07 13:28:30 +03:00
1 parent d38acd74de
commit d5e83eaff5
13 files changed
+211 -17

No files matched your search

+9 -2
View File
@@ -2,7 +2,7 @@
# Install OpenVPN Monitor & Profiler as system services (no containers): Alpine (OpenRC), Debian, Ubuntu (systemd).
#
# deploy/native/install.sh [--prefix DIR] [--ui-dist FILE|DIR | --build-ui [--node-download] | --no-ui]
# [--https-port N] [--host-name NAME] [--admin-user NAME] [--force]
# [--https-port N] [--csp-connect-extra ORIGINS] [--host-name NAME] [--admin-user NAME] [--force]
#
# --prefix install directory (APP_CORE, APP_PROFILER, venvs). REQUIRED: without the option the script
# asks for it (no default is assumed). It must be a new or empty directory, different from
@@ -18,6 +18,9 @@
# automatically (a warning is printed when it is older than APP_UI); when there is no UI
# source at all the install stops
# --https-port HTTPS port of the web UI (default 8088)
# --csp-connect-extra extra origins the UI may call (CSP connect-src), for an API on another host: origins
# https://host[:port] or http://host[:port] separated by spaces, in quotes (default: none, same
# origin only). Kept in /etc/ovpmon/deploy.state as OVPMON_CSP_CONNECT_EXTRA
# --host-name DNS name or IP of this host: certificate name and CORS origin (default: detected address)
# --admin-user login of the initial administrator (default: admin); the password is generated
# --force continue on an untested OS version / Debian derivative
@@ -41,6 +44,7 @@ UI_BUILD=0
UI_NODE_DL=0
NO_UI=0
HTTPS_PORT=8088
CSP_EXTRA=""
HOST_NAME=""
ADMIN_USER="admin"
FORCE=0
@@ -54,6 +58,7 @@ while [ $# -gt 0 ]; do
--node-download) UI_NODE_DL=1; shift ;;
--no-ui) NO_UI=1; shift ;;
--https-port) [ $# -ge 2 ] || die "--https-port needs a value"; HTTPS_PORT="$2"; shift 2 ;;
--csp-connect-extra) [ $# -ge 2 ] || die "--csp-connect-extra needs a value"; CSP_EXTRA="$2"; shift 2 ;;
--host-name) [ $# -ge 2 ] || die "--host-name needs a value"; HOST_NAME="$2"; shift 2 ;;
--admin-user) [ $# -ge 2 ] || die "--admin-user needs a value"; ADMIN_USER="$2"; shift 2 ;;
--force) FORCE=1; shift ;;
@@ -125,6 +130,7 @@ else
[ -z "$_problem" ] || die "invalid --prefix '$PREFIX': $_problem"
fi
valid_port "$HTTPS_PORT" || die "invalid --https-port '$HTTPS_PORT'"
if ! _csp_reason=$(csp_extra_problem "$CSP_EXTRA"); then die "invalid --csp-connect-extra '$CSP_EXTRA': $_csp_reason"; fi
case "$ADMIN_USER" in
""|*[!A-Za-z0-9._-]*) die "invalid --admin-user (letters, digits, . _ - only)" ;;
esac
@@ -434,7 +440,7 @@ fi
# nginx site
_tmp="$TMPD/ovpmon.conf"
mkdir -p "$NGINX_CONF_DIR"
render_nginx "$SRC" "$HTTPS_PORT" "$_tmp"
render_nginx "$SRC" "$HTTPS_PORT" "$_tmp" "$CSP_EXTRA"
rc=0
install_managed "$_tmp" "$NGINX_SITE" 644 "deploy/native/nginx/ovpmon.conf.template" || rc=$?
case "$rc" in
@@ -497,6 +503,7 @@ fi
CURRENT_PHASE="finish"
state_set OVPMON_PREFIX "$PREFIX"
state_set OVPMON_HTTPS_PORT "$HTTPS_PORT"
state_set OVPMON_CSP_CONNECT_EXTRA "$CSP_EXTRA"
state_set OVPMON_OS "$OS_ID $OS_VERSION_ID"
state_set OVPMON_VERSION "$(cat "$PREFIX/VERSION")"
[ -n "$(state_get OVPMON_INSTALLED_AT)" ] || state_set OVPMON_INSTALLED_AT "$(now_iso)"