diff --git a/README.md b/README.md index 29c4b63ea6d1acb6f5fc05b7533695a46bf960ad..1a30f72f3f67c8b153a5b46db2eec7ce1bb70f15 100644 --- a/README.md +++ b/README.md @@ -191,6 +191,8 @@ Note: Pay attetion on the chromedriver version: * `crontab -e` ```bash + SHELL=/bin/bash + 0 4 * * * /bin/bash $HOME/eccs2/cleanAndRunEccs2.sh > $HOME/eccs2/logs/eccs2cron.log 2>&1 ``` diff --git a/cleanAndRunEccs2.sh b/cleanAndRunEccs2.sh index 716d3b063dc4c34193e0114bd5166a1271a834b4..9026204fc383cc489909faca0242221aac956a9a 100755 --- a/cleanAndRunEccs2.sh +++ b/cleanAndRunEccs2.sh @@ -1,14 +1,16 @@ #!/bin/bash +source $HOME/.bash_profile + # logs/stderr_$date.log is kept to see which IdP had been errors BASEDIR=$HOME # Remove old IdP and Fed List -rm -f $BASEDIR/eccs2/input/*.json +#rm -f $BASEDIR/eccs2/input/*.json # Run ECCS2 -$BASEDIR/eccs2/runEccs2.py +#$BASEDIR/eccs2/runEccs2.py # Run Failed Command again bash $BASEDIR/eccs2/logs/failed-cmd.sh @@ -21,34 +23,44 @@ suffix="'" eccs2output="$BASEDIR/eccs2/output/eccs2_$date.log" declare -a eccs2cmdToRemoveArray -while IFS= read -r line -do - string=$line +if [ -s $file ]; then + + 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 - -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 + 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" + + + # 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 + +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