6 # Fetchsetup is a shell script for creating a $HOME/.fetchmailrc
7 # file, that will be used by the program "fetchmail" to connect to
8 # your mail domain and retrieve your mail.
9 # This script is linux specific, so it may not work on another system.
10 # Kent Robotti <krobotti@erols.com> (7-29-98)
15 if [ ! "$UID" = "0" ]; then
16 echo "NOTICE: * $LOGNAME * You need to be 'root' to run this script."
17 echo "You could login: root"
18 echo "You could also try this: # sudo fetchsetup"
19 echo "You could also try this: # su -c fetchsetup"
20 echo "This assumes the permissions on 'sudo' and 'su' are 4111."
21 echo "To give 'su' or 'sudo' these permissions, you have to be root."
22 echo "~# chown root.root sudo ; chmod 4111 sudo"
23 echo "You also need a /etc/sudoers file for 'sudo'."
28 echo -n "Continue? (Y/n) : "
30 if [ "$ans" = "n" -o "$ans" = "N" ]; then
36 echo "Remote mail site?: foo.boo.com <-Your service providers mail domain name.)"
37 echo -n "Remote mail site?: "
40 echo "Protocol?: pop3 <-My service provider uses the 'pop3' mail protocol.)"
41 echo "Protocol?: auto <-If not sure put: auto"
42 echo "Choices: pop2 pop3 apop imap imap-k4 kpop rpop etrn auto"
46 echo "Remote username?: jerry <-My username or login is jerry.)"
47 echo -n "Remote username?: "
50 echo "Remote password?: ? <-What's the password for?: $USR"
51 echo -n "Remote password?: "
55 echo -n "Create $HOME/.fetchmailrc file? (Y/n) : "
57 if [ "$ans" = "n" -o "$ans" = "N" ]; then
59 echo "Fetchsetup cancelled."
64 if [ -s $HOME/.fetchmailrc ]; then
65 mv $HOME/.fetchmailrc $HOME/.fetchmailrc.OLD
68 echo 'poll "'$SITE'"' > $HOME/.fetchmailrc
69 echo "protocol $PROTO" >> $HOME/.fetchmailrc
70 echo 'username "'$USR'"' >> $HOME/.fetchmailrc
71 echo 'password "'$PASS'"' >> $HOME/.fetchmailrc
73 ps x >/tmp/grep.tmp 2>/dev/null
75 if [ -s /tmp/grep.tmp ]; then
76 if cat /tmp/grep.tmp | grep "sendmail: accepting" >/dev/null 2>&1 &&
77 grep "A=procmail" /etc/sendmail.cf >/dev/null 2>&1 ; then
84 if [ ! "$MDA" = "1" ]; then
85 if [ -x /usr/bin/procmail ]; then
86 echo mda '"/usr/bin/procmail -d %s"' >> $HOME/.fetchmailrc
88 elif [ -x /usr/local/bin/procmail ]; then
89 echo mda '"/usr/local/bin/procmail -d %s"' >> $HOME/.fetchmailrc
91 elif [ -x /usr/sbin/procmail ]; then
92 echo mda '"/usr/sbin/procmail -d %s"' >> $HOME/.fetchmailrc
94 elif [ -x /bin/procmail ]; then
95 echo mda '"/bin/procmail -d %s"' >> $HOME/.fetchmailrc
97 elif [ -x /sbin/procmail ]; then
98 echo mda '"/sbin/procmail -d %s"' >> $HOME/.fetchmailrc
100 elif [ -x /bin/mail.local ]; then
101 echo mda '"/bin/mail.local %s"' >> $HOME/.fetchmailrc
103 elif [ -x /usr/bin/mail.local ]; then
104 echo mda '"/usr/bin/mail.local %s"' >> $HOME/.fetchmailrc
111 echo >> $HOME/.fetchmailrc
113 echo "This is your $HOME/.fetchmailrc file."
115 chmod 600 $HOME/.fetchmailrc
118 cat $HOME/.fetchmailrc
120 if [ ! "$MAIL" = "" ]; then
121 echo "Fetchmail will retrieve your mail and put it in: $MAIL"
122 if [ ! -s "$MAIL" ]; then
123 touch $MAIL 2>/dev/null
124 chmod 600 $MAIL 2>/dev/null
129 if [ "$MDA" = "1" ]; then
130 echo "You seem to have sendmail running, sendmail will be used"
131 echo "as the (m)ail (d)elivery (a)gent for fetchmail."
133 echo "WARNING: There's no way to know if sendmail is set up"
134 echo "properly for local mail delivery, so the first time you"
135 echo "run fetchmail, run it this way. -> ~# fetchmail -k"
137 echo "If the mail that fetchmail retrieves is not put in your mailbox,"
138 echo "you'll know that sendmail is not set up properly in the"
139 echo "/etc/sendmail.cf file, for delivery of local mail."
141 elif [ "$MDA" = "2" ]; then
142 echo "I put that (m)ail (d)elivery (a)gent in .fetchmailrc,"
143 echo "because i found it on your system, this doesn't mean"
144 echo "it's correct or the one you want to use."
146 echo "The first time you run fetchmail, you should run it"
147 echo "this way. -> ~# fetchmail -k"
149 elif [ "$MDA" = "3" ]; then
150 echo "I Don't know what (m)ail (d)elivery (a)gent you're going to use."
151 echo "You need a <mda> to deliver the mail to you, after <fetchmail> retrieves it."
153 echo "Put the <mda> in your .fetchmailrc file, like below."
154 echo "password $PASS"
155 echo mda '"/usr/bin/procmail -d %s"'
156 echo mda '"/bin/mail.local %s"'
158 echo "The first time you run fetchmail, you should run it"
159 echo "this way. -> ~# fetchmail -k"