Skip to content

Instantly share code, notes, and snippets.

@OilSlick
Last active August 29, 2015 13:56
Show Gist options
  • Select an option

  • Save OilSlick/9180220 to your computer and use it in GitHub Desktop.

Select an option

Save OilSlick/9180220 to your computer and use it in GitHub Desktop.
Bash shell script for updating keyrings and reliability statistics for Mixmaster client on OS X
http://anonusa.net/echolot/
http://pinger.mixmin.net
http://www.tahina.priv.at/~cm/stats/
http://www.hermetix.org/echolot/
http://www.deuxpi.ca/echolot/
http://www.eurovibes.org/echolot/
http://echolot.theremailer.net/
http://pinger.mixmin.net/
http://www.noreply.org/echolot/
http://senshiweb.webhop.net/
#!/bin/sh
###################################################
# update-mix.sh by Michael Wright #
# Updated: 2/22/14 #
# #
# Set the following variables to your environment #
###################################################
# PRIVOXY_OPTION should be either true or false
# Setting it to false means you don't want the option to use privoxy + tor
PRIVOXY_OPTION=true
PROXY="http://localhost:8118"
# Don't add trailing slashes (/) to the end of the paths
PRIVOXY_PATH="/usr/local/Cellar/privoxy/3.0.21/sbin"
PRIVOXY_CONFIG_PATH="/usr/local/etc/privoxy"
MIX_DIR="/Users/jschmoe/mix"
# No changes need to be made beyond this point
# enable font colorization
# per http://stackoverflow.com/questions/1085432/how-do-you-automatically-colorize-program-outputs-in-a-bash-shell
red=$(tput setaf 1)
green=$(tput setaf 2)
reset=$(tput op)
cd $MIX_DIR
if [ "$PRIVOXY_OPTION" == "true" ]; then
while true; do
read -p "Do you want to run Privoxy? Y or N " yn
case $yn in
[Yy]* ) USEPRIVOXY=1;break;;
[Nn]* ) USEPRIVOXY=0;break;;
* ) USEPRIVOX=1;break;;
esac
done
#launch tor + privoxy
if [ "$USEPRIVOXY" == 1 ]; then
export http_proxy=$PROXY
echo "Launching TOR..."
open -g -a TorBrowser
sleep 5s
echo "Launching Privoxy...sudo password required"
sudo $PRIVOXY_PATH/privoxy $PRIVOXY_CONFIG_PATH/config
wget www.google.com
if [ -f index.html ]; then
echo "Connection established. Let's do this!"
rm index.html
else
echo "${red}Error${reset} Can't connect to the intarwebs. Bailing."
exit 1
fi
fi
fi
#if no URL is provided, grab one from pingers.txt
if [ ! -f ./pingers.txt ]; then
echo "${red}ERROR${reset}"
echo "Can't locate pingers.txt in the local directory."
echo "You must either provide a pinger URL as a command argument such as "./update-mix.sh http://pinger.mixmin.net" or have a populated pinger.txt"
echo "You may find some live pingers on this dated list (if it still exists): http://www.noreply.org/allpingers/allpingers.txt"
exit 1
fi
if [ -z $1 ]; then
FIRST=$(head -$((${RANDOM} % `wc -l < ./pingers.txt` + 1)) ./pingers.txt | tail -1)
else
FIRST="$1"
fi
SECOND=$(head -$((${RANDOM} % `wc -l < ./pingers.txt` + 1)) ./pingers.txt | tail -1)
if [ "$FIRST" == "$SECOND" ]; then
SECOND=$(head -$((${RANDOM} % `wc -l < ./pingers.txt` + 1)) ./pingers.txt | tail -1)
fi
# if at first you don't succeed, warn and try again
TRYAGAIN () {
wget -q $SECOND/$2
if [ -f "./$2" ]; then
echo "$2 ${green}OK${reset}"
else
echo "$2 ${red}FAIL${reset}"
echo "Terminating script"
echo "Check here for updated pingers: http://www.palfrader.org/echolot/"
echo "Also check here: http://www.noreply.org/allpingers/allpingers.txt"
exit
fi
}
VERIFY () {
if [ -f "./$1" ]; then
echo "$1 ${green}OK${reset}"
else
echo "$1 ${red}FAILED${reset}"
echo "Trying second pinger: $SECOND"
TRYAGAIN $SECOND $1
fi
}
clear
echo "Trying $FIRST....."
echo ""
if [ -f rlist.txt ]; then
mv -f rlist.txt rlist.txt.old
fi
wget -q $FIRST/rlist.txt
VERIFY rlist.txt
if [ -f pubring.mix ]; then
mv -f pubring.mix pubring.mix.old
fi
wget -q $FIRST/pubring.mix
VERIFY pubring.mix
if [ -f type2.list ]; then
mv -f type2.list type2.list.old
fi
wget -q $FIRST/type2.list
VERIFY type2.list
if [ -f pubring.asc ]; then
mv -f pubring.asc pubring.asc.old
fi
wget -q $FIRST/pgp-all.asc
VERIFY pgp-all.asc
mv -f pgp-all.asc pubring.asc
if [ -f mlist.txt ]; then
mv -f mlist.txt mlist.txt.old
fi
wget -q $FIRST/mlist.txt
VERIFY mlist.txt
egrep 'Last update' ./mlist.txt
echo ""
echo "Happy mixing"
echo ""
echo "./mix --mail --to=recipient@domain.com --copies=X --subject='YOUR SUBJECT'"
echo "Enter the message, complete with headers"
echo "When done, press ^D"
echo ""
echo ""
echo "Alternatively, you can compose your message into a file then use the following:"
echo "./mix -tm recipient@domain.com /path/to/file"
echo "When done, pres ^d (command + d)"
if [ "$USEPRIVOXY" == 1 ] && [ "$PRIVOXY_OPTION" == "true"]; then
echo "Killing Privoxy"
sudo killall privoxy
unset http_proxy
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment