+# usage:
+# alertme SUBJECT
+# printf "subject\nbody\n" | alertme
+alertme() {
+ if [[ -t 0 ]]; then
+ exim -t <<EOF
+From: alertme@b8.nz
+To: alerts@iankelling.org
+Subject: $*
+EOF
+ else
+ read sub
+ { cat <<EOF
+From: alertme@b8.nz
+To: alerts@iankelling.org
+Subject: $sub
+
+EOF
+ cat
+ } | exim -t
+ fi
+}
+daylertme() {
+ if [[ -t 0 ]]; then
+ exim -t <<EOF
+From: alertme@b8.nz
+To: daylert@iankelling.org
+Subject: $*
+EOF
+ else
+ read sub
+ { cat <<EOF
+From: alertme@b8.nz
+To: daylert@iankelling.org
+Subject: $sub
+
+EOF
+ cat
+ } | exim -t
+ fi
+}
+
+# alert when a page goes live. not urgent.
+alert200() {
+ url="$1"
+ tmpdir="$(mktemp -d)"
+ cd $tmpdir
+ while true; do
+ if torsocks wget -q "$url"; then
+ alertme $tmpdir
+ fi
+ sleep $(( 600 + RANDOM % 300 ))
+ done
+}
+
+# alert on changes to a webpage (just the base page that curl gets)
+# usage: weblert URL [SUBJECT...]
+weblert() {
+ local u old new quiet
+ quiet=false
+ case $1 in
+ # dont send a diff of the html. some html is not very readable
+ -q) quiet=true
+ shift
+ ;;
+ esac
+ u="$1"
+ shift
+ subject="${*:-weblert}"
+ old=$(curl -s "$u") ||:
+ while true; do
+ new=$(curl -s "$u") ||:
+ if [[ $old && $new ]]; then
+ if [[ $new != "$old" ]]; then
+ if $quiet; then
+ echo | daylertme "$subject"
+ else
+ diff <(printf "%s\n" "$old") <(printf "%s\n" "$new") | daylertme "$subject" ||:
+ fi
+ fi
+ old="$new"
+ fi
+ sleep $(( 60 + RANDOM % 120 ))
+ done
+}
+
+torshell() {
+ # per man torsocks
+ source `type -p torsocks` on
+}
+
+eless2() {
+ less /var/log/exim4/mymain
+}
+
+