1- #! /bin/sh
1+ #! /bin/bash
22
33function init_conf {
44 default_psql_vars
@@ -86,7 +86,7 @@ function wait_nginx_services {
8686 set +e
8787 while : ; do
8888 wget -qS ${DASHBOARD_INTERNAL} /admin/login/ 2>&1 | grep -q " 200 OK"
89- if [[ $? = " 0" ] ]; then
89+ if [ $? = " 0" ]; then
9090 FAILURE=0
9191 echo " Connection with dashboard established."
9292 break
@@ -97,7 +97,7 @@ function wait_nginx_services {
9797}
9898
9999function ssl_http_behaviour {
100- if [ " $NGINX_HTTP_ALLOW " == " True" ]; then
100+ if [ " $NGINX_HTTP_ALLOW " = " True" ]; then
101101 envsubst_create_config /etc/nginx/openwisp.template.conf http DOMAIN
102102 else
103103 envsubst < /etc/nginx/openwisp.ssl.80.template.conf > /etc/nginx/conf.d/openwisp.http.conf
@@ -236,18 +236,25 @@ function openvpn_config_checksum {
236236}
237237
238238function openvpn_config_download {
239- curl --silent --retry 10 --retry-delay 5 --retry-max-time 300\
240- --insecure --output vpn.tar.gz \
241- ${API_INTERNAL} /controller/vpn/download-config/$UUID /? key=$KEY
239+ curl --silent --retry 10 --retry-delay 5 --retry-max-time 300 --insecure --output vpn.tar.gz \
240+ " ${API_INTERNAL} /controller/vpn/download-config/$UUID /?key=$KEY "
242241 curl --silent --insecure --output checksum \
243- ${API_INTERNAL} /controller/vpn/checksum/$UUID /? key=$KEY
242+ " ${API_INTERNAL} /controller/vpn/checksum/$UUID /?key=$KEY "
244243 tar xzf vpn.tar.gz
245244 chmod 600 * .pem
245+ # Prefer a newly extracted non-standard filename and normalize it.
246+ CONF_FILE=$( find . -maxdepth 1 -type f -name ' *.conf' ! -name ' openvpn.conf' -print -quit)
247+ if [ -n " $CONF_FILE " ]; then
248+ mv -f -- " $CONF_FILE " openvpn.conf
249+ elif [ ! -f openvpn.conf ]; then
250+ echo " ERROR: no OpenVPN config file found after extraction" >&2
251+ return 1
252+ fi
246253}
247254
248255function crl_download {
249256 curl --silent --insecure --output revoked.crl \
250- ${DASHBOARD_INTERNAL} /admin/pki/ca/x509/ca/${CA_UUID} .crl
257+ " ${DASHBOARD_INTERNAL} /admin/pki/ca/x509/ca/${CA_UUID} .crl"
251258}
252259
253260function init_send_network_topology {
0 commit comments