~inx-devel/inx/scriptsandfunctions

« back to all changes in this revision

Viewing changes to lib/inx/f-mailfunctions

  • Committer: Peter Garrett
  • Date: 2009-08-15 14:51:49 UTC
  • Revision ID: inx-one@optusnet.com.au-20090815145149-91ot0y3f9w9va9wh
Fixes to f-mailfunctions for 'persistent', 
altered install-options, netinxtaller

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
 
 
1
which_mail ()
 
2
    {
 
3
    echo -e "\n  1) I want to use Gmail."
 
4
    echo -e "  2) I want to use my ISP's email (or another service)\n"
 
5
    echo -e "\n  Type the number for your choice ..."
 
6
    
 
7
        repair ()
 
8
        {
 
9
        read -s -n 1 REPAIR
 
10
        case $REPAIR in
 
11
            1)
 
12
            GMAIL=yes
 
13
            f-mail-settings
 
14
            ;;
 
15
            2)
 
16
            f-mail-settings
 
17
            ;;
 
18
            *)
 
19
            echo -e "\n  That doesn't look right - please try again ...\n"
 
20
            repair
 
21
            ;;
 
22
        esac
 
23
        }
 
24
        repair
 
25
    }
 
26
    
2
27
f-mail ()
3
28
{
4
29
        clear
160
185
                if ! [ -f ~/.muttrc ] || ! [ -f ~/.msmtprc ] ; then
161
186
                        # bail out
162
187
                        echo "  Something wicked happened to your mail setup..."
163
 
                        echo "  Let's replace it."
164
 
                        sleep 4
165
 
                        f-mail-settings
 
188
                        echo -e "  Let's replace it.\n"
 
189
                        which_mail                        
166
190
                fi
167
191
 
168
192
                if [ -f ~/.muttrc.bak ] ; then
171
195
                        mv ~/.mutt-temp ~/.muttrc.bak  
172
196
 
173
197
                elif [ -f ~/.muttrc ] ; then
174
 
                        f-mail-settings
 
198
                        which_mail
175
199
                fi
176
200
 
177
201
                if [ -f ~/.msmtprc.bak ] ; then
179
203
                        mv ~/.msmtprc.bak ~/.msmtprc
180
204
                        mv ~/.msmtprc-temp ~/.msmtprc.bak
181
205
                elif [ -f ~/.msmtprc ] ; then
182
 
                        f-mail-settings
 
206
                        which_mail
183
207
                fi
184
208
                        echo "  OK - restored your previous settings."
185
209
                        chmod 600 ~/.muttrc ~/.muttrc.bak ~/.msmtprc ~/.msmtprc.bak
422
446
 
423
447
password ()
424
448
{
 
449
    if ! grep -q persistent /proc/cmdline ; then
425
450
        head-col
426
451
        bold
427
452
        echo
439
464
            echo "  The passwords do not match - please try again."
440
465
            password    
441
466
        fi
 
467
    fi  
442
468
}
443
469
 
444
470
put ()
459
485
set folder="imaps://${SERVER}/INBOX"
460
486
set spoolfile="imaps://${SERVER}/INBOX."
461
487
set imap_user="${USERNAME}"
462
 
set imap_pass="${PASSWORD}"
463
488
my_hdr From: ${IDENTITY} <${ADDRESS}> 
464
489
 
465
490
#-----------------------------------------------#
474
499
 
475
500
set folder="imaps://${USERNAME}@imap.gmail.com:993"
476
501
set spoolfile="imaps://${USERNAME}@imap.gmail.com/INBOX"
477
 
set imap_pass="${PASSWORD}"
478
502
set imap_user="${USERNAME}"
479
503
my_hdr From: ${IDENTITY} <${ADDRESS}>
480
504
#------------------------------------------------#
503
527
host $SERVER
504
528
from $IDENTITY <${ADDRESS}>
505
529
user $USERNAME
506
 
password $PASSWORD 
507
530
 
508
531
#-----------------------------------------------#
509
532
EOMSMTP
520
543
tls on
521
544
tls_trust_file /etc/ssl/certs/ca-certificates.crt
522
545
user ${USERNAME}@gmail.com
523
 
password $PASSWORD
524
546
port 587
525
547
 
526
548
#-----------------------------------------------#
534
556
echo " " >> $HOME/.muttrc
535
557
cat $HOME/.muttrc-base >> $HOME/.muttrc
536
558
 
537
 
# Obliterate the password variable now that it is recorded
538
 
PASSWORD=
539
 
# Clobber the GMAIL variable too...
540
 
GMAIL=
541
 
 
542
559
# Fix the permissions
543
560
chmod 600 ~/.muttrc ~/.msmtprc
544
561
 
549
566
        chmod 600 ~/.msmtprc.bak
550
567
fi
551
568
 
 
569
# Unset the pesky GMAIL variable...
 
570
unset GMAIL
 
571
 
552
572
echo
553
573
 
554
574
}
598
618
                f-mutt
599
619
                ;;
600
620
                n|N)
 
621
                # OK we need to store the password for non-persistent cases then...
 
622
                if ! grep -q persistent /proc/cmdline ; then
 
623
                    echo password $PASSWORD >> $HOME/.msmtprc  
 
624
                    echo set imap_pass=\"$PASSWORD\" >> $HOME/.muttrc
 
625
                fi    
601
626
                f-mail
602
627
                ;;
603
628
                *)
647
672
        case $COWBOYGEEK in
648
673
                yes)
649
674
                bblack
650
 
                f-mail-settings
 
675
                which_mail
651
676
                ;;
652
677
                no)
653
678
                bblack && clear
670
695
 
671
696
}
672
697
 
 
698
 
673
699
oops ()
674
700
{
675
701
if [ -f $HOME/.muttrc ] ; then
 
702
# Put passwords in readable files only during this mail session, on 'persistent' (security and all that...)
 
703
    if grep -q persistent /proc/cmdline ; then
 
704
        echo -e "\n  Please type your password for $(grep ^my_hdr $HOME/.muttrc | cut -d'<' -f2 | sed -s 's/>//')
 
705
  It will not show as you type...\n"
 
706
        read -s
 
707
        PASSWORD="$REPLY"
 
708
    fi  
 
709
    if [ -n "$PASSWORD" ] ; then # $PASSWORD should now exist either way... 
 
710
        echo password $PASSWORD >> $HOME/.msmtprc  
 
711
        echo set imap_pass=\"$PASSWORD\" >> $HOME/.muttrc
 
712
    fi
 
713
 
 
714
 
 
715
        echo 
676
716
        /usr/bin/mutt # OK, bypass this and use the actual program, since the config is there.
 
717
# Remove readable passwords before we exit to the menu again on 'persistent' sessions
 
718
# Leave it there if not 'persistent' ( hdd installs, or live 'volatile' sessions.)
 
719
    if grep -q persistent /proc/cmdline ; then
 
720
        sed -i 's/^password.*//g' $HOME/.msmtprc
 
721
        sed -i 's/^set imap_pass.*//g' $HOME/.muttrc
 
722
    fi  
677
723
        f-mail
678
 
else
679
 
        echo
680
 
        bred ; yellow ; bold 
681
 
        echo
682
 
        echo "  Umm... you seem to be trying to use mutt for mail without configuring it."
683
 
        echo "  This will only work if you know *exactly* what you are doing.            "
684
 
        bblack
685
 
        offer_config 
 
724
else    if [ "$MAILCHOICE" != "4" ] ; then
 
725
            echo  
 
726
            bred ; yellow ; bold 
 
727
            echo
 
728
            echo "  Umm... you seem to be trying to use mutt for mail without configuring it."
 
729
            echo "  This will only work if you know *exactly* what you are doing.            "
 
730
            bblack
 
731
            offer_config
 
732
        else
 
733
            which_mail
 
734
        fi    
686
735
fi
687
736
}
688
737