Browse Source

handling of bdsmail admin password

Bob Mottram 7 years ago
parent
commit
fb5fe89009
1 changed files with 23 additions and 6 deletions
  1. 23
    6
      src/freedombone-app-bdsmail

+ 23
- 6
src/freedombone-app-bdsmail View File

@@ -95,10 +95,13 @@ function add_user_bdsmail {
95 95
         mkdir /home/$new_username/.mutt
96 96
         cp /etc/skel/.mutt/bdsmail /home/$new_username/.mutt
97 97
     fi
98
+    read_config_param MY_USERNAME
99
+    BDSMAIL_PASSWORD=$(${PROJECT_NAME}-pass -u $MY_USERNAME -a bdsmail)
98 100
     sed -i "s|username|$new_username|g" /home/$new_username/.mutt/bdsmail
101
+    sed -i "s|password|$BDSMAIL_PASSWORD|g" /home/$new_username/.mutt/bdsmail
99 102
     bdsmail_configure_users
100 103
     cd $BDSMAIL_DIR
101
-    $BDSMAIL_DIR/bin/mailtool $BDSMAIL_DIR/config.ini $new_username /home/$new_username/Maildir/i2p
104
+    $BDSMAIL_DIR/bin/mailtool $BDSMAIL_DIR/config.ini $new_username /home/$new_username/Maildir/i2p "$BDSMAIL_PASSWORD"
102 105
     chown -R $new_username:$new_username /home/$new_username/.mutt
103 106
     echo '0'
104 107
 }
@@ -111,6 +114,19 @@ function install_interactive_bdsmail {
111 114
 function change_password_bdsmail {
112 115
     curr_username="$1"
113 116
     new_user_password="$2"
117
+
118
+    ${PROJECT_NAME}-pass -u $MY_USERNAME -a bdsmail -p "$new_user_password"
119
+
120
+    for d in /home/*/ ; do
121
+        USERNAME=$(echo "$d" | awk -F '/' '{print $3}')
122
+        if [[ $(is_valid_user "$USERNAME") == "1" ]]; then
123
+            sed -i "s|set smtp_url=.*|set smtp_url=smtp://${curr_username}:${new_user_password}@127.0.0.1:$I2P_SMTP_PORT/" /home/${USERNAME}/.mutt/bdsmail
124
+            sed -i "s|set from=.*|set from=${USERNAME}@$(bdsmail_domain)|g" /home/${USERNAME}/.mutt/bdsmail
125
+            chown ${USERNAME}:${USERNAME} /home/${USERNAME}/.mutt/bdsmail
126
+            cd $BDSMAIL_DIR
127
+            $BDSMAIL_DIR/bin/mailtool $BDSMAIL_DIR/config.ini $curr_username /home/$curr_username/Maildir/i2p "$new_user_password"
128
+        fi
129
+    done
114 130
 }
115 131
 
116 132
 function bdsmail_update_domain {
@@ -412,17 +428,17 @@ function install_bdsmail {
412 428
         exit 8934638
413 429
     fi
414 430
 
415
-    bdsmail_admin_password="$(create_password ${MINIMUM_PASSWORD_LENGTH})"
416
-    ${PROJECT_NAME}-pass -u $MY_USERNAME -a bdsmail -p "$bdsmail_admin_password"
431
+    BDSMAIL_PASSWORD="$(create_password ${MINIMUM_PASSWORD_LENGTH})"
432
+    ${PROJECT_NAME}-pass -u $MY_USERNAME -a bdsmail -p "$BDSMAIL_PASSWORD"
417 433
     cd $BDSMAIL_DIR
418
-    $BDSMAIL_DIR/bin/mailtool $BDSMAIL_DIR/config.ini admin $BDSMAIL_DIR/Maildir/i2p/admin "$bdsmail_admin_password"
434
+    $BDSMAIL_DIR/bin/mailtool $BDSMAIL_DIR/config.ini admin $BDSMAIL_DIR/Maildir/i2p/admin "$BDSMAIL_PASSWORD"
419 435
 
420 436
     # Create mutt configuration
421 437
     if [ ! -d /etc/skel/.mutt ]; then
422 438
         mkdir /etc/skel/.mutt
423 439
     fi
424 440
     echo 'set mbox_type=Maildir' > /etc/skel/.mutt/bdsmail
425
-    echo "set smtp_url=smtp://admin:${bdsmail_admin_password}@127.0.0.1:$I2P_SMTP_PORT/" >> /etc/skel/.mutt/bdsmail
441
+    echo "set smtp_url=smtp://username:password@127.0.0.1:$I2P_SMTP_PORT/" >> /etc/skel/.mutt/bdsmail
426 442
     echo 'set use_from=yes' >> /etc/skel/.mutt/bdsmail
427 443
     echo "set from=username@${bds_domain}" >> /etc/skel/.mutt/bdsmail
428 444
     echo "set spoolfile=~/Maildir/i2p" >> /etc/skel/.mutt/bdsmail
@@ -437,12 +453,13 @@ function install_bdsmail {
437 453
     fi
438 454
     cp /etc/skel/.mutt/bdsmail /home/$MY_USERNAME/.mutt
439 455
     sed -i "s|username|$MY_USERNAME|g" /home/$MY_USERNAME/.mutt/bdsmail
456
+    sed -i "s|password|$BDSMAIL_PASSWORD|g" /home/$MY_USERNAME/.mutt/bdsmail
440 457
     chown -R $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/.mutt
441 458
 
442 459
     bdsmail_configure_users
443 460
 
444 461
     cd $BDSMAIL_DIR
445
-    $BDSMAIL_DIR/bin/mailtool $BDSMAIL_DIR/config.ini $MY_USERNAME /home/$MY_USERNAME/Maildir/i2p
462
+    $BDSMAIL_DIR/bin/mailtool $BDSMAIL_DIR/config.ini $MY_USERNAME /home/$MY_USERNAME/Maildir/i2p "$BDSMAIL_PASSWORD"
446 463
 
447 464
     APP_INSTALLED=1
448 465
 }