3 # Description: Tells you which websites have changed since last run/mirroring.
6 OLD
=$
(tput setaf
1) # red
7 SAMELINE
=$
(tput setaf
4) # blue
8 NEW
=$
(tput setaf
2) # green
10 INFO
=$
(tput setaf
3) #yellow
11 NORMAL
=$
(tput setaf
7) #gray
13 #how wide is your terminal or how much text in width would you like to include in the output? see echo $COLUMNS for how many letters you can show on one line, it doesn't work inside a script for some reason..
16 # $colour{cyan} = "\033[1;36m";
17 # $colour{red} = "\033[1;31m";
19 function _show_help
() {
20 echo -e "\nupdcheck 0.7.1\n\nusage: updcheck [--no-colors] [-h|--help] \n\nTells you which webpages of the ones in \`${HOME}/.updcheck/urls' have changed since last mirroring. The first time you run with a new entry it will mirror the entry, the second time it will check for differences, and tell you if it finds any discrepancies.\n\n --no-colors Turn off colors\n"
24 if [ "$1" = "-h" -o "$1" = "--help" ]
30 #git diff --color x y...
31 diff -w -W $TERMWIDTH -y --suppress-common-lines mirrors
/$_url2 $_url2|
sed "s#\(.*|.*\)#`echo $SAMELINE`&#"|
sed "s#\(.*>.*\)#`echo $NEW`&#"|
sed "s#\(.*<.*\)#`echo $OLD`&#"
32 if [ $PIPESTATUS -eq 1 ]
34 echo $INFO && echo -n $_url2|
sed 's|,|/|g' && echo " have updated." && echo $NORMAL
36 # mv new copy over the old one
40 function _diff_no_colors
() {
41 diff -w -W $TERMWIDTH -y --suppress-common-lines mirrors
/${_url2} ${_url2}
44 echo "`echo $_url2|sed 's|,|/|g'` have updated."
46 # mv new copy over the old one
50 # create needed directories upon first run
51 if [ ! -d "${HOME}/.updcheck/mirrors" ]
53 mkdir
-p ${HOME}/.updcheck
/mirrors
54 touch ${HOME}/.updcheck
/urls
55 echo "Creating ´~/.updcheck/mirrors...urls. Fill in ´~/.updcheck/urls´"
56 echo -e "# Works best with pages that doesn't look different\n# each time you refresh it(because of ads, a clock/date script etc)\n# but perhaps the download page or the news page for example.\n# Example:\n# http://en.wikipedia.org/wiki/Linux\n# " > ${HOME}/.updcheck
/urls
59 # cd into standard dir
62 #start file-reading loop
64 # set _url to use , instead of / for processing
65 _url2
=`echo ${_url}|sed 's|/|,|g'`
66 elinks
-dump -no-numbering -no-references -no-connect 0 -no-home 1 "${_url}" > "$_url2"
68 #is it already mirrored? in that case diff it against the new file!
69 if [ -f mirrors
/${_url2} -a -f ${_url2} ]
71 if [ "$1" = "--no-colors" ]
79 #mirror doesn't exist. create mirror
80 if [ ! -f mirrors
/${_url2} ];
83 if [ "$1" = "--no-colors" ]
85 echo "Making mirror of" `echo $_url2|sed 's|,|/|g'`
87 echo $INFO && echo "Making mirror of $_url2"|
sed 's|,|/|g' && echo $NORMAL
90 done < <(egrep -v "^$|#" urls
)