forked from GabrielaBezerra/CheckForChanges
-
Notifications
You must be signed in to change notification settings - Fork 0
/
check-for-changes
executable file
·119 lines (93 loc) · 2.43 KB
/
check-for-changes
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#!/bin/bash
if [[ "$OSTYPE" == "darwin"* ]]; then
if ! command -v say &> /dev/null
then
echo "say could not be found, make sure it is installed and try again."
exit
fi
elif [[ "$OSTYPE" == "linux-gnu"* ]]; then
if ! command -v espeak &> /dev/null
then
echo "espeak could not be found, make sure it is installed and try again."
exit
fi
fi
if [[ -z $1 || -z $2 ]]; then
echo " usage: ./check \"<url>\" \"<message>\" [interval]"
else
clear;
chmod +x .
sleep 0.2
./banner.sh
sleep 0.3
while [ : ]
do
echo -ne "\n Check for changes" '|\r'
sleep 0.4
echo -ne "cHeck for changes" '/\r'
sleep 0.4
echo -ne "chEck for changes" '一\r'
sleep 0.4
echo -ne "cheCk for changes" '\\ \r'
sleep 0.4
echo -ne "checK for changes" '|\r'
sleep 0.4
echo -ne "check For changes" '$\r'
sleep 0.4
echo -ne "check fOr changes" '|\r'
sleep 0.3
echo -ne "cHeck foR changes" '/\r'
sleep 0.3
echo -ne "check for Changes" '一\r'
sleep 0.3
echo -ne "check for cHanges" '\\ \r'
sleep 0.3
echo -ne "check for chAnges" '|\r'
sleep 0.3
echo -ne "check For chaNges" '$\r'
sleep 0.3
echo -ne "check for chanGes" '|\r'
sleep 0.3
echo -ne "check for changEs" '/\r'
sleep 0.3
echo -ne "check for ChangeS" '一\r\n'
sleep 0.3
break;
done
interval=10
if [ ! -z $3 ]; then
interval=$3
fi
if [ -f /tmp/previous.html ]; then
rm /tmp/previous.html
fi
while :
do
current=`curl $1 2> /dev/null`;
if [ ! -f /tmp/previous.html ]; then
echo -e "\n Writing in /tmp/previous.html";
mkdir -p "`dirname \"/tmp/previous.html\"`" 2>/dev/null
echo "$current" >> "/tmp/previous.html"
fi
previous="`cat /tmp/previous.html`";
current_count=`echo -e "$current" | wc -l`
previous_count=`echo -e "$previous" | wc -l`
echo -e "\t$current_count vs. $previous_count" ;
if [ "$previous_count" = "$current_count" ]; then
echo -e "\n****************************************\n$(date)\nNothing New...\n****************************************\n"
sleep $interval
clear;
./banner.sh
echo -e "\n"
else
echo -e "\n****************************************\n$(date)\nNew Content!\n****************************************\n"
if [[ "$OSTYPE" == "darwin"* ]]; then
say $2;
elif [[ "$OSTYPE" == "linux-gnu"* ]]; then
espeak $2;
fi
break;
fi
done
fi
rm /tmp/previous.html;