#!/bin/bash
#To install mixmaster as a Tails user create the directory /home/amnesia/.Mix/
mkdir /home/amnesia/.Mix/
#and populate it with a file called 
#"mix.cfg" that contains the line "SMTPRELAY	gbhpq7eihle4btsn.onion"
echo "SMTPRELAY	gbhpq7eihle4btsn.onion" > /home/amnesia/.Mix/mix.cfg
#and also with a file called
#"update.conf" that contains the lines "SOURCE	noreply" and "DESTINATION /home/amnesia/.Mix/"
echo "SOURCE	noreply" > /home/amnesia/.Mix/update.conf
echo "DESTINATION	/home/amnesia/.Mix/" >> /home/amnesia/.Mix/update.conf
# and note that the Tails "dotfiles" feature can be used to make these files persistent.
#
#Then continue the installation by running the following commands as root, then as root torified, and finally as amnesia:
sudo apt-get update 
sudo apt-get install mixmaster 
sudo torify mixmaster-update --verbose 
mixmaster --verbose --update-pinger-list
#and note that the Tails "APT Packages" and "APT Lists" features can make the results of the first apt-get command persistent

#After installation, you should keep running the following command at least once in every ~24 hour window that preceds every email you send through the mix network (so you might want to just automatically run it every time you boot tails):
mixmaster-update

#Finally, to send high latency emails from the command line you can use something like this (which, after instant submission to a randomly selected three hop circuit of the mix network and a couple days of random delay, delivers an email whose body says "stop spying on us" to the president, yay!):
echo "stop spying on us" | mixmaster --copies=1 --chain=*,*,* --to=president@whitehouse.gov 
#...or use the interactive mode by simply running "mixmaster" alone

#Note: a header of "From: amnesia@amnesia" is leaked to the tor hidden service SMTP relay (gbhpq7eihle4btsn.onion) and to the first node in the mixmaster circuit, but does not propagate past this initial injection into the mix network nor out of the mix network to the clearnet nor to the final email recipient. I believe some text needs to go here, so it's not a question of plugging the leak as much as whether some other "user@host" string would be better than "amnesia@amnesia" or not. 

#Note to developers: The complexity of the installation is because the restrictions placed by Tails break the configuration steps performed by the package installer, but I think the package installer would work as intended if installed before the live system is frozen. In this case the only thing needed to supplement the standard package installer is to create the mix.cfg file as described and place it in /etc/mixmaster/ (instead of /home/amnesia/.Mix/) as follows
#sudo echo "SMTPRELAY	gbhpq7eihle4btsn.onion" > /etc/mixmaster/
