Commit 9e43d640 authored by Marco Malavolti's avatar Marco Malavolti
Browse files

Fixed CRON job & log

parent 9ec9cbb3
......@@ -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
```
......
#!/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
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment