Skip to content

Commit 630545d

Browse files
[fix] Ensure POSIX shell compatibility in runtime scripts #572
Replace bash-specific syntax ([[ ]]) with POSIX-compliant ([ ]) to ensure compatibility with /bin/sh environments. Fixes #572
1 parent c03f024 commit 630545d

7 files changed

Lines changed: 9 additions & 9 deletions

File tree

images/common/init_command.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ elif [ "$MODULE_NAME" = 'freeradius' ]; then
2929
source docker-entrypoint.sh -X
3030
fi
3131
elif [ "$MODULE_NAME" = 'openvpn' ]; then
32-
if [[ -z "$VPN_DOMAIN" ]]; then exit; fi
32+
if [ -z "$VPN_DOMAIN" ]; then exit; fi
3333
wait_nginx_services
3434
openvpn_preconfig
3535
openvpn_config
@@ -93,7 +93,7 @@ elif [ "$MODULE_NAME" = 'celery' ]; then
9393
${OPENWISP_CELERY_NETWORK_COMMAND_FLAGS}
9494
fi
9595

96-
if [[ "$USE_OPENWISP_FIRMWARE" == "True" && "$USE_OPENWISP_CELERY_FIRMWARE" == "True" ]]; then
96+
if [ "$USE_OPENWISP_FIRMWARE" = "True" ] && [ "$USE_OPENWISP_CELERY_FIRMWARE" = "True" ]; then
9797
echo "Starting the 'firmware_upgrader' celery worker"
9898
celery -A openwisp worker -l ${DJANGO_LOG_LEVEL} --queues firmware_upgrader \
9999
-n firmware_upgrader@%h --logfile /opt/openwisp/logs/celery_firmware_upgrader.log \
@@ -104,7 +104,7 @@ elif [ "$MODULE_NAME" = 'celery' ]; then
104104
tail -f /opt/openwisp/logs/*
105105
elif [ "$MODULE_NAME" = 'celery_monitoring' ]; then
106106
python services.py database redis dashboard
107-
if [[ "$USE_OPENWISP_MONITORING" == "True" && "$USE_OPENWISP_CELERY_MONITORING" == 'True' ]]; then
107+
if [ "$USE_OPENWISP_MONITORING" = "True" ] && [ "$USE_OPENWISP_CELERY_MONITORING" = "True" ]; then
108108
echo "Starting the 'monitoring' celery worker"
109109
celery -A openwisp worker -l ${DJANGO_LOG_LEVEL} --queues monitoring \
110110
-n monitoring@%h --logfile /opt/openwisp/logs/celery_monitoring.log \

images/common/utils.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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

images/openwisp_freeradius/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ RUN apk add --no-cache --update \
99
RUN addgroup -S freerad && \
1010
adduser -S freerad -G freerad
1111

12-
CMD ["bash", "init_command.sh"]
12+
CMD ["sh", "init_command.sh"]
1313
EXPOSE 1812/udp 1813/udp
1414

1515
# hadolint ignore=DL3045

images/openwisp_nfs/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ ENV TZ=UTC \
1515
EXPORT_DIR="/exports" \
1616
EXPORT_OPTS="10.0.0.0/8(rw,fsid=0,insecure,no_root_squash,no_subtree_check,sync)"
1717

18-
CMD ["bash", "init_command.sh"]
18+
CMD ["sh", "init_command.sh"]

images/openwisp_nginx/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ RUN apk add --update --no-cache \
99
rm -rf /var/cache/apk/* /tmp/*
1010

1111
WORKDIR /etc/nginx/
12-
CMD ["bash", "init_command.sh"]
12+
CMD ["sh", "init_command.sh"]
1313
EXPOSE 80 443
1414

1515
# DL3018

images/openwisp_openvpn/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ RUN apk add --no-cache \
77
tzdata \
88
supervisor && \
99
rm -rf /var/cache/apk/* /tmp/*
10-
CMD ["bash", "init_command.sh"]
10+
CMD ["sh", "init_command.sh"]
1111
EXPOSE 1194
1212

1313
ENV MODULE_NAME=openvpn \

images/openwisp_postfix/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ RUN apk add --no-cache --upgrade \
1111
tzdata && \
1212
rm -rf /tmp/* /var/cache/apk/*
1313

14-
CMD ["bash", "init_command.sh"]
14+
CMD ["sh", "init_command.sh"]
1515
EXPOSE 25
1616

1717
COPY ./openwisp_postfix/rsyslog.conf /etc/rsyslog.conf

0 commit comments

Comments
 (0)