From 374ea33501e66053143354f2dbf9ba1760924766 Mon Sep 17 00:00:00 2001 From: Lukas Werner <lks.werner@fau.de> Date: Wed, 4 Aug 2021 17:47:11 +0200 Subject: [PATCH] Added some colored status messages --- runner_scripts/root/cleanup.sh | 12 +++++++++--- runner_scripts/root/config.sh | 12 +++++++++--- runner_scripts/root/run.sh | 10 +++++++++- 3 files changed, 27 insertions(+), 7 deletions(-) diff --git a/runner_scripts/root/cleanup.sh b/runner_scripts/root/cleanup.sh index 9291068..6e6421d 100755 --- a/runner_scripts/root/cleanup.sh +++ b/runner_scripts/root/cleanup.sh @@ -1,7 +1,13 @@ #!/bin/bash -l set -euf -o pipefail shopt -s inherit_errexit - + +TXT_RED="\e[31m" +TXT_BLUE="\e[94m" +TXT_GREEN="\e[32m" +TXT_CLEAR="\e[0m" +TXT_BOLD="\e[1m" + hash awk hash chown hash diff @@ -13,7 +19,7 @@ hash ssh-keygen function error { : "${RV:=${2:-$BUILD_FAILURE_EXIT_CODE}}" - echo "$1" >&2 + echo -e "${TXT_RED}${TXT_BOLD}$1${TXT_CLEAR}" >&2 return "$RV" } @@ -44,7 +50,7 @@ exit 1 AUTH_USER_WORK=$(runuser "$AUTH_USER" --login --command "echo \$WORK") -: "${AUTH_USER_WORK:?"Could not determine $AUTH_USER's \$WORK directory."}" +: "${AUTH_USER_WORK:?"${TXT_RED}${TXT_BOLD}Could not determine $AUTH_USER's \$WORK directory.${TXT_CLEAR}"}" 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 22f11a6..eef9813 100755 --- a/runner_scripts/root/config.sh +++ b/runner_scripts/root/config.sh @@ -2,14 +2,20 @@ set -euf -o pipefail shopt -s inherit_errexit -: "${CUSTOM_ENV_AUTH_USER:?"AUTH_USER CI/CD variable has not been set."}" -: "${CUSTOM_ENV_AUTH_KEY:?"AUTH_KEY secret CI/CD variable has not been set."}" +TXT_RED="\e[31m" +TXT_BLUE="\e[94m" +TXT_GREEN="\e[32m" +TXT_CLEAR="\e[0m" +TXT_BOLD="\e[1m" + +: "${CUSTOM_ENV_AUTH_USER:?"${TXT_RED}${TXT_BOLD}AUTH_USER CI/CD variable has not been set.${TXT_CLEAR}"}" +: "${CUSTOM_ENV_AUTH_KEY:?"${TXT_RED}${TXT_BOLD}AUTH_KEY secret CI/CD variable has not been set.${TXT_CLEAR}"}" AUTH_USER=$CUSTOM_ENV_AUTH_USER AUTH_USER_WORK=$(runuser "$AUTH_USER" --login --command "echo \$WORK") -: "${AUTH_USER_WORK:?"Could not determine $AUTH_USER's \$WORK directory."}" +: "${AUTH_USER_WORK:?"${TXT_RED}${TXT_BOLD}Could not determine $AUTH_USER's \$WORK directory.${TXT_CLEAR}"}" cat << EOS { diff --git a/runner_scripts/root/run.sh b/runner_scripts/root/run.sh index 50e7690..c3f1d51 100755 --- a/runner_scripts/root/run.sh +++ b/runner_scripts/root/run.sh @@ -4,6 +4,12 @@ shopt -s inherit_errexit MAX_CI_JOB_RUNTIME=120 +TXT_RED="\e[31m" +TXT_BLUE="\e[94m" +TXT_GREEN="\e[32m" +TXT_CLEAR="\e[0m" +TXT_BOLD="\e[1m" + hash awk hash chown hash diff @@ -18,7 +24,7 @@ hash sinfo function error { : "${RV:=${2:-$BUILD_FAILURE_EXIT_CODE}}" - echo "$1" >&2 + echo -e "${TXT_RED}${TXT_BOLD}$1${TXT_CLEAR}" >&2 return "$RV" } @@ -110,6 +116,8 @@ if [[ ("$2" == "step_script" || "$2" == "build_script") && "${CUSTOM_ENV_NO_SLUR \"$AUTH_USER_SHELL\" --login \"$BASE_DIR.tmp/$CUSTOM_ENV_CI_JOB_ID.sh\"" >> "$TMPDIR"/salloc.sh chmod +x "$TMPDIR"/salloc.sh + echo -e "${TXT_GREEN}${TXT_BOLD}Submitting job to node $SLURM_NODELIST...${TXT_CLEAR}" + exec runuser --login "$AUTH_USER" --command "$TMPDIR"/salloc.sh #exec runuser --login "$AUTH_USER" --command "salloc --quiet --chdir \"$BASE_DIR\" ${SALLOC_OPTIONS[@]} \ -- GitLab