]> Pileus Git - ~andy/fetchmail/blob - contrib/fetchsetup
Minor bug fixes for socket.c
[~andy/fetchmail] / contrib / fetchsetup
1 #!/bin/sh
2
3 MSG() {
4 cat << EOF
5
6 # Fetchsetup is a shell script for creating a .fetchmailrc file, that will be
7 # used by the program "fetchmail" to connect to your mail domain and retrieve
8 # your mail.
9 # This script is linux specific, so it may not work on another system.
10 # Kent Robotti <krobot@erols.com> (3-31-99)
11
12 EOF
13 }
14
15 if [ "$(id -ur)" != "0" ]; then
16     echo >&2 "$0: You need to be root [found $(id -un)] to run this script."
17     echo >&2 "You could login as root"
18     echo >&2 "You could also try one of these: # sudo fetchsetup"
19     echo >&2 "                                 # su root -c fetchsetup"
20     exit 1
21 fi
22
23 MSG
24 echo -n "Continue? (Y/n) : "
25 read ans
26 if [ "$ans" = "n" -o "$ans" = "N" ]; then
27     echo "Cancelled."
28     exit 0
29 fi
30
31 stty erase "^?" 2>/dev/null
32
33 echo
34 echo "Remote mail site?: pop.boo.com   <Your service providers mail domain name>"
35 echo -n "Remote mail site?: "
36 read SITE
37 echo
38 echo "Protocol?: pop3   <My service provider uses the 'pop3' mail protocol>"
39 echo "Protocol?: auto   <If not sure put: auto>"
40 echo "Choices: apop auto etrn imap imap-gss imap-k4 kpop pop2 pop3 rpop sdps"
41 echo -n "Protocol?: "
42 read PROTO
43 echo
44 echo "Remote username?: jerry   <My username or login is jerry>"
45 echo -n "Remote username?: "
46 read USR
47 echo
48 echo "Remote password?: ?       <What's the password for?: $USR>"
49 echo -n "Remote password?: "
50 read PASS
51
52 echo
53 echo -n "Create $HOME/.fetchmailrc file? (Y/n) : "
54 read ans
55 if [ "$ans" = "n" -o "$ans" = "N" ]; then
56     echo
57     echo "Fetchsetup cancelled."
58     echo
59     exit 0
60 fi
61
62 echo 'poll "'$SITE'"' > $HOME/.fetchmailrc
63 echo "protocol $PROTO" >> $HOME/.fetchmailrc
64 echo 'username "'$USR'"' >> $HOME/.fetchmailrc
65 echo 'password "'$PASS'"' >> $HOME/.fetchmailrc
66
67 PROCMAIL=`type -all procmail | sed -n "1 p" | cut -d' ' -f3`
68 SENDMAIL=`type -all sendmail | sed -n "1 p" | cut -d' ' -f3`
69
70 if [ ! "$PROCMAIL" = "" ]; then
71     echo 'mda "'$PROCMAIL -d %s'"' >> $HOME/.fetchmailrc
72     MDA="1"
73 elif [ ! "$SENDMAIL" = "" ]; then
74     echo 'mda "'$SENDMAIL %s'"' >> $HOME/.fetchmailrc
75     MDA="2"
76 else
77     MDA="3"
78 fi
79
80 echo >> $HOME/.fetchmailrc
81 echo
82 echo "This is your $HOME/.fetchmailrc file."
83
84 chmod 600 $HOME/.fetchmailrc
85
86 echo
87 cat $HOME/.fetchmailrc
88
89 if [ ! "$MAIL" = "" ]; then
90     echo "Fetchmail will retrieve your mail and put it in:"
91     echo "$MAIL"
92     if [ ! -f "$MAIL" ]; then
93         touch $MAIL 2>/dev/null
94         chmod 600 $MAIL 2>/dev/null
95     fi
96 fi
97
98 echo
99 if [ "$MDA" = "1" ]; then
100     echo "I put that (m)ail (d)elivery (a)gent in .fetchmailrc"
101     echo "because i found it on your system, this doesn't mean"
102     echo "it's correct or the one you want to use."
103     echo
104     echo "The first time you run fetchmail, you should run it"
105     echo "this way: # fetchmail -k"
106     echo
107 elif [ "$MDA" = "2" ]; then
108     echo "You seem to have sendmail, sendmail will be used"
109     echo "as the (m)ail (d)elivery (a)gent for fetchmail."
110     echo
111     echo "WARNING! There's no way to know if sendmail is set up"
112     echo "properly for local mail delivery, so the first time you"
113     echo "run fetchmail run it this way: # fetchmail -k"
114     echo
115     echo "If the mail that fetchmail retrieves is not put in your mailbox,"
116     echo "you'll know that sendmail is not set up properly for the delivery"
117     echo "of local mail."
118     echo
119 elif [ "$MDA" = "3" ]; then
120     echo "I Don't know what (m)ail (d)elivery (a)gent you're going to use."
121     echo "You need a <mda> to deliver the mail to you, after <fetchmail> retrieves it."
122     echo
123     echo "Put the <mda> in your .fetchmailrc file, like below."
124     echo "password $PASS"
125     echo mda '"/usr/bin/procmail -d %s"'
126     echo mda '"/usr/sbin/sendmail %s"'
127     echo
128     echo "The first time you run fetchmail, you should run it"
129     echo "this way: # fetchmail -k"
130     echo
131 fi