]> Pileus Git - ~andy/fetchmail/blob - contrib/fetchsetup
Updated.
[~andy/fetchmail] / contrib / fetchsetup
1 #!/bin/sh
2
3 MSG() {
4 cat << EOF
5
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)
11
12 EOF
13 }
14
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'."
24 exit 1
25 fi
26
27 MSG
28 echo -n "Continue? (Y/n) : "
29 read ans
30 if [ "$ans" = "n" -o "$ans" = "N" ]; then
31 echo "Cancelled."
32 exit 0
33 fi
34
35 echo
36 echo "Remote mail site?: pop.boo.com   <Your service providers mail domain name>"
37 echo -n "Remote mail site?: "
38 read SITE
39 echo
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" 
43 echo -n "Protocol?: "
44 read PROTO
45 echo
46 echo "Remote username?: jerry   <My username or login is jerry>"
47 echo -n "Remote username?: "
48 read USR
49 echo
50 echo "Remote password?: ?       <What's the password for?: $USR>"
51 echo -n "Remote password?: "
52 read PASS
53
54 echo
55 echo -n "Create $HOME/.fetchmailrc file? (Y/n) : "
56 read ans
57 if [ "$ans" = "n" -o "$ans" = "N" ]; then
58 echo
59 echo "Fetchsetup cancelled."
60 echo
61 exit 0
62 fi
63
64 echo 'poll "'$SITE'"' > $HOME/.fetchmailrc
65 echo "protocol $PROTO" >> $HOME/.fetchmailrc
66 echo 'username "'$USR'"' >> $HOME/.fetchmailrc
67 echo 'password "'$PASS'"' >> $HOME/.fetchmailrc
68
69 ps ax >/tmp/grep.tmp 2>/dev/null
70
71 if [ -s /etc/sendmail.cf ]; then
72 CF=/etc/sendmail.cf
73 elif [ -s /etc/mail/sendmail.cf ]; then
74 CF=/etc/mail/sendmail.cf
75 fi
76
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
80 MDA="1"
81 fi
82 fi
83
84 rm -f /tmp/grep.tmp
85
86 if [ ! "$MDA" = "1" ]; then
87 if [ -x /usr/bin/procmail ]; then
88 echo mda '"/usr/bin/procmail -d %s"' >> $HOME/.fetchmailrc
89 MDA="2"
90 elif [ -x /usr/local/bin/procmail ]; then
91 echo mda '"/usr/local/bin/procmail -d %s"' >> $HOME/.fetchmailrc
92 MDA="2"
93 elif [ -x /usr/sbin/procmail ]; then
94 echo mda '"/usr/sbin/procmail -d %s"' >> $HOME/.fetchmailrc
95 MDA="2"
96 elif [ -x /bin/procmail ]; then
97 echo mda '"/bin/procmail -d %s"' >> $HOME/.fetchmailrc
98 MDA="2"
99 elif [ -x /sbin/procmail ]; then
100 echo mda '"/sbin/procmail -d %s"' >> $HOME/.fetchmailrc
101 MDA="2"
102 elif [ -x /bin/mail.local ]; then
103 echo mda '"/bin/mail.local %s"' >> $HOME/.fetchmailrc
104 MDA="2"
105 elif [ -x /usr/bin/mail.local ]; then
106 echo mda '"/usr/bin/mail.local %s"' >> $HOME/.fetchmailrc
107 MDA="2"
108 else
109 MDA="3"
110 fi 
111 fi
112
113 echo >> $HOME/.fetchmailrc
114 echo
115 echo "This is your $HOME/.fetchmailrc file."
116
117 chmod 600 $HOME/.fetchmailrc
118
119 echo
120 cat $HOME/.fetchmailrc
121
122 if [ ! "$MAIL" = "" ]; then
123 echo "Fetchmail will retrieve your mail and put it in:"
124 echo "$MAIL"
125 if [ ! -f "$MAIL" ]; then
126 touch $MAIL 2>/dev/null
127 chmod 600 $MAIL 2>/dev/null
128 fi
129 fi
130
131 echo
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."
135 echo
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"
139 echo
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."
143 echo 
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."
148 echo
149 echo "The first time you run fetchmail, you should run it"
150 echo "this way: # fetchmail -k"
151 echo
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."
155 echo
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"'
160 echo
161 echo "The first time you run fetchmail, you should run it"
162 echo "this way: # fetchmail -k"
163 echo
164 fi