Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion deploy/auto-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ setup_docker_openwisp() {
set_env "VPN_DOMAIN" ""
set_env CELERY_SERVICE_NETWORK_MODE ""
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"
Expand Down
14 changes: 7 additions & 7 deletions docs/user/settings.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -57,8 +57,8 @@ properly on your system.

.. _vpn_domain:

``VPN_DOMAIN``
~~~~~~~~~~~~~~
``OPENVPN_DOMAIN``
~~~~~~~~~~~~~~~~~~
Comment on lines 58 to +61
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

# First, let's examine the current state of the file around lines 58-61
sed -n '55,70p' docs/user/settings.rst

Repository: openwisp/docker-openwisp

Length of output: 446


🏁 Script executed:

# Search for cross-references to vpn_domain anchor
rg -n ':ref:`.*vpn_domain.*`' --glob '*.rst'

Repository: openwisp/docker-openwisp

Length of output: 50


🏁 Script executed:

# Search for any references to vpn_domain in the codebase
rg -n 'vpn_domain' --glob '*.rst'

Repository: openwisp/docker-openwisp

Length of output: 163


🏁 Script executed:

# Check if openvpn_domain anchor or references already exist
rg -n 'openvpn_domain' --glob '*.rst'

Repository: openwisp/docker-openwisp

Length of output: 50


🏁 Script executed:

# Examine the context around the vpn_domain reference in quickstart.rst
sed -n '50,65p' docs/user/quickstart.rst

Repository: openwisp/docker-openwisp

Length of output: 897


Update the reStructuredText anchor and cross-reference to match the variable name.

The anchor on line 58 of docs/user/settings.rst uses .. _vpn_domain: while the environment variable is named OPENVPN_DOMAIN. This inconsistency should be resolved by renaming the anchor to .. _openvpn_domain:. Additionally, the cross-reference in docs/user/quickstart.rst:58 that uses :ref:OpenVPN <vpn_domain> must be updated to `:ref:`OpenVPN <openvpn_domain> to maintain the working reference.

Changes required

In docs/user/settings.rst line 58:

-.. _vpn_domain:
+.. _openvpn_domain:

In docs/user/quickstart.rst line 58:

-<vpn_domain>` services.
+<openvpn_domain>` services.
🤖 Prompt for AI Agents
In `@docs/user/settings.rst` around lines 58 - 61, Rename the reST anchor ..
_vpn_domain: to .. _openvpn_domain: in the settings documentation and update the
corresponding cross-reference :ref:`OpenVPN <vpn_domain>` to :ref:`OpenVPN
<openvpn_domain>` so the anchor name matches the environment variable
OPENVPN_DOMAIN and the reference resolves correctly.


- **Explanation:** Valid domain / IP address to reach the OpenVPN server.
- **Valid Values:** Any valid domain or IP address.
Expand Down Expand Up @@ -988,15 +988,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
Expand Down
2 changes: 1 addition & 1 deletion images/common/init_command.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,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
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

# Check the shebang and content of the file
head -n 35 images/common/init_command.sh | cat -n

Repository: openwisp/docker-openwisp

Length of output: 1216


Fix POSIX shell incompatibility: use [ ] instead of [[ ]].

Line 32 uses bash-specific [[ ]] test syntax, but the shebang is /bin/sh. This will cause a syntax error in dash (the default /bin/sh in most container environments). Replace with the POSIX-compatible [ -z "$OPENVPN_DOMAIN" ].

Suggested fix
-	if [[ -z "$OPENVPN_DOMAIN" ]]; then exit; fi
+	if [ -z "$OPENVPN_DOMAIN" ]; then exit; fi
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if [[ -z "$OPENVPN_DOMAIN" ]]; then exit; fi
if [ -z "$OPENVPN_DOMAIN" ]; then exit; fi
🧰 Tools
🪛 Shellcheck (0.11.0)

[warning] 32-32: In POSIX sh, [[ ]] is undefined.

(SC3010)

🤖 Prompt for AI Agents
In `@images/common/init_command.sh` at line 32, The test using bash-only [[ ]]
around OPENVPN_DOMAIN is incompatible with the /bin/sh shebang; replace the
conditional in the init script that checks OPENVPN_DOMAIN (the line using [[ -z
"$OPENVPN_DOMAIN" ]]) with a POSIX-compatible test using [ -z "$OPENVPN_DOMAIN"
] and ensure proper quoting and an exit (e.g., exit 1) remains after the test to
preserve behavior in the init_command.sh flow.

wait_nginx_services
openvpn_preconfig
openvpn_config
Expand Down
8 changes: 4 additions & 4 deletions images/openwisp_base/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,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 \
Expand Down
6 changes: 3 additions & 3 deletions images/openwisp_dashboard/load_init_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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:
Expand All @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion images/openwisp_openvpn/supervisord.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading