From 8146355b16c0924fb9b93a674257a863bb820af6 Mon Sep 17 00:00:00 2001 From: Marco Malavolti <marco.malavolti@gmail.com> Date: Wed, 29 Jul 2020 10:32:34 +0200 Subject: [PATCH] Fixed environment variables --- README.md | 2 -- cleanAndRunEccs2.sh | 62 +++++++++++++++++++++++++-------------------- 2 files changed, 34 insertions(+), 30 deletions(-) diff --git a/README.md b/README.md index dcacb62..dfbe123 100644 --- a/README.md +++ b/README.md @@ -181,11 +181,9 @@ Note: Pay attetion on the chromedriver version: * CentOS: * `vim $HOME/.bash_profile` * `PATH=$PATH:$HOME/.local/bin:$HOME/bin` becomes `PATH=$HOME/eccs2/eccs2venv/bin:$HOME/.local/bin:$HOME/bin:$PATH` - * `source $HOME/.bash_profile` * Debian: * `vim $HOME/.profile` * `PATH="$HOME/bin:$PATH"` becomes `PATH="$HOME/eccs2/eccs2venv/bin:$HOME/bin:$PATH"` - * `source $HOME/.bash_profile` 3. Configure ECCS2 cron job for the local user: * `crontab -e` diff --git a/cleanAndRunEccs2.sh b/cleanAndRunEccs2.sh index a7b7455..29db4bb 100755 --- a/cleanAndRunEccs2.sh +++ b/cleanAndRunEccs2.sh @@ -4,6 +4,8 @@ BASEDIR=$HOME +source $HOME/.bash_profile + # Remove old IdP and Fed List rm -f $BASEDIR/eccs2/input/*.json @@ -21,44 +23,48 @@ suffix="'" eccs2output="$BASEDIR/eccs2/output/eccs2_$date.log" declare -a eccs2cmdToRemoveArray -if [ -s $file ]; then +if [ -s $eccsoutput ]; then + if [ -s $file ]; then - while IFS= read -r line - do - string=$line + while IFS= read -r line + do + string=$line - #remove "prefix" from the command string at the beginning. - prefix_removed_string=${string/#$prefix} + #remove "prefix" from the command string at the beginning. + prefix_removed_string=${string/#$prefix} - #remove "suffix" from the command string at the end. - suffix_removed_string=${prefix_removed_string/%$suffix} + #remove "suffix" from the command string at the end. + suffix_removed_string=${prefix_removed_string/%$suffix} - entityIDidp=$(echo "$suffix_removed_string" | jq '.entityID') + entityIDidp=$(echo "$suffix_removed_string" | jq '.entityID') - #remove start and end quotes from the entityIDidp to be able to use "grep" - entityIDidp="${entityIDidp:1}" - entityIDidp="${entityIDidp%?}" + #remove start and end quotes from the entityIDidp to be able to use "grep" + entityIDidp="${entityIDidp:1}" + entityIDidp="${entityIDidp%?}" - result=$(grep $entityIDidp $eccs2output | wc -l) + result=$(grep $entityIDidp $eccs2output | wc -l) - if [[ "$result" = 1 ]]; then - eccs2cmdToRemoveArray+=("$entityIDidp") - else - echo "The result for the IdP '$entityIDidp' has been found multiple times on $eccs2output. It is wrong." - fi + if [[ "$result" = 1 ]]; then + eccs2cmdToRemoveArray+=("$entityIDidp") + else + echo "The result for the IdP '$entityIDidp' has been found multiple times on $eccs2output. It is wrong." + fi - done <"$file" + done <"$file" - # Remove IdP command that had success from "failed-cmd.sh" - for idpToRemove in ${eccs2cmdToRemoveArray[@]} - do - $(grep -v $idpToRemove $file > temp ; mv -f temp $file) - done -fi + # Remove IdP command that had success from "failed-cmd.sh" + for idpToRemove in ${eccs2cmdToRemoveArray[@]} + do + $(grep -v $idpToRemove $file > temp ; mv -f temp $file) + done -if [ -s $file ]; then - echo "$date - ECCS2 NOT OK: Some eduGAIN IdPs have remained unchecked. See the 'logs/failed-cmd.sh' and logs/stderr_$date.log files" + if [ -s $file ]; then + echo "$date - ECCS2 NOT OK: Some eduGAIN IdPs have remained unchecked. See the 'logs/failed-cmd.sh' and logs/stderr_$date.log files" + else + echo "$date - ECCS2 OK: All eduGAIN IdPs have been checked successfully" + fi + fi else - echo "$date - ECCS2 OK: All eduGAIN IdPs have been checked successfully" + echo "$date - Something went wrong and the ECCS2 check has not been executed" fi -- GitLab