-
Notifications
You must be signed in to change notification settings - Fork 6
/
check-old.sh
executable file
·47 lines (31 loc) · 976 Bytes
/
check-old.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
#!/bin/bash
address=$1
days_cutoff=180
timeout=5
response=$(curl -m $timeout --write-out %{http_code} --silent --output /dev/null http://$address)
if [ $response != "200" ]; then
address=$(curl -m $timeout --write-out %{url_effective} --silent --output /dev/null -L http://$address)
fi
exec `curl -m $timeout -I --silent $address > temp.txt`
modified_date=`grep -E "^Last-Modified:" temp.txt | sed -r 's/^(Last-Modified): (.*)/\2/g'`
date=`grep -E "^Date:" temp.txt | sed -r 's/^(Date): (.*)/\2/g'`
today=`date`
if [ "$modified_date" != "" ]; then
start=`date +%s -d "$modified_date"`
end=`date +%s -d "$today"`
diff_modified=$(( ( $end - $start ) / 86400 ))
else
diff_modified=0
fi
if [ "$date" != "" ]; then
start=`date +%s -d "$date"`
end=`date +%s -d "$today"`
diff_date=$(( ( $end - $start ) / 86400 ))
else
diff_date=0
fi
if [ "$diff_modified" -gt "$days_cutoff" ] || [ "$diff_date" -gt "$days_cutoff" ]; then
echo "1"
else
echo "0"
fi