2026-01-09 01:05:50 +03:00
|
|
|
#!/sbin/openrc-run
|
2026-10-05 10:45:24 +03:00
|
|
|
# managed by ovpmon deploy/native (install.sh / update.sh replace this file only while this marker line is present)
|
|
|
|
|
#
|
|
|
|
|
# OpenVPN Monitor API (Flask under gunicorn, APP_CORE), OpenRC (Alpine).
|
|
|
|
|
# Install: deploy/native/install.sh renders this template (install dir, if not the default) into
|
|
|
|
|
# /etc/init.d/ovpmon-api. Manual use: copy it there (chmod 755), `rc-update add ovpmon-api default`,
|
|
|
|
|
# `rc-service ovpmon-api start`. Guide: DOCS/Deployment/Scenario2_System_Services.md
|
|
|
|
|
#
|
|
|
|
|
# Settings come from /etc/ovpmon/env (root:root 600), sourced in start_pre while still root; the
|
|
|
|
|
# daemon then runs as ovpmon. supervise-daemon restarts it after a crash.
|
|
|
|
|
# The service does not depend on openvpn: the VPN server is started from the UI through the root helper.
|
2026-01-09 01:05:50 +03:00
|
|
|
|
|
|
|
|
name="ovpmon-api"
|
2026-10-05 10:45:24 +03:00
|
|
|
description="OpenVPN Monitor API (gunicorn)"
|
|
|
|
|
|
2026-01-09 01:05:50 +03:00
|
|
|
supervisor="supervise-daemon"
|
2026-10-05 10:45:24 +03:00
|
|
|
respawn_delay=3
|
|
|
|
|
respawn_max=0
|
2026-01-09 01:05:50 +03:00
|
|
|
|
2026-10-05 10:45:24 +03:00
|
|
|
command_user="ovpmon:ovpmon"
|
|
|
|
|
directory="/opt/OpenVPN-Monitoring-Simple/APP_CORE"
|
|
|
|
|
command="/opt/OpenVPN-Monitoring-Simple/APP_CORE/venv/bin/python"
|
|
|
|
|
command_args="-m gunicorn -w 2 -b 127.0.0.1:5001 openvpn_api_v3:app"
|
2026-01-09 01:05:50 +03:00
|
|
|
|
2026-10-05 10:45:24 +03:00
|
|
|
output_log="/var/log/ovpmon/ovpmon-api.log"
|
|
|
|
|
error_log="/var/log/ovpmon/ovpmon-api.log"
|
2026-01-09 01:05:50 +03:00
|
|
|
|
|
|
|
|
depend() {
|
|
|
|
|
need net
|
|
|
|
|
after firewall
|
|
|
|
|
}
|
2026-10-05 10:45:24 +03:00
|
|
|
|
|
|
|
|
start_pre() {
|
|
|
|
|
# log file writable for the service user (the log directory is owned by ovpmon)
|
|
|
|
|
checkpath -f -m 0640 -o ovpmon:ovpmon "$output_log" || return 1
|
|
|
|
|
# export the service environment; the file is data written by install.sh (KEY=VALUE lines)
|
|
|
|
|
[ -r /etc/ovpmon/env ] || { eerror "/etc/ovpmon/env is missing"; return 1; }
|
|
|
|
|
set -a
|
|
|
|
|
. /etc/ovpmon/env
|
|
|
|
|
set +a
|
|
|
|
|
# extend, never replace: OpenRC itself needs /lib/rc/bin (ebegin, eend) on the PATH
|
|
|
|
|
export PATH="/usr/local/sbin:/usr/local/bin:$PATH"
|
|
|
|
|
}
|