forked from ISTI-ansible-roles/ansible-roles
More fixes to the algorithms updater script.
This commit is contained in:
parent
cc74bb44f1
commit
f2196b3cf9
|
@ -87,10 +87,10 @@ function algorithms_updater() {
|
||||||
ALGO_NAME=$( echo "$algo" | awk -F \| '{ print $1 }' )
|
ALGO_NAME=$( echo "$algo" | awk -F \| '{ print $1 }' )
|
||||||
ALGO_BODY=$( echo "$algo" | awk -F \| '{ print $2 }' )
|
ALGO_BODY=$( echo "$algo" | awk -F \| '{ print $2 }' )
|
||||||
ALGO_DATE=$( echo "$algo" | awk -F \| '{ print $3 }' )
|
ALGO_DATE=$( echo "$algo" | awk -F \| '{ print $3 }' )
|
||||||
ALGO_TIMESTAMP=$( date +%s -d "$ALGO_DATE" )
|
ALGO_TIMESTAMP=$( date +%s -d "$ALGO_DATE" 2>/dev/null )
|
||||||
if [ $? -ne 0 ] ; then
|
if [ $? -ne 0 ] ; then
|
||||||
echo "the date for algorithm $ALGO_NAME is wrong"
|
echo "the date for algorithm $ALGO_NAME is wrong"
|
||||||
fi
|
else
|
||||||
ALGO_LINE=$( egrep ^"$ALGO_NAME" $ALGORITHMS_INSTALLED_FILE )
|
ALGO_LINE=$( egrep ^"$ALGO_NAME" $ALGORITHMS_INSTALLED_FILE )
|
||||||
ALGO_PRESENT=$?
|
ALGO_PRESENT=$?
|
||||||
if [ $ALGO_PRESENT -ne 0 ] ; then
|
if [ $ALGO_PRESENT -ne 0 ] ; then
|
||||||
|
@ -110,17 +110,17 @@ function algorithms_updater() {
|
||||||
echo 'if [ $RETVAL -ne 0 ] ; then' >> $ALGORITHMS_TEMP_SCRIPT.body_
|
echo 'if [ $RETVAL -ne 0 ] ; then' >> $ALGORITHMS_TEMP_SCRIPT.body_
|
||||||
echo " logger 'algorithms-updater: the adding of algorithm $ALGO_NAME failed'" >> $ALGORITHMS_TEMP_SCRIPT.body_
|
echo " logger 'algorithms-updater: the adding of algorithm $ALGO_NAME failed'" >> $ALGORITHMS_TEMP_SCRIPT.body_
|
||||||
echo "else" >> $ALGORITHMS_TEMP_SCRIPT.body_
|
echo "else" >> $ALGORITHMS_TEMP_SCRIPT.body_
|
||||||
echo " echo '$ALGO_NAME | $ALGO_DATE' >> $ALGORITHMS_INSTALLED_FILE" >> $ALGORITHMS_TEMP_SCRIPT.body_
|
echo " echo 'egrep -v ^$ALGO_NAME\ $ALGORITHMS_INSTALLED_FILE > ${ALGORITHMS_INSTALLED_FILE}_ " >> $ALGORITHMS_TEMP_SCRIPT.body_
|
||||||
|
echo " echo 'mv ${ALGORITHMS_INSTALLED_FILE}_ $ALGORITHMS_INSTALLED_FILE" >> $ALGORITHMS_TEMP_SCRIPT.body_
|
||||||
|
echo " echo '$ALGO_NAME | $ALGO_TIMESTAMP' >> $ALGORITHMS_INSTALLED_FILE" >> $ALGORITHMS_TEMP_SCRIPT.body_
|
||||||
echo " logger 'algorithms-updater: the adding of algorithm $ALGO_NAME succeeded'" >> $ALGORITHMS_TEMP_SCRIPT.body_
|
echo " logger 'algorithms-updater: the adding of algorithm $ALGO_NAME succeeded'" >> $ALGORITHMS_TEMP_SCRIPT.body_
|
||||||
echo "fi" >> $ALGORITHMS_TEMP_SCRIPT.body_
|
echo "fi" >> $ALGORITHMS_TEMP_SCRIPT.body_
|
||||||
else
|
else
|
||||||
ALGO_LOCAL_TIMESTAMP=0
|
ALGO_LOCAL_TIMESTAMP=0
|
||||||
ALGO_LOCAL_DATE=$( egrep ^"$ALGO_NAME" $ALGORITHMS_INSTALLED_FILE | awk -F \| '{ print $2 }' | grep -v \' )
|
# ALGO_LOCAL_DATE=$( egrep ^"$ALGO_NAME" $ALGORITHMS_INSTALLED_FILE | awk -F \| '{ print $2 }' | grep -v \' )
|
||||||
ALGO_LOCAL_TIMESTAMP=$( date +%s -d "$ALGO_LOCAL_DATE" )
|
# ALGO_LOCAL_TIMESTAMP=$( date +%s -d "$ALGO_LOCAL_DATE" 2>/dev/null )
|
||||||
if [ $? -ne 0 ] ; then
|
ALGO_LOCAL_TIMESTAMP=$( egrep ^"$ALGO_NAME" $ALGORITHMS_INSTALLED_FILE | tail -1 | awk -F \| '{ print $2 }' | grep -v \' )
|
||||||
echo "the locally saved date for algorithm $ALGO_NAME is wrong"
|
if [ $? -ne 0 ] || [ $ALGO_LOCAL_TIMESTAMP -ne $ALGO_TIMESTAMP ]; then
|
||||||
fi
|
|
||||||
if [ $ALGO_LOCAL_TIMESTAMP -ne $ALGO_TIMESTAMP ] ; then
|
|
||||||
echo "logger 'algorithms-updater: running the add command of algorithm $ALGO_NAME'" >> $ALGORITHMS_TEMP_SCRIPT.body_
|
echo "logger 'algorithms-updater: running the add command of algorithm $ALGO_NAME'" >> $ALGORITHMS_TEMP_SCRIPT.body_
|
||||||
echo "logger 'algorithms-updater: the add command string is $ALGO_BODY'" >> $ALGORITHMS_TEMP_SCRIPT.body_
|
echo "logger 'algorithms-updater: the add command string is $ALGO_BODY'" >> $ALGORITHMS_TEMP_SCRIPT.body_
|
||||||
echo "RETVAL=" >> $ALGORITHMS_TEMP_SCRIPT.body_
|
echo "RETVAL=" >> $ALGORITHMS_TEMP_SCRIPT.body_
|
||||||
|
@ -137,13 +137,14 @@ function algorithms_updater() {
|
||||||
echo 'if [ $RETVAL -ne 0 ] ; then' >> $ALGORITHMS_TEMP_SCRIPT.body_
|
echo 'if [ $RETVAL -ne 0 ] ; then' >> $ALGORITHMS_TEMP_SCRIPT.body_
|
||||||
echo " logger 'algorithms-updater: the adding of algorithm $ALGO_NAME failed'" >> $ALGORITHMS_TEMP_SCRIPT.body_
|
echo " logger 'algorithms-updater: the adding of algorithm $ALGO_NAME failed'" >> $ALGORITHMS_TEMP_SCRIPT.body_
|
||||||
echo "else" >> $ALGORITHMS_TEMP_SCRIPT.body_
|
echo "else" >> $ALGORITHMS_TEMP_SCRIPT.body_
|
||||||
echo " echo 'grep -v $ALGO_NAME $ALGORITHMS_INSTALLED_FILE > ${ALGORITHMS_INSTALLED_FILE}_ " >> $ALGORITHMS_TEMP_SCRIPT.body_
|
echo " echo 'egrep -v ^$ALGO_NAME\ $ALGORITHMS_INSTALLED_FILE > ${ALGORITHMS_INSTALLED_FILE}_ " >> $ALGORITHMS_TEMP_SCRIPT.body_
|
||||||
echo " echo 'mv ${ALGORITHMS_INSTALLED_FILE}_ $ALGORITHMS_INSTALLED_FILE" >> $ALGORITHMS_TEMP_SCRIPT.body_
|
echo " echo 'mv ${ALGORITHMS_INSTALLED_FILE}_ $ALGORITHMS_INSTALLED_FILE" >> $ALGORITHMS_TEMP_SCRIPT.body_
|
||||||
echo " echo '$ALGO_NAME | $ALGO_DATE' >> $ALGORITHMS_INSTALLED_FILE" >> $ALGORITHMS_TEMP_SCRIPT.body_
|
echo " echo '$ALGO_NAME | $ALGO_TIMESTAMP' >> $ALGORITHMS_INSTALLED_FILE" >> $ALGORITHMS_TEMP_SCRIPT.body_
|
||||||
echo " logger 'algorithms-updater: the adding of algorithm $ALGO_NAME succeeded'" >> $ALGORITHMS_TEMP_SCRIPT.body_
|
echo " logger 'algorithms-updater: the adding of algorithm $ALGO_NAME succeeded'" >> $ALGORITHMS_TEMP_SCRIPT.body_
|
||||||
echo "fi" >> $ALGORITHMS_TEMP_SCRIPT.body_
|
echo "fi" >> $ALGORITHMS_TEMP_SCRIPT.body_
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
done < ${ALGORITHMS_TEMP_SCRIPT}.algorithmslist
|
done < ${ALGORITHMS_TEMP_SCRIPT}.algorithmslist
|
||||||
set -o pipefail
|
set -o pipefail
|
||||||
set -e
|
set -e
|
||||||
|
|
Loading…
Reference in New Issue