diff --git a/README.md b/README.md index dcacb629f78f191aa5805ef4a283c64cdc13e536..dfbe1239fcab2a8f9e16600d2bd69ec9790e4257 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 a7b74555b95ff9a9e23cb8cd914452d4856bf18a..29db4bb3b0e5ea31dda007f8c61232f900c63f3f 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