From b21beb96c2624fae6db008c2e0adeb41ce7d9ef5 Mon Sep 17 00:00:00 2001 From: Felix Bartels Date: Tue, 26 Feb 2019 16:52:56 +0100 Subject: [PATCH] shellcheck for webapp Signed-off-by: Felix Bartels --- core/start-service.sh | 22 +++++++++++----------- webapp/start.sh | 8 ++++---- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/core/start-service.sh b/core/start-service.sh index 75b9911..a433035 100755 --- a/core/start-service.sh +++ b/core/start-service.sh @@ -4,29 +4,29 @@ ADDITIONAL_KOPANO_PACKAGES=${ADDITIONAL_KOPANO_PACKAGES:-""} set -eu # unset variables are errors & non-zero return values exit the whole script -if [ ! -e /kopano/$SERVICE_TO_START.py ]; then +if [ ! -e /kopano/"$SERVICE_TO_START".py ]; then echo "Invalid service specified: $SERVICE_TO_START" | ts exit 1 fi [ ! -z "$ADDITIONAL_KOPANO_PACKAGES" ] && apt update -[ ! -z "$ADDITIONAL_KOPANO_PACKAGES" ] && for installpkg in "$ADDITIONAL_KOPANO_PACKAGES"; do - if [ $(dpkg-query -W -f='${Status}' $installpkg 2>/dev/null | grep -c "ok installed") -eq 0 ]; then - apt --assume-yes install $installpkg; +[ ! -z "$ADDITIONAL_KOPANO_PACKAGES" ] && for installpkg in $ADDITIONAL_KOPANO_PACKAGES; do + if [ $(dpkg-query -W -f='${Status}' "$installpkg" 2>/dev/null | grep -c "ok installed") -eq 0 ]; then + apt --assume-yes install "$installpkg"; fi done -mkdir -p /kopano/data/attachments /kopano/data/kapi-kvs /tmp/$SERVICE_TO_START /var/run/kopano +mkdir -p /kopano/data/attachments /kopano/data/kapi-kvs /tmp/"$SERVICE_TO_START" /var/run/kopano echo "Configure core service '$SERVICE_TO_START'" | ts -/usr/bin/python3 /kopano/$SERVICE_TO_START.py +/usr/bin/python3 /kopano/"$SERVICE_TO_START".py echo "Set ownership" | ts chown -R kopano:kopano /run /tmp chown kopano:kopano /kopano/data/ /kopano/data/attachments # ensure removed pid-file on unclean shutdowns and mounted volumes -rm -f /var/run/kopano/$SERVICE_TO_START.pid +rm -f /var/run/kopano/"$SERVICE_TO_START".pid # allow helper commands given by "docker-compose run" if [ $# -gt 0 ]; then @@ -40,8 +40,8 @@ server) /kopano/services/kopano-public-store.sh & /kopano/services/kopano-users.sh & dockerize \ - -wait file://$KCCONF_SERVER_SERVER_SSL_CA_FILE \ - -wait file://$KCCONF_SERVER_SERVER_SSL_KEY_FILE \ + -wait file://"$KCCONF_SERVER_SERVER_SSL_CA_FILE" \ + -wait file://"$KCCONF_SERVER_SERVER_SSL_KEY_FILE" \ -wait tcp://db:3306 \ -timeout 360s # cleaning up env variables @@ -75,8 +75,8 @@ ical) grapi) LC_CTYPE=en_US.UTF-8 export socket_path=/var/run/kopano/grapi - mkdir -p $socket_path - chown -R kapi:kopano $socket_path + mkdir -p "$socket_path" + chown -R kapi:kopano "$socket_path" # cleaning up env variables unset "${!KCCONF_@}" exec kopano-grapi serve diff --git a/webapp/start.sh b/webapp/start.sh index 133e0de..9354172 100755 --- a/webapp/start.sh +++ b/webapp/start.sh @@ -10,10 +10,10 @@ set -eu # unset variables are errors & non-zero return values exit the whole scr ADDITIONAL_KOPANO_PACKAGES="$ADDITIONAL_KOPANO_PACKAGES $ADDITIONAL_KOPANO_WEBAPP_PLUGINS" -[ ! -z ${ADDITIONAL_KOPANO_PACKAGES// } ] && apt update -[ ! -z ${ADDITIONAL_KOPANO_PACKAGES// } ] && for installpkg in "$ADDITIONAL_KOPANO_PACKAGES"; do - if [ $(dpkg-query -W -f='${Status}' $installpkg 2>/dev/null | grep -c "ok installed") -eq 0 ]; then - apt --assume-yes install $installpkg; +[ ! -z "${ADDITIONAL_KOPANO_PACKAGES// }" ] && apt update +[ ! -z "${ADDITIONAL_KOPANO_PACKAGES// }" ] && for installpkg in $ADDITIONAL_KOPANO_PACKAGES; do + if [ $(dpkg-query -W -f='${Status}' "$installpkg" 2>/dev/null | grep -c "ok installed") -eq 0 ]; then + apt --assume-yes install "$installpkg" fi done