From 5b79c4fda75af59df212d4b7f8c12c7f30ecc34b Mon Sep 17 00:00:00 2001 From: Adityashandilya555 Date: Mon, 6 Oct 2025 22:24:04 +0530 Subject: [PATCH] [env] Update VPN environment variables to OPENVPN for WireGuard support #227 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Changed VPN_* environment variables to OPENVPN_* to distinguish them from upcoming WireGuard VPN configurations. This prepares the codebase for WireGuard support by making OpenVPN-specific variables clearly identifiable. Changes: - VPN_DOMAIN → OPENVPN_DOMAIN - VPN_NAME → OPENVPN_NAME - VPN_CLIENT_NAME → OPENVPN_CLIENT_NAME Updated across configuration files, Docker images, scripts, and documentation. Fixes #227 --- .env | 8 ++++---- deploy/auto-install.sh | 6 +++--- docs/user/settings.rst | 14 +++++++------- images/common/init_command.sh | 2 +- images/openwisp_base/Dockerfile | 8 ++++---- images/openwisp_dashboard/load_init_data.py | 6 +++--- images/openwisp_openvpn/supervisord.conf | 2 +- 7 files changed, 23 insertions(+), 23 deletions(-) diff --git a/.env b/.env index 573874aa..940e0257 100644 --- a/.env +++ b/.env @@ -7,7 +7,7 @@ API_DOMAIN=api.openwisp.org # SSH Credentials Configurations SSH_PRIVATE_KEY_PATH=/home/openwisp/.ssh/id_ed25519 SSH_PUBLIC_KEY_PATH=/home/openwisp/.ssh/id_ed25519.pub -VPN_DOMAIN=openvpn.openwisp.org +OPENVPN_DOMAIN=openvpn.openwisp.org EMAIL_DJANGO_DEFAULT=example@example.org DB_USER=admin DB_PASS=admin @@ -42,9 +42,9 @@ X509_ORGANIZATION_NAME=OpenWISP X509_ORGANIZATION_UNIT_NAME=OpenWISP X509_EMAIL=certificate@example.com X509_COMMON_NAME=OpenWISP -# VPN -VPN_NAME=default -VPN_CLIENT_NAME=default-management-vpn +# OpenVPN +OPENVPN_NAME=default +OPENVPN_CLIENT_NAME=default-management-vpn # Developer DEBUG_MODE=False DJANGO_LOG_LEVEL=INFO diff --git a/deploy/auto-install.sh b/deploy/auto-install.sh index 356b79ef..1127a25b 100755 --- a/deploy/auto-install.sh +++ b/deploy/auto-install.sh @@ -147,11 +147,11 @@ setup_docker_openwisp() { fi # VPN domain if [[ -z "$vpn_domain" ]]; then - set_env "VPN_DOMAIN" "openvpn.${domain}" + set_env "OPENVPN_DOMAIN" "openvpn.${domain}" elif [[ "${vpn_domain,,}" == "n" ]]; then - set_env "VPN_DOMAIN" "example.com" + set_env "OPENVPN_DOMAIN" "example.com" else - set_env "VPN_DOMAIN" "$vpn_domain" + set_env "OPENVPN_DOMAIN" "$vpn_domain" fi # Site manager email set_env "EMAIL_DJANGO_DEFAULT" "$django_default_email" diff --git a/docs/user/settings.rst b/docs/user/settings.rst index 13bdd7fb..399cc7d6 100644 --- a/docs/user/settings.rst +++ b/docs/user/settings.rst @@ -25,7 +25,7 @@ Additionally, you can search for the following prefixes: - ``DASHBOARD_``: Settings specific to the OpenWISP dashboard. - ``API_``: Settings specific to the OpenWISP API. - ``X509_``: Configurations related to x509 CA and certificates. -- ``VPN_``: Default VPN and VPN template configurations. +- ``OPENVPN_``: Default OpenVPN and OpenVPN template configurations. - ``CRON_``: Periodic task configurations. - ``EXPORT_``: NFS server configurations. @@ -57,8 +57,8 @@ properly on your system. .. _vpn_domain: -``VPN_DOMAIN`` -~~~~~~~~~~~~~~ +``OPENVPN_DOMAIN`` +~~~~~~~~~~~~~~~~~~ - **Explanation:** Valid domain / IP address to reach the OpenVPN server. - **Valid Values:** Any valid domain or IP address. @@ -955,15 +955,15 @@ Nginx OpenVPN ------- -``VPN_NAME`` -~~~~~~~~~~~~ +``OPENVPN_NAME`` +~~~~~~~~~~~~~~~~ -- **Explanation:** Name of the VPN Server that will be visible on the +- **Explanation:** Name of the OpenVPN Server that will be visible on the OpenWISP dashboard. - **Valid Values:** STRING. - **Default:** ``default``. -``VPN_CLIENT_NAME`` +``OPENVPN_CLIENT_NAME`` ~~~~~~~~~~~~~~~~~~~ - **Explanation:** Name of the VPN client template that will be visible on diff --git a/images/common/init_command.sh b/images/common/init_command.sh index b023589f..60e956b4 100644 --- a/images/common/init_command.sh +++ b/images/common/init_command.sh @@ -28,7 +28,7 @@ elif [ "$MODULE_NAME" = 'freeradius' ]; then source docker-entrypoint.sh -X fi elif [ "$MODULE_NAME" = 'openvpn' ]; then - if [[ -z "$VPN_DOMAIN" ]]; then exit; fi + if [[ -z "$OPENVPN_DOMAIN" ]]; then exit; fi wait_nginx_services openvpn_preconfig openvpn_config diff --git a/images/openwisp_base/Dockerfile b/images/openwisp_base/Dockerfile index 7c5623bc..10cf2e9a 100644 --- a/images/openwisp_base/Dockerfile +++ b/images/openwisp_base/Dockerfile @@ -148,10 +148,10 @@ ENV DASHBOARD_APP_SERVICE=dashboard \ # SSH Credentials Configurations SSH_PRIVATE_KEY_PATH=/home/openwisp/.ssh/id_ed25519 \ SSH_PUBLIC_KEY_PATH=/home/openwisp/.ssh/id_ed25519.pub \ - # VPN Configurations - VPN_DOMAIN=openvpn.example.com \ - VPN_NAME=default \ - VPN_CLIENT_NAME=default-management-vpn \ + # OpenVPN Configurations + OPENVPN_DOMAIN=openvpn.example.com \ + OPENVPN_NAME=default \ + OPENVPN_CLIENT_NAME=default-management-vpn \ X509_NAME_CA=default \ X509_NAME_CERT=default \ X509_COUNTRY_CODE=IN \ diff --git a/images/openwisp_dashboard/load_init_data.py b/images/openwisp_dashboard/load_init_data.py index 04b6dee4..3eee4d93 100644 --- a/images/openwisp_dashboard/load_init_data.py +++ b/images/openwisp_dashboard/load_init_data.py @@ -83,7 +83,7 @@ def create_default_cert(ca): def create_default_vpn(ca, cert): """Creates default vpn.""" - vpn_name = os.environ["VPN_NAME"] + vpn_name = os.environ["OPENVPN_NAME"] if Vpn.objects.exists(): try: vpn = Vpn.objects.get(name=vpn_name) @@ -104,7 +104,7 @@ def create_default_vpn(ca, cert): "you may modify these settings and they will soon reflect " "in your OpenVPN Server instance." ), - host=os.environ["VPN_DOMAIN"], + host=os.environ["OPENVPN_DOMAIN"], backend="openwisp_controller.vpn_backends.OpenVpn", ) with open("openvpn.json", "r") as json_file: @@ -120,7 +120,7 @@ def create_default_vpn(ca, cert): def create_default_vpn_template(vpn): """Creates default vpn client template.""" - template_name = os.environ["VPN_CLIENT_NAME"] + template_name = os.environ["OPENVPN_CLIENT_NAME"] if Template.objects.filter(vpn=vpn).exists(): return Template.objects.get(vpn=vpn) diff --git a/images/openwisp_openvpn/supervisord.conf b/images/openwisp_openvpn/supervisord.conf index 2c2ce187..b5bf869b 100644 --- a/images/openwisp_openvpn/supervisord.conf +++ b/images/openwisp_openvpn/supervisord.conf @@ -18,7 +18,7 @@ pidfile=/supervisord.pid [program:openvpn] user=root directory=/ -command=/usr/sbin/openvpn --config %(ENV_VPN_NAME)s.conf +command=/usr/sbin/openvpn --config %(ENV_OPENVPN_NAME)s.conf autostart=true autorestart=true stopsignal=INT