Browse Source

Additional email ports

Bob Mottram 9 years ago
parent
commit
e579a5551a
1 changed files with 34 additions and 11 deletions
  1. 34
    11
      src/freedombone

+ 34
- 11
src/freedombone View File

@@ -285,10 +285,6 @@ MARIADB_PASSWORD=
285 285
 # Directory where XMPP settings are stored
286 286
 XMPP_DIRECTORY="/var/lib/prosody"
287 287
 
288
-# port used for xmpp as an onion service
289
-XMPP_ONION_PORT=8091
290
-XMPP_ONION_PORT2=8092
291
-
292 288
 # file containing a list of remote locations to backup to
293 289
 # Format: [username@friendsdomain//home/username] [ssh_password]
294 290
 # With the only space character being between the server and the password
@@ -313,9 +309,6 @@ XMPP_ECC_CURVE='"secp384r1"'
313 309
 # the default email address
314 310
 MY_EMAIL_ADDRESS=$MY_USERNAME@$DEFAULT_DOMAIN_NAME
315 311
 
316
-# port used for SMTP via an onion address
317
-EMAIL_ONION_PORT=8093
318
-
319 312
 # optionally specify your name to appear on the blog
320 313
 MY_NAME=$DEFAULT_DOMAIN_NAME
321 314
 
@@ -4238,7 +4231,37 @@ function configure_email {
4238 4231
         exit 48
4239 4232
     fi
4240 4233
 
4241
-    EMAIL_ONION_HOSTNAME=$(add_onion_service email 25 ${EMAIL_ONION_PORT})
4234
+    onion_service_name='email'
4235
+    if [ ! -d /var/lib/tor ]; then
4236
+        echo $"No Tor installation found. ${onion_service_name} onion site cannot be configured."
4237
+        exit 877367
4238
+    fi
4239
+    if ! grep -q "hidden_service_${onion_service_name}" /etc/tor/torrc; then
4240
+        echo "HiddenServiceDir /var/lib/tor/hidden_service_${onion_service_name}/" >> /etc/tor/torrc
4241
+        echo 'HiddenServicePort 25 127.0.0.1:25' >> /etc/tor/torrc
4242
+        echo 'HiddenServicePort 587 127.0.0.1:587' >> /etc/tor/torrc
4243
+        echo 'HiddenServicePort 465 127.0.0.1:465' >> /etc/tor/torrc
4244
+        echo 'HiddenServicePort 993 127.0.0.1:993' >> /etc/tor/torrc
4245
+        echo $"Added onion site for ${onion_service_name}"
4246
+    fi
4247
+
4248
+    systemctl restart tor
4249
+
4250
+    # wait for the new service to appear
4251
+    sleep_ctr=0
4252
+    while [ ! -f /var/lib/tor/hidden_service_${onion_service_name}/hostname ]; do
4253
+        sleep 1
4254
+        sleep_ctr=$((sleep_ctr + 1))
4255
+        if [ $sleep_ctr -gt 10 ]; then
4256
+            break
4257
+        fi
4258
+    done
4259
+
4260
+    if [ ! -f /var/lib/tor/hidden_service_${onion_service_name}/hostname ]; then
4261
+        echo $"${onion_service_name} onion site hostname not found"
4262
+        exit 76362
4263
+    fi
4264
+    EMAIL_ONION_HOSTNAME=$(cat /var/lib/tor/hidden_service_${onion_service_name}/hostname)
4242 4265
 
4243 4266
     if [[ $ONION_ONLY != "no" ]]; then
4244 4267
         set_hostname ${EMAIL_ONION_HOSTNAME}
@@ -7042,13 +7065,13 @@ function install_xmpp {
7042 7065
     fi
7043 7066
     if ! grep -q "hidden_service_xmpp" /etc/tor/torrc; then
7044 7067
         echo 'HiddenServiceDir /var/lib/tor/hidden_service_xmpp/' >> /etc/tor/torrc
7045
-        echo "HiddenServicePort 5222 127.0.0.1:${XMPP_ONION_PORT}" >> /etc/tor/torrc
7046
-        echo "HiddenServicePort 5269 127.0.0.1:${XMPP_ONION_PORT2}" >> /etc/tor/torrc
7068
+        echo "HiddenServicePort 5222 127.0.0.1:5222" >> /etc/tor/torrc
7069
+        echo "HiddenServicePort 5269 127.0.0.1:5269" >> /etc/tor/torrc
7047 7070
         echo $'Added onion site for XMPP chat'
7048 7071
     fi
7049 7072
 
7050 7073
     systemctl restart tor
7051
-    sleep 2
7074
+    sleep 5
7052 7075
 
7053 7076
     if [ ! -f /var/lib/tor/hidden_service_xmpp/hostname ]; then
7054 7077
         echo $'XMPP onion site hostname not found'