From 4cb7ece4bef8563c616bc70852995f410359432a Mon Sep 17 00:00:00 2001 From: Sancho Lerena Date: Wed, 24 Sep 2014 19:46:43 +0200 Subject: [PATCH] Updated integrity check: added option to compare two integrity files. --- pandora_server/util/integrity_check | 64 +++++++++++++++++++++++++++-- 1 file changed, 61 insertions(+), 3 deletions(-) diff --git a/pandora_server/util/integrity_check b/pandora_server/util/integrity_check index 0d89a80f51..eb52c949f7 100755 --- a/pandora_server/util/integrity_check +++ b/pandora_server/util/integrity_check @@ -19,9 +19,9 @@ if [ $# -lt 2 ] then echo "Syntax:" echo " " - echo "integrity_chech new|check [" + echo "integrity_chech new|check|compare [] [] []" echo " " - echo " If mode 'check' is selected, it will require a integrity file (generated by this tool) to check it against current setup" + echo " If mode 'check' is selected, it will require a integrity file (generated by this tool) to check it against current setup. If mode 'compare' is selected, it wil require two integrity files, and will report differences between them" echo " " exit -1 fi @@ -32,12 +32,70 @@ INTEGRITY_REPORT=$INTEGRITY_FILE.report MODE=$1 ERROR=0 -if [ ! -d "$CONSOLE_PATH" ] +if [ ! -d "$CONSOLE_PATH" ] && [ "$MODE" != "compare" ] then echo "Error: Console path doesn't exist" exit -1 fi +if [ "$MODE" == "compare" ] +then + FILE1=$2 + FILE2=$3 + + if [ ! -f "$FILE1" ] || [ ! -f "$FILE2" ] + then + echo "Error, at least one of the integrity files provided not found" + exit -1 + fi + + IFS=" +" + COUNTER=0 + for a in `cat $FILE1 | grep -v "^#"` + do + if [ $COUNTER -eq 0 ] + then + echo -ne "\b|" + fi + + if [ $COUNTER -eq 1 ] + then + echo -ne "\b/" + fi + + if [ $COUNTER -eq 2 ] + then + echo -ne "\b-" + fi + if [ $COUNTER -eq 3 ] + then + echo -ne "\b\\" + COUNTER=-1 + fi + + COUNTER=`expr $COUNTER + 1` + + F1=`echo $a | awk '{ print $2 }'` + M1=`echo $a | awk '{ print $1 }'` + + BUF=`cat $FILE2 | grep "$F1\$"` + if [ -z "$BUF" ] + then + echo " " + echo "[MISS] $F1 is not present in $FILE2" + else + M2=`echo $BUF | awk '{ print $1 }'` + if [ "$M2" != "$M1" ] + then + echo " " + echo "[DIFF] $F1 has changed" + fi + fi + done + +fi + if [ "$MODE" == "check" ] then if [ ! -f "$INTEGRITY_FILE" ]