Skip to content
Snippets Groups Projects

6877 final status in log

Merged Hahn Axel (hahn) requested to merge 6877_final_status_in_log into master
1 file
+ 64
0
Compare changes
  • Side-by-side
  • Inline
+ 64
0
#!/usr/bin/env bash
# ======================================================================
#
# DEPLOYMENT CLIENT :: CHECK STATUS
#
# ----------------------------------------------------------------------
# 2023-12-11 v0.1 <axel.hahn@iml.unibe.ch> first lines...
# ======================================================================
# ----------------------------------------------------------------------
# CONFIG
# ----------------------------------------------------------------------
cd $( dirname $0 )
selfdir=$( /bin/pwd )
logdir=/var/log/imldeployment-client
tmpfile=/tmp/deploystatus.log
typeset -i iErrors=0
typeset -i iCount=0
# ----------------------------------------------------------------------
# FUNCTIONS
# ----------------------------------------------------------------------
# get a list profiles by searching a config.sh
# no param
function getprofiles(){
find ${selfdir}/profiles/ -name "config.sh" | rev | cut -f 2 -d "/" | rev
}
# ----------------------------------------------------------------------
# MAIN
# ----------------------------------------------------------------------
for myprofile in $( getprofiles )
do
iCount+=1
logfile=$( ls -tr1 ${logdir}/${myprofile}__* | tail -1 )
lastline=$( tail -1 ${logfile} )
if grep "^OK:" <<< $lastline >/dev/null; then
echo "OK: $myprofile - $logfile"
else
iErrors+=1
echo "ERROR: $myprofile - $logfile"
echo " Last lines:"
tail -10 "${logfile}" | sed "s#^# #g"
echo
fi
done > "$tmpfile"
if [ $iCount -eq 0 ]; then
echo "Deployment No profile was created yet."
else
if [ $iErrors -eq 0 ]; then
echo -n "OK"
else
echo -n "ERROR"
fi
echo " Deployment ... Profiles: $iCount ... Errors: $iErrors"
cat "$tmpfile"
fi
rm -f "$tmpfile"
exit $iErrors
# ----------------------------------------------------------------------
Loading