1 |
lefcha |
1.1 |
#!/bin/sh |
2 |
|
|
|
3 |
lefcha |
1.2 |
# Default values |
4 |
|
|
|
5 |
lefcha |
1.1 |
destdir="/usr/local" |
6 |
|
|
bindir="$destdir/bin" |
7 |
|
|
mandir="$destdir/man" |
8 |
|
|
|
9 |
lefcha |
1.4 |
encpasswds="yes" |
10 |
lefcha |
1.20 |
ssltls="yes" |
11 |
lefcha |
1.19 |
cram="yes" |
12 |
lefcha |
1.1 |
|
13 |
|
|
libs="" |
14 |
lefcha |
1.19 |
libssl="-lssl" |
15 |
|
|
libcrypto="-lcrypto" |
16 |
lefcha |
1.1 |
|
17 |
lefcha |
1.26 |
cflags="-g" |
18 |
lefcha |
1.17 |
ldflags="" |
19 |
lefcha |
1.10 |
|
20 |
lefcha |
1.1 |
interactive="no" |
21 |
|
|
|
22 |
|
|
|
23 |
|
|
# Get options and arguments |
24 |
|
|
|
25 |
|
|
while getopts "hid:b:m:o:" opt |
26 |
|
|
do |
27 |
|
|
case $opt in |
28 |
|
|
d) |
29 |
|
|
destdir=$OPTARG |
30 |
|
|
bindir=$destdir/bin |
31 |
|
|
mandir=$destdir/man |
32 |
|
|
;; |
33 |
|
|
b) |
34 |
|
|
bindir=$OPTARG |
35 |
|
|
;; |
36 |
|
|
m) |
37 |
|
|
mandir=$OPTARG |
38 |
|
|
;; |
39 |
|
|
o) |
40 |
lefcha |
1.5 |
head=`echo $OPTARG | cut -d= -f1` |
41 |
|
|
body=`echo $OPTARG | cut -d= -f2` |
42 |
lefcha |
1.26 |
if [ $head = "encpasswds" ] |
43 |
lefcha |
1.6 |
then |
44 |
|
|
if [ $body = "yes" ]; then encpasswds="yes" |
45 |
lefcha |
1.8 |
elif [ $body = "no" ]; then encpasswds="no" |
46 |
lefcha |
1.6 |
fi |
47 |
lefcha |
1.20 |
elif [ $head = "ssltls" ] |
48 |
lefcha |
1.5 |
then |
49 |
lefcha |
1.20 |
if [ $body = "yes" ]; then ssltls="yes" |
50 |
|
|
elif [ $body = "no" ]; then ssltls="no" |
51 |
lefcha |
1.5 |
fi |
52 |
lefcha |
1.19 |
elif [ $head = "cram" ] |
53 |
|
|
then |
54 |
|
|
if [ $body = "yes" ]; then cram="yes" |
55 |
|
|
elif [ $body = "no" ]; then cram="no" |
56 |
|
|
fi |
57 |
lefcha |
1.5 |
fi |
58 |
lefcha |
1.1 |
;; |
59 |
|
|
i) |
60 |
|
|
interactive="yes" |
61 |
|
|
;; |
62 |
|
|
h | *) |
63 |
|
|
cat << EOF |
64 |
|
|
Usage: |
65 |
|
|
config [-hi] [-d destdir] [-b bindir] [-m mandir] [-o option=argument] |
66 |
|
|
|
67 |
|
|
Description: |
68 |
|
|
-h This brief usage and description message. |
69 |
|
|
-i Interactive mode. |
70 |
lefcha |
1.15 |
-d destdir Installation path for program's files [$destdir] |
71 |
|
|
-b bindir Installation path for binaries [$bindir] |
72 |
|
|
-m mandir Installation path for manual pages [$mandir] |
73 |
lefcha |
1.1 |
-o option=argument Enabling/disabling of program's options. |
74 |
|
|
|
75 |
|
|
Options: |
76 |
lefcha |
1.14 |
encpasswds Encrypted passwords support [$encpasswds] |
77 |
lefcha |
1.20 |
ssltls Secure Socket Layer and Transport Layer Security [$ssltls] |
78 |
lefcha |
1.19 |
cram Challenge-Response Authentication Mechanism [$cram] |
79 |
lefcha |
1.1 |
EOF |
80 |
|
|
exit 1 |
81 |
|
|
;; |
82 |
|
|
esac |
83 |
|
|
done |
84 |
|
|
|
85 |
|
|
|
86 |
|
|
# Interactive or non-interactive mode |
87 |
|
|
|
88 |
|
|
if [ $interactive = "yes" ] |
89 |
|
|
then |
90 |
lefcha |
1.9 |
printf "Destination directory [$destdir]: " |
91 |
lefcha |
1.1 |
read tmp |
92 |
|
|
if [ -n "$tmp" ]; then destdir="$tmp"; fi |
93 |
|
|
|
94 |
lefcha |
1.9 |
printf "Binaries directory [$bindir]: " |
95 |
lefcha |
1.1 |
read tmp |
96 |
|
|
if [ -n "$tmp" ]; then bindir="$tmp"; fi |
97 |
|
|
|
98 |
lefcha |
1.9 |
printf "Manual pages directory [$mandir]: " |
99 |
lefcha |
1.1 |
read tmp |
100 |
|
|
if [ -n "$tmp" ]; then mandir="$tmp"; fi |
101 |
|
|
|
102 |
lefcha |
1.14 |
printf "Encrypted passwords support [$encpasswds]: " |
103 |
lefcha |
1.4 |
read tmp |
104 |
|
|
if [ -n "$tmp" ]; then encpasswds="$tmp"; fi |
105 |
|
|
|
106 |
lefcha |
1.20 |
printf "Secure Socket Layer and Transport Layer Security [$ssltls]: " |
107 |
lefcha |
1.1 |
read tmp |
108 |
lefcha |
1.20 |
if [ -n "$tmp" ]; then ssltls="$tmp"; fi |
109 |
lefcha |
1.19 |
|
110 |
|
|
printf "Challenge-Response Authentication Mechanism [$cram]: " |
111 |
|
|
read tmp |
112 |
|
|
if [ -n "$tmp" ]; then cram="$tmp"; fi |
113 |
lefcha |
1.1 |
else |
114 |
|
|
cat << EOF |
115 |
|
|
Destination directory: $destdir |
116 |
|
|
Binaries directory: $bindir |
117 |
|
|
Manual pages directory: $mandir |
118 |
lefcha |
1.4 |
Encrypted passwords support: $encpasswds |
119 |
lefcha |
1.20 |
Secure Socket Layer and Transport Layer Security: $ssltls |
120 |
|
|
Challenge-Response Authentication Mechanism: $cram |
121 |
lefcha |
1.1 |
EOF |
122 |
|
|
fi |
123 |
|
|
|
124 |
|
|
|
125 |
|
|
# Libraries |
126 |
|
|
|
127 |
lefcha |
1.20 |
if [ $ssltls = "yes" ] |
128 |
lefcha |
1.1 |
then |
129 |
lefcha |
1.19 |
libs="$libs $libssl $libcrypto" |
130 |
lefcha |
1.24 |
elif [ $encpasswds = "yes" ] || [ $cram = "yes" ] |
131 |
lefcha |
1.4 |
then |
132 |
lefcha |
1.19 |
libs="$libs $libcrypto" |
133 |
lefcha |
1.1 |
fi |
134 |
|
|
|
135 |
|
|
|
136 |
|
|
# Backup of original Makefile and config.h |
137 |
|
|
|
138 |
lefcha |
1.13 |
if [ ! -f .Makefile ]; then cp -f Makefile .Makefile; fi |
139 |
|
|
if [ ! -f .config.h ]; then cp -f config.h .config.h; fi |
140 |
lefcha |
1.1 |
|
141 |
|
|
|
142 |
|
|
# Write Makefile |
143 |
|
|
|
144 |
lefcha |
1.13 |
mv -f Makefile Makefile~ |
145 |
lefcha |
1.1 |
|
146 |
|
|
cat > Makefile << EOF |
147 |
|
|
CC = cc |
148 |
lefcha |
1.10 |
CFLAGS = $cflags |
149 |
lefcha |
1.16 |
LDFLAGS = |
150 |
lefcha |
1.1 |
|
151 |
|
|
DESTDIR = $destdir |
152 |
|
|
BINDIR = $bindir |
153 |
|
|
MANDIR = $mandir |
154 |
|
|
|
155 |
|
|
MAN_BIN = imapfilter.1 |
156 |
|
|
MAN_RC = imapfilterrc.5 |
157 |
|
|
|
158 |
|
|
BIN = imapfilter |
159 |
lefcha |
1.22 |
OBJ = account.o action.o auth.o buffer.o cert.o destroy.o file.o filter.o \\ |
160 |
|
|
imap.o imapfilter.o lock.o log.o match.o memory.o misc.o parse.o \\ |
161 |
|
|
passwd.o response.o request.o socket.o tty.o |
162 |
lefcha |
1.1 |
|
163 |
|
|
LIBS = $libs |
164 |
|
|
|
165 |
lefcha |
1.22 |
all: imapfilter |
166 |
|
|
|
167 |
lefcha |
1.1 |
imapfilter: \$(OBJ) |
168 |
lefcha |
1.16 |
\$(CC) \$(LIBS) \$(LDFLAGS) -o \$(BIN) \$(OBJ) |
169 |
lefcha |
1.1 |
|
170 |
lefcha |
1.22 |
account.o action.o auth.o buffer.o cert.o destroy.o file.o filter.o imap.o \\ |
171 |
|
|
imapfilter.o lock.o log.o match.o memory.o parse.o passwd.o \\ |
172 |
|
|
request.o response.o socket.o tty.o: config.h imapfilter.h |
173 |
|
|
account.o destroy.o filter.o imapfilter.o match.o: account.h |
174 |
lefcha |
1.27 |
action.o destroy.o filter.o imap.o imapfilter.o match.o: filter.h |
175 |
lefcha |
1.22 |
account.o filter.o: struct.h |
176 |
|
|
buffer.o imap.o imapfilter.o response.o: buffer.h |
177 |
lefcha |
1.26 |
cert.o file.o lock.o log.o parse.o: pathnames.h |
178 |
lefcha |
1.22 |
imapfilter.o: version.h |
179 |
lefcha |
1.1 |
|
180 |
|
|
install: imapfilter |
181 |
lefcha |
1.11 |
if test ! -d \$(BINDIR); then mkdir -p \$(BINDIR); fi |
182 |
|
|
cp -f \$(BIN) \$(BINDIR) && chmod 0755 \$(BINDIR)/\$(BIN) |
183 |
|
|
if test ! -d \$(MANDIR)/man1; then mkdir -p \$(MANDIR)/man1; fi |
184 |
|
|
cp -f \$(MAN_BIN) \$(MANDIR)/man1 && chmod 0644 \$(MANDIR)/man1/\$(MAN_BIN) |
185 |
lefcha |
1.12 |
if test ! -d \$(MANDIR)/man5; then mkdir -p \$(MANDIR)/man5; fi |
186 |
lefcha |
1.11 |
cp -f \$(MAN_RC) \$(MANDIR)/man5 && chmod 0644 \$(MANDIR)/man5/\$(MAN_RC) |
187 |
lefcha |
1.1 |
|
188 |
lefcha |
1.22 |
deinstall: |
189 |
lefcha |
1.1 |
rm -f \$(BINDIR)/\$(BIN) \$(MANDIR)/man1/\$(MAN_BIN) \$(MANDIR)/man5/\$(MAN_RC) |
190 |
lefcha |
1.22 |
|
191 |
|
|
uninstall: deinstall |
192 |
lefcha |
1.1 |
|
193 |
|
|
clean: |
194 |
|
|
rm -f \$(OBJ) \$(BIN) imapfilter.core core *.BAK *~ |
195 |
|
|
|
196 |
|
|
distclean: clean |
197 |
lefcha |
1.11 |
@if test -f .Makefile; then mv -f .Makefile Makefile; fi |
198 |
|
|
@if test -f .config.h; then mv -f .config.h config.h; fi |
199 |
lefcha |
1.1 |
EOF |
200 |
|
|
|
201 |
|
|
|
202 |
|
|
# Write config.h |
203 |
|
|
|
204 |
lefcha |
1.13 |
mv -f config.h config.h~ |
205 |
lefcha |
1.1 |
|
206 |
lefcha |
1.23 |
echo "#ifndef CONFIG_H" > config.h |
207 |
|
|
echo "#define CONFIG_H" >> config.h |
208 |
|
|
echo >> config.h; echo >> config.h |
209 |
|
|
|
210 |
lefcha |
1.4 |
echo "/* Encrypted passwords support. */" >> config.h |
211 |
|
|
if [ $encpasswds = "yes" ] |
212 |
|
|
then |
213 |
|
|
echo "#define ENCRYPTED_PASSWORDS" >> config.h |
214 |
|
|
else |
215 |
|
|
echo "#undef ENCRYPTED_PASSWORDS" >> config.h |
216 |
lefcha |
1.1 |
fi |
217 |
|
|
echo >> config.h |
218 |
|
|
|
219 |
|
|
echo "/* Secure Socket Layer and Transport Layer Security support. */" >> config.h |
220 |
lefcha |
1.20 |
if [ $ssltls = "yes" ] |
221 |
lefcha |
1.1 |
then |
222 |
|
|
echo "#define SSL_TLS" >> config.h |
223 |
|
|
else |
224 |
|
|
echo "#undef SSL_TLS" >> config.h |
225 |
lefcha |
1.19 |
fi |
226 |
|
|
echo >> config.h |
227 |
|
|
|
228 |
|
|
echo "/* Challenge-Response Authentication Mechanism support. */" >> config.h |
229 |
|
|
if [ $cram = "yes" ] |
230 |
|
|
then |
231 |
|
|
echo "#define CRAM_MD5" >> config.h |
232 |
|
|
else |
233 |
|
|
echo "#undef CRAM_MD5" >> config.h |
234 |
lefcha |
1.1 |
fi |
235 |
lefcha |
1.23 |
|
236 |
|
|
echo >> config.h; echo >> config.h |
237 |
|
|
echo "#endif /* CONFIG_H */" >> config.h |
238 |
lefcha |
1.1 |
|
239 |
|
|
|
240 |
|
|
exit 0 |