|  | @@ -38,6 +38,36 @@ BDSMAIL_COMMIT='6a2296b0b8e6c3da61081b85802e7b1cc88ca285'
 | 
	
		
			
			| 38 | 38 |  
 | 
	
		
			
			| 39 | 39 |  bdsmail=(MY_USERNAME)
 | 
	
		
			
			| 40 | 40 |  
 | 
	
		
			
			|  | 41 | +function bdsmail_configure_users {
 | 
	
		
			
			|  | 42 | +    for d in /home/*/ ; do
 | 
	
		
			
			|  | 43 | +        USERNAME=$(echo "$d" | awk -F '/' '{print $3}')
 | 
	
		
			
			|  | 44 | +        if [[ $(is_valid_user "$USERNAME") == "1" ]]; then
 | 
	
		
			
			|  | 45 | +            if [ -f /home/$USERNAME/.muttrc ]; then
 | 
	
		
			
			|  | 46 | +                # Create a mutt i2p folder
 | 
	
		
			
			|  | 47 | +                if ! grep -q ' =i2p' /home/$USERNAME/.muttrc; then
 | 
	
		
			
			|  | 48 | +                    MUTT_MAILBOXES=$(grep "mailboxes =" /home/$USERNAME/.muttrc)
 | 
	
		
			
			|  | 49 | +                    sed -i "s|$MUTT_MAILBOXES|$MUTT_MAILBOXES =i2p|g" /home/$USERNAME/.muttrc
 | 
	
		
			
			|  | 50 | +                fi
 | 
	
		
			
			|  | 51 | +
 | 
	
		
			
			|  | 52 | +                # Create a mutt folder hook to the i2p config
 | 
	
		
			
			|  | 53 | +                if ! grep -q 'folder-hook !i2p' /home/$USERNAME/.muttrc; then
 | 
	
		
			
			|  | 54 | +                    echo 'folder-hook !i2p/*     source ~/.muttrc' >> /home/$USERNAME/.muttrc
 | 
	
		
			
			|  | 55 | +                fi
 | 
	
		
			
			|  | 56 | +                if ! grep -q 'folder-hook i2p' /home/$USERNAME/.muttrc; then
 | 
	
		
			
			|  | 57 | +                    echo 'folder-hook i2p/*     source ~/.mutt/bdsmail' >> /home/$USERNAME/.muttrc
 | 
	
		
			
			|  | 58 | +                fi
 | 
	
		
			
			|  | 59 | +            fi
 | 
	
		
			
			|  | 60 | +
 | 
	
		
			
			|  | 61 | +            # Create a directory where i2p mail will be stored
 | 
	
		
			
			|  | 62 | +            if [ ! -d /home/$USERNAME/Maildir/i2p/cur ]; then
 | 
	
		
			
			|  | 63 | +                mkdir -p /home/$USERNAME/Maildir/i2p/cur
 | 
	
		
			
			|  | 64 | +                mkdir -p /home/$USERNAME/Maildir/i2p/new
 | 
	
		
			
			|  | 65 | +                chown -R $USERNAME:$USERNAME /home/$USERNAME/Maildir/i2p
 | 
	
		
			
			|  | 66 | +            fi
 | 
	
		
			
			|  | 67 | +        fi
 | 
	
		
			
			|  | 68 | +    done
 | 
	
		
			
			|  | 69 | +}
 | 
	
		
			
			|  | 70 | +
 | 
	
		
			
			| 41 | 71 |  function logging_on_bdsmail {
 | 
	
		
			
			| 42 | 72 |      echo -n ''
 | 
	
		
			
			| 43 | 73 |  }
 | 
	
	
		
			
			|  | @@ -59,6 +89,7 @@ function add_user_bdsmail {
 | 
	
		
			
			| 59 | 89 |          cp /etc/skel/.mutt/bdsmail /home/$new_username/.mutt
 | 
	
		
			
			| 60 | 90 |      fi
 | 
	
		
			
			| 61 | 91 |      sed -i "s|username|$new_username|g" /home/$new_username/.mutt/bdsmail
 | 
	
		
			
			|  | 92 | +    bdsmail_configure_users
 | 
	
		
			
			| 62 | 93 |      chown -R $new_username:$new_username /home/$new_username/.mutt
 | 
	
		
			
			| 63 | 94 |      echo '0'
 | 
	
		
			
			| 64 | 95 |  }
 | 
	
	
		
			
			|  | @@ -176,6 +207,29 @@ function remove_bdsmail {
 | 
	
		
			
			| 176 | 207 |      if [ -d /etc/bdsmail ]; then
 | 
	
		
			
			| 177 | 208 |          rm -rf /etc/bdsmail
 | 
	
		
			
			| 178 | 209 |      fi
 | 
	
		
			
			|  | 210 | +
 | 
	
		
			
			|  | 211 | +    for d in /home/*/ ; do
 | 
	
		
			
			|  | 212 | +        USERNAME=$(echo "$d" | awk -F '/' '{print $3}')
 | 
	
		
			
			|  | 213 | +        if [[ $(is_valid_user "$USERNAME") == "1" ]]; then
 | 
	
		
			
			|  | 214 | +            # Remove mutt folder hook to the i2p config
 | 
	
		
			
			|  | 215 | +            if [ -f /home/$USERNAME/.muttrc ]; then
 | 
	
		
			
			|  | 216 | +                if grep -q 'folder-hook !i2p' /home/$USERNAME/.muttrc; then
 | 
	
		
			
			|  | 217 | +                    sed -i '/folder-hook !i2p/d' /home/$USERNAME/.muttrc
 | 
	
		
			
			|  | 218 | +                fi
 | 
	
		
			
			|  | 219 | +                if grep -q 'folder-hook i2p' /home/$USERNAME/.muttrc; then
 | 
	
		
			
			|  | 220 | +                    sed -i '/folder-hook i2p/d' /home/$USERNAME/.muttrc
 | 
	
		
			
			|  | 221 | +                fi
 | 
	
		
			
			|  | 222 | +            fi
 | 
	
		
			
			|  | 223 | +
 | 
	
		
			
			|  | 224 | +            # Remove folder
 | 
	
		
			
			|  | 225 | +            if grep -q ' =i2p' /home/$USERNAME/.muttrc; then
 | 
	
		
			
			|  | 226 | +                sed -i 's| =i2p||g' /home/$USERNAME/.muttrc
 | 
	
		
			
			|  | 227 | +            fi
 | 
	
		
			
			|  | 228 | +
 | 
	
		
			
			|  | 229 | +            # NOTE: leave Maildir/i2p. We might want to archive that
 | 
	
		
			
			|  | 230 | +            # or just be reinstalling the system without losing mail
 | 
	
		
			
			|  | 231 | +        fi
 | 
	
		
			
			|  | 232 | +    done
 | 
	
		
			
			| 179 | 233 |  }
 | 
	
		
			
			| 180 | 234 |  
 | 
	
		
			
			| 181 | 235 |  function install_bdsmail {
 |