diff --git a/runner_scripts/root/cleanup.sh b/runner_scripts/root/cleanup.sh index 93a0630a62fcc3250c923d8dc5706d1516436d11..6ae593906b5c9a019c8a6c6adad0821c0d4e7fa2 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 16d120a715f7d75c2eb81bed03f149e1d513e5c8..4458a02d1fab303f8ff2cf36596b1052c87fd5b7 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 5cb26a5296ac85fdf3980f32a1ba59e2dc27c92d..9cb8210d5b41ad95e469f33213dca775272798b2 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"