]> pere.pagekite.me Git - exim4-smtorp.git/blob - setup-exim-hidden-service
Merge pull request #1 from bashrc/master
[exim4-smtorp.git] / setup-exim-hidden-service
1 #!/bin/sh
2 #
3 # Configure a machine without exim installed as a mail server receiving
4 # email using SMTP via Tor.
5
6 if dpkg -l exim4-config > /dev/null ; then
7 echo "******************************************************************"
8 echo "* Unable to set up SMTP over Tor, exim4-config already installed *"
9 echo "* Purge the package and try again, or *"
10 echo "* run "dpkg-reconfigure exim4-config" to configure manually. *"
11 echo "******************************************************************"
12 exit 1
13 fi
14
15 DEBIAN_FRONTEND=noninteractive apt-get install -y tor
16 torhsdir=$(awk '/^HiddenServiceDir (.*) *$/ { print $2 }' /etc/tor/torrc)
17 if [ -e "$torhsdir/hostname" ] ; then
18 torhsname=$(cat "$torhsdir/hostname")
19 else
20 echo "*******************************************************************"
21 echo "* Unable to set up SMTP over TOR. There is no Tor hidden service *"
22 echo "* name in $torhsdir *"
23 echo "*******************************************************************"
24 echo "Please add lines like this to /etc/tor/torrc:"
25 echo
26 echo "HiddenServiceDir /var/lib/tor/hidden_service/"
27 echo "HiddenServicePort 25 127.0.0.1:25"
28 mkdir /var/lib/tor/hidden_service
29 chown debian-tor:debian-tor /var/lib/tor/hidden_service
30 exit 1
31 fi
32
33 cat <<EOF | debconf-set-selections
34 exim4-config exim4/dc_eximconfig_configtype select internet site; mail is sent and received directly using SMTP
35 exim4-config exim4/dc_local_interfaces string 127.0.0.1 ; ::1
36 exim4-config exim4/dc_other_hostnames string $torhsname
37 exim4-config exim4/use_split_config boolean true
38 EOF
39
40 DEBIAN_FRONTEND=noninteractive apt-get install -y exim4