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
 # Directory where XMPP settings are stored
285
 # Directory where XMPP settings are stored
286
 XMPP_DIRECTORY="/var/lib/prosody"
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
 # file containing a list of remote locations to backup to
288
 # file containing a list of remote locations to backup to
293
 # Format: [username@friendsdomain//home/username] [ssh_password]
289
 # Format: [username@friendsdomain//home/username] [ssh_password]
294
 # With the only space character being between the server and the password
290
 # With the only space character being between the server and the password
313
 # the default email address
309
 # the default email address
314
 MY_EMAIL_ADDRESS=$MY_USERNAME@$DEFAULT_DOMAIN_NAME
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
 # optionally specify your name to appear on the blog
312
 # optionally specify your name to appear on the blog
320
 MY_NAME=$DEFAULT_DOMAIN_NAME
313
 MY_NAME=$DEFAULT_DOMAIN_NAME
321
 
314
 
4238
         exit 48
4231
         exit 48
4239
     fi
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
     if [[ $ONION_ONLY != "no" ]]; then
4266
     if [[ $ONION_ONLY != "no" ]]; then
4244
         set_hostname ${EMAIL_ONION_HOSTNAME}
4267
         set_hostname ${EMAIL_ONION_HOSTNAME}
7042
     fi
7065
     fi
7043
     if ! grep -q "hidden_service_xmpp" /etc/tor/torrc; then
7066
     if ! grep -q "hidden_service_xmpp" /etc/tor/torrc; then
7044
         echo 'HiddenServiceDir /var/lib/tor/hidden_service_xmpp/' >> /etc/tor/torrc
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
         echo $'Added onion site for XMPP chat'
7070
         echo $'Added onion site for XMPP chat'
7048
     fi
7071
     fi
7049
 
7072
 
7050
     systemctl restart tor
7073
     systemctl restart tor
7051
-    sleep 2
7074
+    sleep 5
7052
 
7075
 
7053
     if [ ! -f /var/lib/tor/hidden_service_xmpp/hostname ]; then
7076
     if [ ! -f /var/lib/tor/hidden_service_xmpp/hostname ]; then
7054
         echo $'XMPP onion site hostname not found'
7077
         echo $'XMPP onion site hostname not found'