-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmd5-web-check-up.sh
More file actions
executable file
·66 lines (55 loc) · 1.58 KB
/
md5-web-check-up.sh
File metadata and controls
executable file
·66 lines (55 loc) · 1.58 KB
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
61
62
63
64
65
66
#!/bin/bash
source "$(dirname "$0")/md5-web-variables.sh"
source "$(dirname "$0")/md5-web-mail.sh"
echo
echo "--- MD5 fingerprint ---"
echo
# No cache
for ((i = 0 ; i < "${#URL[@]}"; i++)); do
if [ ! -f check${i}.md5 ]; then
curl --silent ${URL[i]} | md5sum > check${i}.md5
echo -e "Creating a new fingerprint for ${URL[i]}"
else
echo -e "Nothing to do"
fi
done
# With cache
for ((i = 0 ; i < "${#URLC[@]}"; i++)); do
if [ ! -f checkcache${i}.md5 ]; then
curl --silent ${URLC[i]} | md5sum > checkcache${i}.md5
echo -e "Creating a new fingerprint for ${URLC[i]}"
else
echo -e "Nothing to do"
fi
done
echo
echo "--- MD5 Check ---"
echo
# No cache
for ((i = 0 ; i < "${#URL[@]}"; i++)); do
curl --silent "${URL[i]}?$(date +%s)" | md5sum > check${i}.md5new
if ! cmp check${i}.md5 check${i}.md5new > /dev/null; then
for ((c = 0 ; c < "${#MAIL[@]}"; c++)); do
echo "Go check ${URL[i]}" | mail -s "Change detected - MD5 Check " ${MAIL[c]}
done
echo -e "Go check ${URL[i]}"
mv check${i}.md5new check${i}.md5
else
echo -e "No changes detected in ${URL[i]}"
rm check${i}.md5new
fi
done
# With cache
for ((i = 0 ; i < "${#URLC[@]}"; i++)); do
curl --silent "${URLC[i]}" | md5sum > checkcache${i}.md5new
if ! cmp checkcache${i}.md5 checkcache${i}.md5new > /dev/null; then
for ((c = 0 ; c < "${#MAIL[@]}"; c++)); do
echo "Go check ${URLC[i]}" | mail -s "Change detected - MD5 Check " ${MAIL[c]}
done
echo -e "Go check ${URLC[i]}"
mv checkcache${i}.md5new checkcache${i}.md5
else
echo -e "No changes detected in ${URLC[i]}"
rm checkcache${i}.md5new
fi
done