Bläddra i källkod

bdsmail directory

Bob Mottram 7 år sedan
förälder
incheckning
c1643e475b
1 ändrade filer med 37 tillägg och 36 borttagningar
  1. 37
    36
      src/freedombone-app-bdsmail

+ 37
- 36
src/freedombone-app-bdsmail Visa fil

35
 
35
 
36
 BDSMAIL_REPO="https://github.com/majestrate/bdsmail"
36
 BDSMAIL_REPO="https://github.com/majestrate/bdsmail"
37
 BDSMAIL_COMMIT='6a2296b0b8e6c3da61081b85802e7b1cc88ca285'
37
 BDSMAIL_COMMIT='6a2296b0b8e6c3da61081b85802e7b1cc88ca285'
38
+BDSMAIL_DIR=/bdsmail
38
 
39
 
39
 bdsmail=(MY_USERNAME)
40
 bdsmail=(MY_USERNAME)
40
 
41
 
120
     fi
121
     fi
121
 
122
 
122
     # update to the next commit
123
     # update to the next commit
123
-    set_repo_commit /etc/bdsmail "bdsmail commit" "$BDSMAIL_COMMIT" $BDSMAIL_REPO
124
-    chown -R i2psvc:i2psvc /etc/bdsmail
124
+    set_repo_commit $BDSMAIL_DIR "bdsmail commit" "$BDSMAIL_COMMIT" $BDSMAIL_REPO
125
+    chown -R i2psvc:i2psvc $BDSMAIL_DIR
125
 }
126
 }
126
 
127
 
127
 function backup_local_bdsmail {
128
 function backup_local_bdsmail {
128
     systemctl stop bdsmail
129
     systemctl stop bdsmail
129
 
130
 
130
-    source_directory=/etc/bdsmail
131
+    source_directory=$BDSMAIL_DIR
131
 
132
 
132
     function_check backup_directory_to_usb
133
     function_check backup_directory_to_usb
133
     dest_directory=bdsmail
134
     dest_directory=bdsmail
140
     systemctl stop bdsmail
141
     systemctl stop bdsmail
141
 
142
 
142
     temp_restore_dir=/root/tempbdsmail
143
     temp_restore_dir=/root/tempbdsmail
143
-    bdsmail_dir=/etc/bdsmail
144
+    bdsmail_dir=$BDSMAIL_DIR
144
 
145
 
145
     function_check restore_directory_from_usb
146
     function_check restore_directory_from_usb
146
     restore_directory_from_usb $temp_restore_dir bdsmail
147
     restore_directory_from_usb $temp_restore_dir bdsmail
163
 function backup_remote_bdsmail {
164
 function backup_remote_bdsmail {
164
     systemctl stop bdsmail
165
     systemctl stop bdsmail
165
 
166
 
166
-    source_directory=/etc/bdsmail
167
+    source_directory=$BDSMAIL_DIR
167
 
168
 
168
     function_check backup_directory_to_friend
169
     function_check backup_directory_to_friend
169
     dest_directory=bdsmail
170
     dest_directory=bdsmail
176
     systemctl stop bdsmail
177
     systemctl stop bdsmail
177
 
178
 
178
     temp_restore_dir=/root/tempbdsmail
179
     temp_restore_dir=/root/tempbdsmail
179
-    bdsmail_dir=/etc/bdsmail
180
+    bdsmail_dir=$BDSMAIL_DIR
180
 
181
 
181
     function_check restore_directory_from_friend
182
     function_check restore_directory_from_friend
182
     restore_directory_from_friend $temp_restore_dir bdsmail
183
     restore_directory_from_friend $temp_restore_dir bdsmail
234
     remove_completion_param install_bdsmail
235
     remove_completion_param install_bdsmail
235
     sed -i '/bdsmail/d' $COMPLETION_FILE
236
     sed -i '/bdsmail/d' $COMPLETION_FILE
236
     rm -rf /etc/skel/.mutt
237
     rm -rf /etc/skel/.mutt
237
-    if [ -d /etc/bdsmail ]; then
238
-        rm -rf /etc/bdsmail
238
+    if [ -d $BDSMAIL_DIR ]; then
239
+        rm -rf $BDSMAIL_DIR
239
     fi
240
     fi
240
 }
241
 }
241
 
242
 
242
 function install_bdsmail {
243
 function install_bdsmail {
243
-    if [ -d /etc/bdsmail ]; then
244
+    if [ -d $BDSMAIL_DIR ]; then
244
         remove_bdsmail
245
         remove_bdsmail
245
     fi
246
     fi
246
 
247
 
247
     if [ -d /repos/bdsmail ]; then
248
     if [ -d /repos/bdsmail ]; then
248
-        mkdir /etc/bdsmail
249
-        cp -r -p /repos/bdsmail/. /etc/bdsmail
250
-        cd /etc/bdsmail
249
+        mkdir $BDSMAIL_DIR
250
+        cp -r -p /repos/bdsmail/. $BDSMAIL_DIR
251
+        cd $BDSMAIL_DIR
251
         git pull
252
         git pull
252
     else
253
     else
253
-        git_clone $BDSMAIL_REPO /etc/bdsmail
254
+        git_clone $BDSMAIL_REPO $BDSMAIL_DIR
254
     fi
255
     fi
255
 
256
 
256
-    if [ ! -d /etc/bdsmail ]; then
257
+    if [ ! -d $BDSMAIL_DIR ]; then
257
         echo $'Unable to clone bdsmail repo'
258
         echo $'Unable to clone bdsmail repo'
258
         exit 5735735
259
         exit 5735735
259
     fi
260
     fi
260
 
261
 
261
-    cd /etc/bdsmail
262
+    cd $BDSMAIL_DIR
262
     git checkout $BDSMAIL_COMMIT -b $BDSMAIL_COMMIT
263
     git checkout $BDSMAIL_COMMIT -b $BDSMAIL_COMMIT
263
     set_completion_param "bdsmail commit" "$BDSMAIL_COMMIT"
264
     set_completion_param "bdsmail commit" "$BDSMAIL_COMMIT"
264
 
265
 
265
     make GOROOT=/home/go/go${GO_VERSION}
266
     make GOROOT=/home/go/go${GO_VERSION}
266
-    if [ ! -f /etc/bdsmail/bin/bdsconfig ]; then
267
+    if [ ! -f $BDSMAIL_DIR/bin/bdsconfig ]; then
267
         echo $'Unable to make bdsmail'
268
         echo $'Unable to make bdsmail'
268
         exit 87923567842
269
         exit 87923567842
269
     fi
270
     fi
272
     i2p_enable_sam
273
     i2p_enable_sam
273
 
274
 
274
     # create configuration file
275
     # create configuration file
275
-    /etc/bdsmail/bin/bdsconfig > /etc/bdsmail/config.ini
276
-    echo '[maild]' > /etc/bdsmail/config.ini
277
-    echo 'i2paddr = 127.0.0.1:7656' >> /etc/bdsmail/config.ini
278
-    echo 'i2pkeyfile = bdsmail-privkey.dat' >> /etc/bdsmail/config.ini
279
-    echo 'bindmail = 127.0.0.1:2525' >> /etc/bdsmail/config.ini
280
-    echo 'bindweb = 127.0.0.1:8489' >> /etc/bdsmail/config.ini
281
-    echo 'domain = localhost' >> /etc/bdsmail/config.ini
282
-    echo 'maildir = mail' >> /etc/bdsmail/config.ini
283
-    echo 'database = localhost.sqlite' >> /etc/bdsmail/config.ini
284
-    echo 'assets = contrib/assets/web' >> /etc/bdsmail/config.ini
276
+    $BDSMAIL_DIR/bin/bdsconfig > $BDSMAIL_DIR/config.ini
277
+    echo '[maild]' > $BDSMAIL_DIR/config.ini
278
+    echo 'i2paddr = 127.0.0.1:7656' >> $BDSMAIL_DIR/config.ini
279
+    echo 'i2pkeyfile = bdsmail-privkey.dat' >> $BDSMAIL_DIR/config.ini
280
+    echo 'bindmail = 127.0.0.1:2525' >> $BDSMAIL_DIR/config.ini
281
+    echo 'bindweb = 127.0.0.1:8489' >> $BDSMAIL_DIR/config.ini
282
+    echo 'domain = localhost' >> $BDSMAIL_DIR/config.ini
283
+    echo 'maildir = mail' >> $BDSMAIL_DIR/config.ini
284
+    echo 'database = localhost.sqlite' >> $BDSMAIL_DIR/config.ini
285
+    echo 'assets = contrib/assets/web' >> $BDSMAIL_DIR/config.ini
285
 
286
 
286
     echo '[Unit]' > /etc/systemd/system/bdsmail.service
287
     echo '[Unit]' > /etc/systemd/system/bdsmail.service
287
     echo 'Description=bdsmail' >> /etc/systemd/system/bdsmail.service
288
     echo 'Description=bdsmail' >> /etc/systemd/system/bdsmail.service
292
     echo 'Type=simple' >> /etc/systemd/system/bdsmail.service
293
     echo 'Type=simple' >> /etc/systemd/system/bdsmail.service
293
     echo 'User=i2psvc' >> /etc/systemd/system/bdsmail.service
294
     echo 'User=i2psvc' >> /etc/systemd/system/bdsmail.service
294
     echo 'Group=i2psvc' >> /etc/systemd/system/bdsmail.service
295
     echo 'Group=i2psvc' >> /etc/systemd/system/bdsmail.service
295
-    echo 'WorkingDirectory=/etc/bdsmail' >> /etc/systemd/system/bdsmail.service
296
-    echo 'ExecStart=/etc/bdsmail/bin/maild /etc/bdsmail/config.ini' >> /etc/systemd/system/bdsmail.service
296
+    echo "WorkingDirectory=$BDSMAIL_DIR" >> /etc/systemd/system/bdsmail.service
297
+    echo "ExecStart=$BDSMAIL_DIR/bin/maild $BDSMAIL_DIR/config.ini" >> /etc/systemd/system/bdsmail.service
297
     echo 'Restart=always' >> /etc/systemd/system/bdsmail.service
298
     echo 'Restart=always' >> /etc/systemd/system/bdsmail.service
298
     echo 'Environment="USER=i2psvc"' >> /etc/systemd/system/bdsmail.service
299
     echo 'Environment="USER=i2psvc"' >> /etc/systemd/system/bdsmail.service
299
     echo '' >> /etc/systemd/system/bdsmail.service
300
     echo '' >> /etc/systemd/system/bdsmail.service
300
     echo '[Install]' >> /etc/systemd/system/bdsmail.service
301
     echo '[Install]' >> /etc/systemd/system/bdsmail.service
301
     echo 'WantedBy=multi-user.target' >> /etc/systemd/system/bdsmail.service
302
     echo 'WantedBy=multi-user.target' >> /etc/systemd/system/bdsmail.service
302
 
303
 
303
-    echo '#!/usr/bin/env python2' > /etc/bdsmail/get_address
304
-    echo 'import base64, hashlib, sys' >> /etc/bdsmail/get_address
305
-    echo 'with open(sys.argv[1]) as f:' >> /etc/bdsmail/get_address
306
-    echo "    print(base64.b32encode(hashlib.sha256(base64.b64decode(f.read(516), '-~')).digest()).strip('=')+\".b32.i2p\")" >> /etc/bdsmail/get_address
307
-    chmod +x /etc/bdsmail/get_address
304
+    echo '#!/usr/bin/env python2' > $BDSMAIL_DIR/get_address
305
+    echo 'import base64, hashlib, sys' >> $BDSMAIL_DIR/get_address
306
+    echo 'with open(sys.argv[1]) as f:' >> $BDSMAIL_DIR/get_address
307
+    echo "    print(base64.b32encode(hashlib.sha256(base64.b64decode(f.read(516), '-~')).digest()).strip('=')+\".b32.i2p\")" >> $BDSMAIL_DIR/get_address
308
+    chmod +x $BDSMAIL_DIR/get_address
308
 
309
 
309
-    chown -R i2psvc:i2psvc /etc/bdsmail
310
+    chown -R i2psvc:i2psvc $BDSMAIL_DIR
310
     systemctl enable bdsmail
311
     systemctl enable bdsmail
311
     systemctl start bdsmail
312
     systemctl start bdsmail
312
 
313
 
313
     echo '#!/bin/bash' > /usr/bin/bdsmail_domain
314
     echo '#!/bin/bash' > /usr/bin/bdsmail_domain
314
-    echo 'cd /etc/bdsmail' >> /usr/bin/bdsmail_domain
315
+    echo 'cd $BDSMAIL_DIR' >> /usr/bin/bdsmail_domain
315
     echo 'if [ ! -f bdsmail-privkey.dat ]; then' >> /usr/bin/bdsmail_domain
316
     echo 'if [ ! -f bdsmail-privkey.dat ]; then' >> /usr/bin/bdsmail_domain
316
     echo '    exit 1' >> /usr/bin/bdsmail_domain
317
     echo '    exit 1' >> /usr/bin/bdsmail_domain
317
     echo 'fi' >> /usr/bin/bdsmail_domain
318
     echo 'fi' >> /usr/bin/bdsmail_domain
353
     echo 'set smtp_url=smtp://127.0.0.1:2525/' >> /etc/skel/.mutt/bdsmail
354
     echo 'set smtp_url=smtp://127.0.0.1:2525/' >> /etc/skel/.mutt/bdsmail
354
     echo 'set use_from=yes' >> /etc/skel/.mutt/bdsmail
355
     echo 'set use_from=yes' >> /etc/skel/.mutt/bdsmail
355
     echo "set from=username@${bds_domain}" >> /etc/skel/.mutt/bdsmail
356
     echo "set from=username@${bds_domain}" >> /etc/skel/.mutt/bdsmail
356
-    echo 'set spoolfile=/etc/bdsmail/mail/username' >> /etc/skel/.mutt/bdsmail
357
+    echo "set spoolfile=$BDSMAIL_DIR/mail/username" >> /etc/skel/.mutt/bdsmail
357
 
358
 
358
     # mutt configuration for the admin user
359
     # mutt configuration for the admin user
359
     if [ ! -d /home/$MY_USERNAME/.mutt ]; then
360
     if [ ! -d /home/$MY_USERNAME/.mutt ]; then