浏览代码

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
     fi
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
     if ! grep -q "hidden_service_email" /etc/tor/torrc; then
124
     if ! grep -q "hidden_service_email" /etc/tor/torrc; then
132
         { echo 'HiddenServiceDir /var/lib/tor/hidden_service_email/';
125
         { echo 'HiddenServiceDir /var/lib/tor/hidden_service_email/';
133
           echo 'HiddenServiceVersion 3';
126
           echo 'HiddenServiceVersion 3';
134
           echo 'HiddenServicePort 25 127.0.0.1:25';
127
           echo 'HiddenServicePort 25 127.0.0.1:25';
135
           echo 'HiddenServicePort 587 127.0.0.1:587';
128
           echo 'HiddenServicePort 587 127.0.0.1:587';
136
           echo 'HiddenServicePort 465 127.0.0.1:465'; } >> /etc/tor/torrc
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
     fi
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
     #apt-get -yq install tinycdb perl
161
     #apt-get -yq install tinycdb perl
156
 
162
 
218
         sed -i 's|DNSListenAddress.*|DNSListenAddress 127.0.0.1|g' /etc/tor/torrc
224
         sed -i 's|DNSListenAddress.*|DNSListenAddress 127.0.0.1|g' /etc/tor/torrc
219
     fi
225
     fi
220
 
226
 
227
+    update-exim4.conf.template -r
221
     update-exim4.conf
228
     update-exim4.conf
222
     dpkg-reconfigure --frontend noninteractive exim4-config
229
     dpkg-reconfigure --frontend noninteractive exim4-config
223
     systemctl restart tor
230
     systemctl restart tor
247
         MY_EMAIL_ADDRESS="${MY_USERNAME}@${DEFAULT_DOMAIN_NAME}"
254
         MY_EMAIL_ADDRESS="${MY_USERNAME}@${DEFAULT_DOMAIN_NAME}"
248
         write_config_param "MY_EMAIL_ADDRESS" "$MY_EMAIL_ADDRESS"
255
         write_config_param "MY_EMAIL_ADDRESS" "$MY_EMAIL_ADDRESS"
249
     fi
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
 function backup_email {
265
 function backup_email {
1543
         return
1556
         return
1544
     fi
1557
     fi
1545
 
1558
 
1559
+    create_email_onion_address
1546
     check_email_address_exists
1560
     check_email_address_exists
1547
     install_email_basic
1561
     install_email_basic
1548
     configure_email_onion
1562
     configure_email_onion