#!/bin/bash
#Run this script after configuring a tails persistent volume with dotfiles, APT Packages, and APT Lists enabled. 

#To install mixmaster as a Tails user create the directory /home/amnesia/.Mix/
rm -r /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 copy these files to make them persistent.
cp -r /home/amnesia/.Mix/ /live/persistence/TailsData_unlocked/dotfiles/.Mix/

#
#Then continue the installation by running the following commands as root
sudo sh -c "apt-get update ; apt-get install mixmaster ;"

#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/

