-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathacd_verify.sh
executable file
·60 lines (50 loc) · 1.4 KB
/
acd_verify.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/bin/bash
if [ $# -ne 1 ]
then
echo "usage: ./acd_verify.sh LOCAL_FILE"
exit
fi
FILE=$1
if [ ! -f $FILE ]; then
echo "File "$FILE" not found!"
exit
fi
FILENAME=$(echo $FILE | rev | cut -d'/' -f1 | rev)
#TMP="/tmp/verifyACD-"$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 6 | head -n 1)
LOG="/var/log/acd_verify.log"
ERRORLOG="/var/log/acd_verify_error.log"
echo $(date) >> $LOG
echo "local file:" >> $LOG
echo $FILE >> $LOG
echo "REMOTE: Looking for filename "$FILENAME"..."
RESULT=''
RESULT=$(acd_cli find $FILENAME)
if [ "$RESULT" ]; then
echo "FILENAME CHECK: [OK]" >> $LOG
echo "REMOTE: filename found."
echo "matching file(s): "$RESULT >> $LOG
else
echo "FILENAME CHECK: [FAILED]" >> $LOG
echo "REMOTE: filename not found. Leaving."
echo -e $(date)"\tFilename not found:\t"$FILE >> $ERRORLOG
echo "---" >> $LOG
exit
fi
echo "LOCAL: Calculating MD5 sum of "$FILENAME". Might take a while..."
SUM=$(md5sum $FILE | cut -f1 -d' ')
echo "REMOTE: searching for MD5 "$SUM"..."
RESULT=''
RESULT=$(acd_cli find-md5 $SUM)
if [ "$RESULT" ]; then
echo "MD5 CHECK: [OK]" >> $LOG
echo "REMOTE: md5 sum found."
echo "matching file(s): "$RESULT >> $LOG
else
echo "MD5 CHECK: [FAILED]" >> $LOG
echo "REMOTE: md5 sum not found. Leaving."
echo -e $(date)"\tmd5 sum not found:\t"$FILE >> $ERRORLOG
echo "---" >> $LOG
exit
fi
echo "---" >> $LOG
echo "Looks good. Results written to: "$LOG