|
@@ -102,6 +102,8 @@ DDNS_USERNAME=
|
102
|
102
|
DDNS_PASSWORD=
|
103
|
103
|
CURRENT_DDNS_DOMAIN=
|
104
|
104
|
|
|
105
|
+EXIM_ONION_REPO='https://github.com/petterreinholdtsen/exim4-smtorp'
|
|
106
|
+
|
105
|
107
|
NGINX_ENSITE_REPO="https://github.com/perusio/nginx_ensite"
|
106
|
108
|
NGINX_ENSITE_COMMIT='fa4d72ce1c0a490442c8474e9c8dc21ed52c93d0'
|
107
|
109
|
|
|
@@ -309,6 +311,9 @@ XMPP_ECC_CURVE='"secp384r1"'
|
309
|
311
|
# the default email address
|
310
|
312
|
MY_EMAIL_ADDRESS=$MY_USERNAME@$DEFAULT_DOMAIN_NAME
|
311
|
313
|
|
|
314
|
+# port used for SMTP via an onion address
|
|
315
|
+EMAIL_ONION_PORT=8093
|
|
316
|
+
|
312
|
317
|
# optionally specify your name to appear on the blog
|
313
|
318
|
MY_NAME=$DEFAULT_DOMAIN_NAME
|
314
|
319
|
|
|
@@ -3679,10 +3684,8 @@ function configure_dns {
|
3679
|
3684
|
echo 'configure_dns' >> $COMPLETION_FILE
|
3680
|
3685
|
}
|
3681
|
3686
|
|
3682
|
|
-function set_your_domain_name {
|
3683
|
|
- if grep -Fxq "set_your_domain_name" $COMPLETION_FILE; then
|
3684
|
|
- return
|
3685
|
|
- fi
|
|
3687
|
+function set_hostname {
|
|
3688
|
+ DEFAULT_DOMAIN_NAME="$1"
|
3686
|
3689
|
|
3687
|
3690
|
echo "$DEFAULT_DOMAIN_NAME" > /etc/hostname
|
3688
|
3691
|
hostname $DEFAULT_DOMAIN_NAME
|
|
@@ -3692,6 +3695,15 @@ function set_your_domain_name {
|
3692
|
3695
|
else
|
3693
|
3696
|
echo "127.0.1.1 $DEFAULT_DOMAIN_NAME" >> /etc/hosts
|
3694
|
3697
|
fi
|
|
3698
|
+}
|
|
3699
|
+
|
|
3700
|
+function set_your_domain_name {
|
|
3701
|
+ if grep -Fxq "set_your_domain_name" $COMPLETION_FILE; then
|
|
3702
|
+ return
|
|
3703
|
+ fi
|
|
3704
|
+
|
|
3705
|
+ set_hostname $DEFAULT_DOMAIN_NAME
|
|
3706
|
+
|
3695
|
3707
|
echo 'set_your_domain_name' >> $COMPLETION_FILE
|
3696
|
3708
|
}
|
3697
|
3709
|
|
|
@@ -4091,13 +4103,107 @@ function configure_email {
|
4091
|
4103
|
return
|
4092
|
4104
|
fi
|
4093
|
4105
|
apt-get -y remove postfix
|
4094
|
|
- apt-get -y install exim4 sasl2-bin swaks libnet-ssleay-perl procmail
|
|
4106
|
+ apt-get -y install exim4 sasl2-bin swaks libnet-ssleay-perl procmail xinetd
|
4095
|
4107
|
|
4096
|
4108
|
if [ ! -d /etc/exim4 ]; then
|
4097
|
4109
|
echo $"ERROR: Exim does not appear to have installed. $CHECK_MESSAGE"
|
4098
|
4110
|
exit 48
|
4099
|
4111
|
fi
|
4100
|
4112
|
|
|
4113
|
+ if [ ! -d /var/lib/tor ]; then
|
|
4114
|
+ echo $'No Tor installation found. Email onion domain cannot be configured.'
|
|
4115
|
+ exit 69356
|
|
4116
|
+ fi
|
|
4117
|
+ if ! grep -q "hidden_service_email" /etc/tor/torrc; then
|
|
4118
|
+ echo 'HiddenServiceDir /var/lib/tor/hidden_service_email/' >> /etc/tor/torrc
|
|
4119
|
+ echo "HiddenServicePort 25 127.0.0.1:${EMAIL_ONION_PORT}" >> /etc/tor/torrc
|
|
4120
|
+ echo $'Added onion domain for email'
|
|
4121
|
+ fi
|
|
4122
|
+
|
|
4123
|
+ systemctl restart tor
|
|
4124
|
+
|
|
4125
|
+ if [ ! -f /var/lib/tor/hidden_service_email/hostname ]; then
|
|
4126
|
+ echo $'Email onion domain hostname not found'
|
|
4127
|
+ exit 73928
|
|
4128
|
+ fi
|
|
4129
|
+ EMAIL_ONION_HOSTNAME=$(cat /var/lib/tor/hidden_service_email/hostname)
|
|
4130
|
+ if [[ $ONION_ONLY != "no" ]]; then
|
|
4131
|
+ set_hostname ${EMAIL_ONION_HOSTNAME}
|
|
4132
|
+ MY_EMAIL_ADDRESS=${MY_USERNAME}@${DEFAULT_DOMAIN_NAME}
|
|
4133
|
+ fi
|
|
4134
|
+ if ! grep -q "Email onion domain" $COMPLETION_FILE; then
|
|
4135
|
+ echo "Email onion domain:${EMAIL_ONION_HOSTNAME}" >> $COMPLETION_FILE
|
|
4136
|
+ else
|
|
4137
|
+ sed -i "s|Email onion domain.*|Email onion domain:${EMAIL_ONION_HOSTNAME}|g" $COMPLETION_FILE
|
|
4138
|
+ fi
|
|
4139
|
+
|
|
4140
|
+ echo '# tor stuff first' > /etc/exim4/conf.d/router/100_smtorp
|
|
4141
|
+ echo '#' >> /etc/exim4/conf.d/router/100_smtorp
|
|
4142
|
+ echo '# if were submitting mail *from* a .tor/.onion address,' >> /etc/exim4/conf.d/router/100_smtorp
|
|
4143
|
+ echo '# make sure any header lines that may give us away is' >> /etc/exim4/conf.d/router/100_smtorp
|
|
4144
|
+ echo '# stripped out, and add a new, cryptic Message-ID.' >> /etc/exim4/conf.d/router/100_smtorp
|
|
4145
|
+ echo '# In address_data we store the name we should HELO as.' >> /etc/exim4/conf.d/router/100_smtorp
|
|
4146
|
+ echo 'tor_to_any:' >> /etc/exim4/conf.d/router/100_smtorp
|
|
4147
|
+ echo ' debug_print = "R: manualroute from .onion to $local_part@$domain"' >> /etc/exim4/conf.d/router/100_smtorp
|
|
4148
|
+ echo ' driver = manualroute' >> /etc/exim4/conf.d/router/100_smtorp
|
|
4149
|
+ echo ' domains = ! +local_domains' >> /etc/exim4/conf.d/router/100_smtorp
|
|
4150
|
+ echo ' condition = ${if match {$sender_address_domain}{\N.*\.(onion|tor)$\N}}' >> /etc/exim4/conf.d/router/100_smtorp
|
|
4151
|
+ echo ' address_data = $sender_address_domain' >> /etc/exim4/conf.d/router/100_smtorp
|
|
4152
|
+ echo ' transport = remote_smtp_onion' >> /etc/exim4/conf.d/router/100_smtorp
|
|
4153
|
+ echo ' self = send' >> /etc/exim4/conf.d/router/100_smtorp
|
|
4154
|
+ echo ' route_list = * localhost' >> /etc/exim4/conf.d/router/100_smtorp
|
|
4155
|
+ echo ' headers_remove = Received:Message-ID:X-Mailer:User-Agent' >> /etc/exim4/conf.d/router/100_smtorp
|
|
4156
|
+ echo ' headers_add = Message-ID: <${lc:${sha1:$message_id}}@$sender_address_domain>' >> /etc/exim4/conf.d/router/100_smtorp
|
|
4157
|
+ echo '' >> /etc/exim4/conf.d/router/100_smtorp
|
|
4158
|
+ echo '# this catches the case where were submitting mail' >> /etc/exim4/conf.d/router/100_smtorp
|
|
4159
|
+ echo '# from a regular email address where we dont need to' >> /etc/exim4/conf.d/router/100_smtorp
|
|
4160
|
+ echo '# rewrite any headers' >> /etc/exim4/conf.d/router/100_smtorp
|
|
4161
|
+ echo 'any_to_tor:' >> /etc/exim4/conf.d/router/100_smtorp
|
|
4162
|
+ echo ' debug_print = "R: manualroute for $local_part@$domain"' >> /etc/exim4/conf.d/router/100_smtorp
|
|
4163
|
+ echo ' driver = manualroute' >> /etc/exim4/conf.d/router/100_smtorp
|
|
4164
|
+ echo ' domains = ! +local_domains' >> /etc/exim4/conf.d/router/100_smtorp
|
|
4165
|
+ echo ' transport = remote_smtp_onion' >> /etc/exim4/conf.d/router/100_smtorp
|
|
4166
|
+ echo ' self = send' >> /etc/exim4/conf.d/router/100_smtorp
|
|
4167
|
+ echo ' route_list = *.onion localhost ; *.tor localhost' >> /etc/exim4/conf.d/router/100_smtorp
|
|
4168
|
+ echo ' address_data = $smtp_active_hostname' >> /etc/exim4/conf.d/router/100_smtorp
|
|
4169
|
+
|
|
4170
|
+ echo 'remote_smtp_onion:' > /etc/exim4/conf.d/transport/100_smtorp
|
|
4171
|
+ echo ' debug_print = "T: remote_smtp_onion for $local_part@$original_domain"' >> /etc/exim4/conf.d/transport/100_smtorp
|
|
4172
|
+ echo ' driver = smtp' >> /etc/exim4/conf.d/transport/100_smtorp
|
|
4173
|
+ echo '' >> /etc/exim4/conf.d/transport/100_smtorp
|
|
4174
|
+ echo ' # set helo_data to where we want to connect to,' >> /etc/exim4/conf.d/transport/100_smtorp
|
|
4175
|
+ echo ' # for the proxy program tor-smtp' >> /etc/exim4/conf.d/transport/100_smtorp
|
|
4176
|
+ echo ' helo_data = "$address_data $original_domain"' >> /etc/exim4/conf.d/transport/100_smtorp
|
|
4177
|
+ echo '' >> /etc/exim4/conf.d/transport/100_smtorp
|
|
4178
|
+ echo ' # wherever we configured our script at' >> /etc/exim4/conf.d/transport/100_smtorp
|
|
4179
|
+ echo ' port = 12668' >> /etc/exim4/conf.d/transport/100_smtorp
|
|
4180
|
+ echo '' >> /etc/exim4/conf.d/transport/100_smtorp
|
|
4181
|
+ echo ' # cannot use TLS otherwise it will EHLO again!!' >> /etc/exim4/conf.d/transport/100_smtorp
|
|
4182
|
+ echo ' hosts_avoid_tls = *' >> /etc/exim4/conf.d/transport/100_smtorp
|
|
4183
|
+
|
|
4184
|
+ cd $INSTALL_DIR
|
|
4185
|
+ git clone $EXIM_ONION_REPO
|
|
4186
|
+ cd $INSTALL_DIR/exim4-smtorp/tor-smtp
|
|
4187
|
+ make
|
|
4188
|
+ if [ ! -f $INSTALL_DIR/exim4-smtorp/tor-smtp/tor-smtp ]; then
|
|
4189
|
+ echo $'Unable to make tor smtp transport'
|
|
4190
|
+ exit 52629
|
|
4191
|
+ fi
|
|
4192
|
+ if [ ! -d /usr/lib/exim4-smtorp ]; then
|
|
4193
|
+ mkdir /usr/lib/exim4-smtorp
|
|
4194
|
+ fi
|
|
4195
|
+ cp $INSTALL_DIR/exim4-smtorp/tor-smtp/tor-smtp /usr/lib/exim4-smtorp/tor-smtp
|
|
4196
|
+ if [ ! -f /usr/lib/exim4-smtorp/tor-smtp ]; then
|
|
4197
|
+ echo $'Unable to copy tor-smtp'
|
|
4198
|
+ exit 83503
|
|
4199
|
+ fi
|
|
4200
|
+ cp $INSTALL_DIR/exim4-smtorp/xinetd /etc/xinetd.d/tor-smtp
|
|
4201
|
+ if [ ! -f /etc/xinetd.d/tor-smtp ]; then
|
|
4202
|
+ echo $'Unable to copy to xinetd.d'
|
|
4203
|
+ exit 835954
|
|
4204
|
+ fi
|
|
4205
|
+ systemctl restart xinetd
|
|
4206
|
+
|
4101
|
4207
|
# configure for Maildir format
|
4102
|
4208
|
sed -i 's/MAIL_DIR/#MAIL_DIR/g' /etc/login.defs
|
4103
|
4209
|
sed -i 's|#MAIL_FILE.*|MAIL_FILE Maildir/|g' /etc/login.defs
|
|
@@ -4111,7 +4217,13 @@ function configure_email {
|
4111
|
4217
|
sed -i 's|pam_mail.so nopen|pam_mail.so dir=~/Maildir nopen|g' /etc/pam.d/su
|
4112
|
4218
|
|
4113
|
4219
|
echo 'dc_eximconfig_configtype="internet"' > /etc/exim4/update-exim4.conf.conf
|
4114
|
|
- echo "dc_other_hostnames='$DEFAULT_DOMAIN_NAME'" >> /etc/exim4/update-exim4.conf.conf
|
|
4220
|
+ if [[ $ONION_ONLY == "no" ]]; then
|
|
4221
|
+ # both ICANN and onion domains
|
|
4222
|
+ echo "dc_other_hostnames='${DEFAULT_DOMAIN_NAME};${EMAIL_ONION_HOSTNAME}'" >> /etc/exim4/update-exim4.conf.conf
|
|
4223
|
+ else
|
|
4224
|
+ # in onion-only mode the default domain is the same as the onion domain for email
|
|
4225
|
+ echo "dc_other_hostnames='${DEFAULT_DOMAIN_NAME}'" >> /etc/exim4/update-exim4.conf.conf
|
|
4226
|
+ fi
|
4115
|
4227
|
echo "dc_local_interfaces=''" >> /etc/exim4/update-exim4.conf.conf
|
4116
|
4228
|
echo "dc_readhost=''" >> /etc/exim4/update-exim4.conf.conf
|
4117
|
4229
|
echo "dc_relay_domains=''" >> /etc/exim4/update-exim4.conf.conf
|
|
@@ -4129,7 +4241,7 @@ function configure_email {
|
4129
|
4241
|
echo "dc_localdelivery='maildir_home'" >> /etc/exim4/update-exim4.conf.conf
|
4130
|
4242
|
update-exim4.conf
|
4131
|
4243
|
sed -i "s/START=no/START=yes/g" /etc/default/saslauthd
|
4132
|
|
- /etc/init.d/saslauthd start
|
|
4244
|
+ systemctl start saslauthd
|
4133
|
4245
|
|
4134
|
4246
|
# make a tls certificate for email
|
4135
|
4247
|
if [ ! -f /etc/ssl/certs/exim.dhparam ]; then
|
|
@@ -4151,7 +4263,7 @@ function configure_email {
|
4151
|
4263
|
|
4152
|
4264
|
adduser $MY_USERNAME sasl
|
4153
|
4265
|
addgroup Debian-exim sasl
|
4154
|
|
- /etc/init.d/exim4 restart
|
|
4266
|
+ systemctl restart exim4
|
4155
|
4267
|
if [ ! -d /etc/skel/Maildir ]; then
|
4156
|
4268
|
mkdir -m 700 /etc/skel/.mutt
|
4157
|
4269
|
mkdir -m 700 /etc/skel/Maildir
|