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 <krobot@erols.com> (3-9-99)
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?: pop.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: apop auto etrn imap imap-gss imap-k4 kpop pop2 pop3 rpop sdps"
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 echo 'poll "'$SITE'"' > $HOME/.fetchmailrc
65 echo "protocol $PROTO" >> $HOME/.fetchmailrc
66 echo 'username "'$USR'"' >> $HOME/.fetchmailrc
67 echo 'password "'$PASS'"' >> $HOME/.fetchmailrc
69 ps ax >/tmp/grep.tmp 2>/dev/null
71 if [ -s /etc/sendmail.cf ]; then
73 elif [ -s /etc/mail/sendmail.cf ]; then
74 CF=/etc/mail/sendmail.cf
77 if [ -s /tmp/grep.tmp ] && [ ! "$CF" = "" ]; then
78 if cat /tmp/grep.tmp | grep "sendmail: accepting" >/dev/null 2>&1 &&
79 grep "A=procmail" $CF >/dev/null 2>&1 ; then
86 if [ ! "$MDA" = "1" ]; then
87 if [ -x /usr/bin/procmail ]; then
88 echo mda '"/usr/bin/procmail -d %s"' >> $HOME/.fetchmailrc
90 elif [ -x /usr/local/bin/procmail ]; then
91 echo mda '"/usr/local/bin/procmail -d %s"' >> $HOME/.fetchmailrc
93 elif [ -x /usr/sbin/procmail ]; then
94 echo mda '"/usr/sbin/procmail -d %s"' >> $HOME/.fetchmailrc
96 elif [ -x /bin/procmail ]; then
97 echo mda '"/bin/procmail -d %s"' >> $HOME/.fetchmailrc
99 elif [ -x /sbin/procmail ]; then
100 echo mda '"/sbin/procmail -d %s"' >> $HOME/.fetchmailrc
102 elif [ -x /bin/mail.local ]; then
103 echo mda '"/bin/mail.local %s"' >> $HOME/.fetchmailrc
105 elif [ -x /usr/bin/mail.local ]; then
106 echo mda '"/usr/bin/mail.local %s"' >> $HOME/.fetchmailrc
113 echo >> $HOME/.fetchmailrc
115 echo "This is your $HOME/.fetchmailrc file."
117 chmod 600 $HOME/.fetchmailrc
120 cat $HOME/.fetchmailrc
122 if [ ! "$MAIL" = "" ]; then
123 echo "Fetchmail will retrieve your mail and put it in:"
125 if [ ! -f "$MAIL" ]; then
126 touch $MAIL 2>/dev/null
127 chmod 600 $MAIL 2>/dev/null
132 if [ "$MDA" = "1" ]; then
133 echo "You seem to have sendmail running, sendmail will be used"
134 echo "as the (m)ail (d)elivery (a)gent for fetchmail."
136 echo "WARNING: There's no way to know if sendmail is set up"
137 echo "properly for local mail delivery, so the first time you"
138 echo "run fetchmail run it this way: # fetchmail -k"
140 echo "If the mail that fetchmail retrieves is not put in your mailbox,"
141 echo "you'll know that sendmail is not set up properly in the"
142 echo "$CF file for delivery of local mail."
144 elif [ "$MDA" = "2" ]; then
145 echo "I put that (m)ail (d)elivery (a)gent in .fetchmailrc"
146 echo "because i found it on your system, this doesn't mean"
147 echo "it's correct or the one you want to use."
149 echo "The first time you run fetchmail, you should run it"
150 echo "this way: # fetchmail -k"
152 elif [ "$MDA" = "3" ]; then
153 echo "I Don't know what (m)ail (d)elivery (a)gent you're going to use."
154 echo "You need a <mda> to deliver the mail to you, after <fetchmail> retrieves it."
156 echo "Put the <mda> in your .fetchmailrc file, like below."
157 echo "password $PASS"
158 echo mda '"/usr/bin/procmail -d %s"'
159 echo mda '"/bin/mail.local %s"'
161 echo "The first time you run fetchmail, you should run it"
162 echo "this way: # fetchmail -k"