瀏覽代碼

Use onion address as the main email address on onion-only installs

Bob Mottram 7 年之前
父節點
當前提交
90dd6b1183
共有 1 個檔案被更改,包括 34 行新增20 行删除
  1. 34
    20
      src/freedombone-base-email

+ 34
- 20
src/freedombone-base-email 查看文件

@@ -120,37 +120,43 @@ function email_create_template {
120 120
     fi
121 121
 }
122 122
 
123
-function configure_email_onion {
124
-    if [[ $(is_completed "${FUNCNAME[0]}") == "1" ]]; then
125
-        return
126
-    fi
127
-    if [[ "$SYSTEM_TYPE" == "mesh"* ]]; then
128
-        return
129
-    fi
130
-
123
+function create_email_onion_address {
131 124
     if ! grep -q "hidden_service_email" /etc/tor/torrc; then
132 125
         { echo 'HiddenServiceDir /var/lib/tor/hidden_service_email/';
133 126
           echo 'HiddenServiceVersion 3';
134 127
           echo 'HiddenServicePort 25 127.0.0.1:25';
135 128
           echo 'HiddenServicePort 587 127.0.0.1:587';
136 129
           echo 'HiddenServicePort 465 127.0.0.1:465'; } >> /etc/tor/torrc
137
-    fi
138 130
 
139
-    function_check onion_update
140
-    onion_update
131
+        function_check onion_update
132
+        onion_update
133
+
134
+        function_check wait_for_onion_service
135
+        wait_for_onion_service email
141 136
 
142
-    function_check wait_for_onion_service
143
-    wait_for_onion_service email
137
+        if [ ! -f /var/lib/tor/hidden_service_email/hostname ]; then
138
+            echo $"email onion site hostname not found"
139
+            systemctl restart tor
140
+            exit 782352
141
+        fi
144 142
 
145
-    if [ ! -f /var/lib/tor/hidden_service_email/hostname ]; then
146
-        echo $"email onion site hostname not found"
147
-        systemctl restart tor
148
-        exit 782352
143
+        onion_address=$(cat /var/lib/tor/hidden_service_email/hostname)
144
+        set_completion_param "email onion domain" "${onion_address}"
145
+        add_email_hostname "$onion_address"
146
+    else
147
+        onion_address=$(cat /var/lib/tor/hidden_service_email/hostname)
149 148
     fi
149
+}
150 150
 
151
-    onion_address=$(cat /var/lib/tor/hidden_service_email/hostname)
152
-    set_completion_param "email onion domain" "${onion_address}"
153
-    add_email_hostname "$onion_address"
151
+function configure_email_onion {
152
+    if [[ $(is_completed "${FUNCNAME[0]}") == "1" ]]; then
153
+        return
154
+    fi
155
+    if [[ "$SYSTEM_TYPE" == "mesh"* ]]; then
156
+        return
157
+    fi
158
+
159
+    create_email_onion_address
154 160
 
155 161
     #apt-get -yq install tinycdb perl
156 162
 
@@ -218,6 +224,7 @@ function configure_email_onion {
218 224
         sed -i 's|DNSListenAddress.*|DNSListenAddress 127.0.0.1|g' /etc/tor/torrc
219 225
     fi
220 226
 
227
+    update-exim4.conf.template -r
221 228
     update-exim4.conf
222 229
     dpkg-reconfigure --frontend noninteractive exim4-config
223 230
     systemctl restart tor
@@ -247,6 +254,12 @@ function check_email_address_exists {
247 254
         MY_EMAIL_ADDRESS="${MY_USERNAME}@${DEFAULT_DOMAIN_NAME}"
248 255
         write_config_param "MY_EMAIL_ADDRESS" "$MY_EMAIL_ADDRESS"
249 256
     fi
257
+
258
+    if [[ $ONION_ONLY != 'no' ]]; then
259
+        my_email=$onion_address
260
+        MY_EMAIL_ADDRESS=$onion_address
261
+        write_config_param "MY_EMAIL_ADDRESS" "$MY_EMAIL_ADDRESS"
262
+    fi
250 263
 }
251 264
 
252 265
 function backup_email {
@@ -1543,6 +1556,7 @@ function install_email {
1543 1556
         return
1544 1557
     fi
1545 1558
 
1559
+    create_email_onion_address
1546 1560
     check_email_address_exists
1547 1561
     install_email_basic
1548 1562
     configure_email_onion