From ec8f5f858cddd6d198cfdacc733cb4c88cdf98b1 Mon Sep 17 00:00:00 2001
From: Lukas Werner <lks.werner@fau.de>
Date: Thu, 5 Aug 2021 16:42:46 +0200
Subject: [PATCH] Fixed error messages

---
 runner_scripts/root/cleanup.sh | 6 +++---
 runner_scripts/root/config.sh  | 6 +++---
 runner_scripts/root/run.sh     | 6 +++---
 3 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/runner_scripts/root/cleanup.sh b/runner_scripts/root/cleanup.sh
index 93a0630..6ae5939 100755
--- a/runner_scripts/root/cleanup.sh
+++ b/runner_scripts/root/cleanup.sh
@@ -25,8 +25,8 @@ function error {
 
 ## User authentication
 
-[ -z "$CUSTOM_ENV_AUTH_USER" ] && error "AUTH_USER CI/CD variable has not been set."
-[ -z "$CUSTOM_ENV_AUTH_KEY" ] && error "AUTH_KEY secret CI/CD variable has not been set."
+[ -z "${CUSTOM_ENV_AUTH_USER:+x}" ] && error "AUTH_USER CI/CD variable has not been set."
+[ -z "${CUSTOM_ENV_AUTH_KEY:+x}" ] && error "AUTH_KEY secret CI/CD variable has not been set."
 
 AUTH_USER=$CUSTOM_ENV_AUTH_USER
 
@@ -50,7 +50,7 @@ exit 1
 
 AUTH_USER_WORK=$(runuser "$AUTH_USER" --login --command "echo \$WORK")
 
-[ -z "$AUTH_USER_WORK" ] && error "Could not determine $AUTH_USER's \$WORK directory."
+[ -z "${AUTH_USER_WORK:+x}" ] && error "Could not determine $AUTH_USER's \$WORK directory."
 
 BASE_DIR=$AUTH_USER_WORK/gitlab-runner/builds/${CUSTOM_ENV_CI_CONCURRENT_PROJECT_ID:?}/${CUSTOM_ENV_CI_PROJECT_NAMESPACE:?}/${CUSTOM_ENV_CI_PROJECT_NAME:?}
 
diff --git a/runner_scripts/root/config.sh b/runner_scripts/root/config.sh
index 16d120a..4458a02 100755
--- a/runner_scripts/root/config.sh
+++ b/runner_scripts/root/config.sh
@@ -8,14 +8,14 @@ TXT_GREEN="\e[32m"
 TXT_CLEAR="\e[0m"
 TXT_BOLD="\e[1m"
 
-[ -z "$CUSTOM_ENV_AUTH_USER" ] && error "AUTH_USER CI/CD variable has not been set."
-[ -z "$CUSTOM_ENV_AUTH_KEY" ] && error "AUTH_KEY secret CI/CD variable has not been set."
+[ -z "${CUSTOM_ENV_AUTH_USER:+x}" ] && error "AUTH_USER CI/CD variable has not been set."
+[ -z "${CUSTOM_ENV_AUTH_KEY:+x}" ] && error "AUTH_KEY secret CI/CD variable has not been set."
 
 AUTH_USER=$CUSTOM_ENV_AUTH_USER
 
 AUTH_USER_WORK=$(runuser "$AUTH_USER" --login --command "echo \$WORK")
 
-[ -z "$AUTH_USER_WORK" ] && error "Could not determine $AUTH_USER's \$WORK directory."
+[ -z "${AUTH_USER_WORK:+x}" ] && error "Could not determine $AUTH_USER's \$WORK directory."
 
 cat << EOS
 {
diff --git a/runner_scripts/root/run.sh b/runner_scripts/root/run.sh
index 5cb26a5..9cb8210 100755
--- a/runner_scripts/root/run.sh
+++ b/runner_scripts/root/run.sh
@@ -30,8 +30,8 @@ function error {
 
 ## User authentication
 
-[ -z "$CUSTOM_ENV_AUTH_USER" ] && error "AUTH_USER CI/CD variable has not been set."
-[ -z "$CUSTOM_ENV_AUTH_KEY" ] && error "AUTH_KEY secret CI/CD variable has not been set."
+[ -z "${CUSTOM_ENV_AUTH_USER:+x}" ] && error "AUTH_USER CI/CD variable has not been set."
+[ -z "${CUSTOM_ENV_AUTH_KEY:+x}" ] && error "AUTH_KEY secret CI/CD variable has not been set."
 
 AUTH_USER=$CUSTOM_ENV_AUTH_USER
 
@@ -57,7 +57,7 @@ AUTH_USER_HOME=$(getent passwd "$AUTH_USER" | awk -F ":" '{print $6}')
 AUTH_USER_SHELL=$(getent passwd "$AUTH_USER" | awk -F ":" '{print $7}')
 AUTH_USER_WORK=$(runuser "$AUTH_USER" --login --command "echo \$WORK")
 
-[ -z "$AUTH_USER_WORK" ] && error "Could not determine $AUTH_USER's \$WORK directory."
+[ -z "${AUTH_USER_WORK:+x}" ] && error "Could not determine $AUTH_USER's \$WORK directory."
 
 chown -R "$AUTH_USER" "$TMPDIR"
 
-- 
GitLab