Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion .github/workflows/bot-ci-failure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ permissions:
contents: read

concurrency:
group: ci-failure-${{ github.repository }}-${{ github.event.workflow_run.pull_requests[0].number || format('{0}:{1}', github.event.workflow_run.head_repository.full_name, github.event.workflow_run.head_branch) }}
group: ci-failure-${{ github.repository }}-${{ github.event.workflow_run.pull_requests[0].number || format('{0}:{1}', github.event.workflow_run.head_repository.full_name, github.event.workflow_run.head_branch) }}
cancel-in-progress: true

jobs:
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,15 @@ jobs:
run: |
sudo curl -sL -o /bin/hadolint "https://github.com/hadolint/hadolint/releases/download/v2.12.0/hadolint-Linux-x86_64"
sudo chmod +x /bin/hadolint
sudo curl -sL -o /usr/local/bin/shfmt "https://github.com/mvdan/sh/releases/download/v3.13.1/shfmt_v3.13.1_linux_amd64"
sudo chmod +x /usr/local/bin/shfmt
echo "127.0.0.1 dashboard.openwisp.org api.openwisp.org" | sudo tee -a /etc/hosts
# disable metric collection during builds
sed -i 's/METRIC_COLLECTION=True/METRIC_COLLECTION=False/' .env
# ERROR: Cannot uninstall urllib3 2.0.7, RECORD file not found. Hint: The package was installed by debian.
sudo apt remove python3-urllib3 python3-typing-extensions
sudo pip3 install -r requirements-test.txt
sudo npm install -g prettier

- name: QA checks
run: ./run-qa-checks
Expand Down
8 changes: 4 additions & 4 deletions deploy/auto-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ check_status() {

# Returns true if the backup .env exists and contains app secrets
has_backup_with_secrets() {
[[ -f "$ENV_BACKUP" ]] && \
[[ -n "$(get_env "DB_USER" "$ENV_BACKUP")" ]] && \
[[ -n "$(get_env "DB_PASS" "$ENV_BACKUP")" ]] && \
[[ -n "$(get_env "DJANGO_SECRET_KEY" "$ENV_BACKUP")" ]]
[[ -f "$ENV_BACKUP" ]] &&
[[ -n "$(get_env "DB_USER" "$ENV_BACKUP")" ]] &&
[[ -n "$(get_env "DB_PASS" "$ENV_BACKUP")" ]] &&
[[ -n "$(get_env "DJANGO_SECRET_KEY" "$ENV_BACKUP")" ]]
}

error_msg() {
Expand Down
5 changes: 3 additions & 2 deletions docs/developer/instructions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,9 @@ Run Quality Assurance Checks
----------------------------

We use `shfmt <https://github.com/mvdan/sh#shfmt>`__ to format shell
scripts and `hadolint <https://github.com/hadolint/hadolint#install>`__ to
lint Dockerfiles.
scripts, `hadolint <https://github.com/hadolint/hadolint#install>`__ to
lint Dockerfiles, and `prettier <https://prettier.io>`__ to check
formatting of YAML, JSON, CSS, JavaScript, and Markdown files.

To format all files, run:

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 @@ -66,7 +66,7 @@ elif [ "$MODULE_NAME" = 'nginx' ]; then
# sentinel from the generated nginx.conf.
export NGINX_WORKER_RLIMIT_NOFILE="${NGINX_WORKER_RLIMIT_NOFILE:-__UNSET__}"
envsubst </etc/nginx/nginx.template.conf >/etc/nginx/nginx.conf
# Remove incomplete worker_rlimit_nofile directives if env var is unset or empty
# Remove incomplete worker_rlimit_nofile directives if env var is unset or empty
sed -i '/__UNSET__/d; /^worker_rlimit_nofile *$/d; /^[[:space:]]*$/d' /etc/nginx/nginx.conf
envsubst_create_config /etc/nginx/openwisp.internal.template.conf internal INTERNAL
if [ "$SSL_CERT_MODE" = 'Yes' ]; then
Expand Down
2 changes: 1 addition & 1 deletion images/common/openwisp/asgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
routes.extend(get_controller_routes())

if env_bool(os.environ.get("USE_OPENWISP_TOPOLOGY")):
from openwisp_network_topology.routing import ( # noqa: E402
from openwisp_network_topology.routing import (
websocket_urlpatterns as network_topology_routes,
)

Expand Down
55 changes: 28 additions & 27 deletions images/common/utils.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#!/bin/sh

function init_conf {
init_conf() {
default_psql_vars
}

function default_psql_vars {
default_psql_vars() {
# Set database variable values in default PG
# vars to use psql command without passing additional
# arguments.
Expand All @@ -19,7 +19,7 @@ function default_psql_vars {
export PGSSLROOTCERT=$DB_SSLROOTCERT
}

function start_uwsgi {
start_uwsgi() {
# If a user supplies custom uWSGI configuration, then
# due to lack of write permissions this command will fail.
# Hence, OR (||) operator is used here to continue execution
Expand All @@ -28,7 +28,7 @@ function start_uwsgi {
uwsgi --ini uwsgi.ini
}

function create_prod_certs {
create_prod_certs() {
if [ ! -f /etc/letsencrypt/live/${DASHBOARD_DOMAIN}/privkey.pem ]; then
certbot certonly --standalone --noninteractive --agree-tos \
--rsa-key-size 4096 \
Expand All @@ -41,7 +41,7 @@ function create_prod_certs {
fi
}

function create_dev_certs {
create_dev_certs() {
# Ensure required directories exist
mkdir -p /etc/letsencrypt/live/${DASHBOARD_DOMAIN}/
mkdir -p /etc/letsencrypt/live/${API_DOMAIN}/
Expand All @@ -60,7 +60,7 @@ function create_dev_certs {
fi
}

function nginx_dev {
nginx_dev() {
envsubst_create_config /etc/nginx/openwisp.ssl.template.conf https DOMAIN
ssl_http_behaviour
create_dev_certs
Expand All @@ -69,15 +69,15 @@ function nginx_dev {
nginx -g 'daemon off;'
}

function nginx_prod {
nginx_prod() {
create_prod_certs
ssl_http_behaviour
envsubst_create_config /etc/nginx/openwisp.ssl.template.conf https DOMAIN
CMD="certbot --nginx renew && nginx -s reload"
echo "0 3 * * 7 ${CMD} &>> /etc/nginx/log/crontab.log" | crontab -
}

function wait_nginx_services {
wait_nginx_services() {
# Wait for nginx to start up and then check
# if the openwisp-dashboard is reachable.
echo "Waiting for dashboard to become available..."
Expand All @@ -96,15 +96,15 @@ function wait_nginx_services {
set -e # Restore previous error setting.
}

function ssl_http_behaviour {
if [ "$NGINX_HTTP_ALLOW" == "True" ]; then
ssl_http_behaviour() {
if [ "$NGINX_HTTP_ALLOW" = "True" ]; then
envsubst_create_config /etc/nginx/openwisp.template.conf http DOMAIN
else
envsubst </etc/nginx/openwisp.ssl.80.template.conf >/etc/nginx/conf.d/openwisp.http.conf
fi
}

function envsubst_create_config {
envsubst_create_config() {
# Creates nginx configurations files for dashboard
# and api instances.
for application in DASHBOARD API; do
Expand All @@ -117,7 +117,7 @@ function envsubst_create_config {
done
}

function postfix_config {
postfix_config() {
# This function is used to configure the
# postfix instance.

Expand Down Expand Up @@ -203,7 +203,7 @@ get_redis_value() {
echo -en "GET $key\r\n" | nc redis 6379 | awk 'NR==2 {gsub(/\r/, ""); print}'
}

function openvpn_preconfig {
openvpn_preconfig() {
mkdir -p /dev/net
if [ ! -c /dev/net/tun ]; then
mknod /dev/net/tun c 10 200
Expand All @@ -217,7 +217,7 @@ function openvpn_preconfig {
fi
}

function openvpn_config {
openvpn_config() {
# Fectch UUID and Key of the default VPN only if they
# are not already set. The user may override the UUID and Key
# by setting them in the environment variables to use deploy
Expand All @@ -229,28 +229,29 @@ function openvpn_config {
fi
}

function openvpn_config_checksum {
export OFILE=$(curl --silent --insecure \
${API_INTERNAL}/controller/vpn/checksum/$UUID/?key=$KEY)
export NFILE=$(cat checksum)
openvpn_config_checksum() {
OFILE=$(curl --silent --insecure \
"${API_INTERNAL}/controller/vpn/checksum/${UUID}/?key=${KEY}")
export OFILE
NFILE=$(cat checksum)
export NFILE
Comment thread
nemesifier marked this conversation as resolved.
}

function openvpn_config_download {
curl --silent --retry 10 --retry-delay 5 --retry-max-time 300\
--insecure --output vpn.tar.gz \
${API_INTERNAL}/controller/vpn/download-config/$UUID/?key=$KEY
openvpn_config_download() {
curl --silent --retry 10 --retry-delay 5 --retry-max-time 300 --insecure --output vpn.tar.gz \
"${API_INTERNAL}/controller/vpn/download-config/${UUID}/?key=${KEY}"
curl --silent --insecure --output checksum \
${API_INTERNAL}/controller/vpn/checksum/$UUID/?key=$KEY
"${API_INTERNAL}/controller/vpn/checksum/${UUID}/?key=${KEY}"
tar xzf vpn.tar.gz
chmod 600 *.pem
chmod 600 ./*.pem
Comment thread
nemesifier marked this conversation as resolved.
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.

function crl_download {
crl_download() {
curl --silent --insecure --output revoked.crl \
${DASHBOARD_INTERNAL}/admin/pki/ca/x509/ca/${CA_UUID}.crl
"${DASHBOARD_INTERNAL}/admin/pki/ca/x509/ca/${CA_UUID}.crl"
}

function init_send_network_topology {
init_send_network_topology() {
if [ -z "$TOPOLOGY_UUID" ]; then
export TOPOLOGY_UUID=$(get_redis_value "default_openvpn_topology_uuid")
export TOPOLOGY_KEY=$(get_redis_value "default_openvpn_topology_key")
Expand Down
16 changes: 8 additions & 8 deletions images/openwisp_dashboard/openvpn.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
"comp_lzo": "no",
"auth": "SHA1",
"data_ciphers": [
{
"cipher": "AES-128-GCM",
"optional": false
},
{
"cipher": "none",
"optional": false
}
{
"cipher": "AES-128-GCM",
"optional": false
},
{
"cipher": "none",
"optional": false
}
],
"data_ciphers_fallback": "AES-128-GCM",
"cipher": "AES-128-GCM",
Expand Down
16 changes: 6 additions & 10 deletions run-qa-checks
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,15 @@

set -e

# will be 1 by default when run through github actions
CI=${CI:-false}

echo ''
echo 'Python file QA checks...'
openwisp-qa-check --skip-checkmigrations
openwisp-qa-check --skip-checkmigrations --jslinter --csslinter

if [ "$CI" = "false" ]; then
echo 'Shell scripts QA checks ...'
# check shell scripts formatting
sh_files=$(shfmt -f .)
shfmt -d .
fi
echo ''
echo 'Shell scripts QA checks ...'
# check shell scripts formatting
sh_files=$(shfmt -f .)
shfmt -d .

echo ''
echo 'Dockerfile QA checks...'
Expand Down