]> Pileus Git - ~andy/fetchmail/blob - contrib/fetchsetup
Initial revision
[~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 <krobotti@erols.com> (7-29-98)
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?: foo.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: pop2 pop3 apop imap imap-k4 kpop rpop etrn auto" 
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 if [ -s $HOME/.fetchmailrc ]; then
65 mv $HOME/.fetchmailrc $HOME/.fetchmailrc.OLD
66 fi
67
68 echo 'poll "'$SITE'"' > $HOME/.fetchmailrc
69 echo "protocol $PROTO" >> $HOME/.fetchmailrc
70 echo 'username "'$USR'"' >> $HOME/.fetchmailrc
71 echo 'password "'$PASS'"' >> $HOME/.fetchmailrc
72
73 ps x >/tmp/grep.tmp 2>/dev/null
74
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
78 MDA="1"
79 fi
80 fi
81
82 rm -f /tmp/grep.tmp
83
84 if [ ! "$MDA" = "1" ]; then
85 if [ -x /usr/bin/procmail ]; then
86 echo mda '"/usr/bin/procmail -d %s"' >> $HOME/.fetchmailrc
87 MDA="2"
88 elif [ -x /usr/local/bin/procmail ]; then
89 echo mda '"/usr/local/bin/procmail -d %s"' >> $HOME/.fetchmailrc
90 MDA="2"
91 elif [ -x /usr/sbin/procmail ]; then
92 echo mda '"/usr/sbin/procmail -d %s"' >> $HOME/.fetchmailrc
93 MDA="2"
94 elif [ -x /bin/procmail ]; then
95 echo mda '"/bin/procmail -d %s"' >> $HOME/.fetchmailrc
96 MDA="2"
97 elif [ -x /sbin/procmail ]; then
98 echo mda '"/sbin/procmail -d %s"' >> $HOME/.fetchmailrc
99 MDA="2"
100 elif [ -x /bin/mail.local ]; then
101 echo mda '"/bin/mail.local %s"' >> $HOME/.fetchmailrc
102 MDA="2"
103 elif [ -x /usr/bin/mail.local ]; then
104 echo mda '"/usr/bin/mail.local %s"' >> $HOME/.fetchmailrc
105 MDA="2"
106 else
107 MDA="3"
108 fi 
109 fi
110
111 echo >> $HOME/.fetchmailrc
112 echo
113 echo "This is your $HOME/.fetchmailrc file."
114
115 chmod 600 $HOME/.fetchmailrc
116
117 echo
118 cat $HOME/.fetchmailrc
119
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
125 fi
126 fi
127
128 echo
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."
132 echo
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"
136 echo
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."
140 echo 
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."
145 echo
146 echo "The first time you run fetchmail, you should run it"
147 echo "this way. -> ~# fetchmail -k"
148 echo
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."
152 echo
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"'
157 echo
158 echo "The first time you run fetchmail, you should run it"
159 echo "this way. -> ~# fetchmail -k"
160 echo
161 fi