Browse Source

bdsmail directory

Bob Mottram 7 years ago
parent
commit
c1643e475b
1 changed files with 37 additions and 36 deletions
  1. 37
    36
      src/freedombone-app-bdsmail

+ 37
- 36
src/freedombone-app-bdsmail View File

@@ -35,6 +35,7 @@ SHOW_ON_ABOUT=1
35 35
 
36 36
 BDSMAIL_REPO="https://github.com/majestrate/bdsmail"
37 37
 BDSMAIL_COMMIT='6a2296b0b8e6c3da61081b85802e7b1cc88ca285'
38
+BDSMAIL_DIR=/bdsmail
38 39
 
39 40
 bdsmail=(MY_USERNAME)
40 41
 
@@ -120,14 +121,14 @@ function upgrade_bdsmail {
120 121
     fi
121 122
 
122 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 128
 function backup_local_bdsmail {
128 129
     systemctl stop bdsmail
129 130
 
130
-    source_directory=/etc/bdsmail
131
+    source_directory=$BDSMAIL_DIR
131 132
 
132 133
     function_check backup_directory_to_usb
133 134
     dest_directory=bdsmail
@@ -140,7 +141,7 @@ function restore_local_bdsmail {
140 141
     systemctl stop bdsmail
141 142
 
142 143
     temp_restore_dir=/root/tempbdsmail
143
-    bdsmail_dir=/etc/bdsmail
144
+    bdsmail_dir=$BDSMAIL_DIR
144 145
 
145 146
     function_check restore_directory_from_usb
146 147
     restore_directory_from_usb $temp_restore_dir bdsmail
@@ -163,7 +164,7 @@ function restore_local_bdsmail {
163 164
 function backup_remote_bdsmail {
164 165
     systemctl stop bdsmail
165 166
 
166
-    source_directory=/etc/bdsmail
167
+    source_directory=$BDSMAIL_DIR
167 168
 
168 169
     function_check backup_directory_to_friend
169 170
     dest_directory=bdsmail
@@ -176,7 +177,7 @@ function restore_remote_bdsmail {
176 177
     systemctl stop bdsmail
177 178
 
178 179
     temp_restore_dir=/root/tempbdsmail
179
-    bdsmail_dir=/etc/bdsmail
180
+    bdsmail_dir=$BDSMAIL_DIR
180 181
 
181 182
     function_check restore_directory_from_friend
182 183
     restore_directory_from_friend $temp_restore_dir bdsmail
@@ -234,36 +235,36 @@ function remove_bdsmail {
234 235
     remove_completion_param install_bdsmail
235 236
     sed -i '/bdsmail/d' $COMPLETION_FILE
236 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 240
     fi
240 241
 }
241 242
 
242 243
 function install_bdsmail {
243
-    if [ -d /etc/bdsmail ]; then
244
+    if [ -d $BDSMAIL_DIR ]; then
244 245
         remove_bdsmail
245 246
     fi
246 247
 
247 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 252
         git pull
252 253
     else
253
-        git_clone $BDSMAIL_REPO /etc/bdsmail
254
+        git_clone $BDSMAIL_REPO $BDSMAIL_DIR
254 255
     fi
255 256
 
256
-    if [ ! -d /etc/bdsmail ]; then
257
+    if [ ! -d $BDSMAIL_DIR ]; then
257 258
         echo $'Unable to clone bdsmail repo'
258 259
         exit 5735735
259 260
     fi
260 261
 
261
-    cd /etc/bdsmail
262
+    cd $BDSMAIL_DIR
262 263
     git checkout $BDSMAIL_COMMIT -b $BDSMAIL_COMMIT
263 264
     set_completion_param "bdsmail commit" "$BDSMAIL_COMMIT"
264 265
 
265 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 268
         echo $'Unable to make bdsmail'
268 269
         exit 87923567842
269 270
     fi
@@ -272,16 +273,16 @@ function install_bdsmail {
272 273
     i2p_enable_sam
273 274
 
274 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 287
     echo '[Unit]' > /etc/systemd/system/bdsmail.service
287 288
     echo 'Description=bdsmail' >> /etc/systemd/system/bdsmail.service
@@ -292,26 +293,26 @@ function install_bdsmail {
292 293
     echo 'Type=simple' >> /etc/systemd/system/bdsmail.service
293 294
     echo 'User=i2psvc' >> /etc/systemd/system/bdsmail.service
294 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 298
     echo 'Restart=always' >> /etc/systemd/system/bdsmail.service
298 299
     echo 'Environment="USER=i2psvc"' >> /etc/systemd/system/bdsmail.service
299 300
     echo '' >> /etc/systemd/system/bdsmail.service
300 301
     echo '[Install]' >> /etc/systemd/system/bdsmail.service
301 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 311
     systemctl enable bdsmail
311 312
     systemctl start bdsmail
312 313
 
313 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 316
     echo 'if [ ! -f bdsmail-privkey.dat ]; then' >> /usr/bin/bdsmail_domain
316 317
     echo '    exit 1' >> /usr/bin/bdsmail_domain
317 318
     echo 'fi' >> /usr/bin/bdsmail_domain
@@ -353,7 +354,7 @@ function install_bdsmail {
353 354
     echo 'set smtp_url=smtp://127.0.0.1:2525/' >> /etc/skel/.mutt/bdsmail
354 355
     echo 'set use_from=yes' >> /etc/skel/.mutt/bdsmail
355 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 359
     # mutt configuration for the admin user
359 360
     if [ ! -d /home/$MY_USERNAME/.mutt ]; then