comparison install.bash @ 1:45c8592d5d13

initial version
author carl
date Fri, 10 Mar 2006 10:35:25 -0800
parents
children
comparison
equal deleted inserted replaced
0:616666e2f34c 1:45c8592d5d13
1 #!/bin/bash
2
3 #####################
4 # stop the milter if it is already installed
5 if [ -f /etc/rc.d/init.d/dnsbl ]; then
6 /etc/rc.d/init.d/dnsbl stop
7 rm -f /etc/rc.d/init.d/dnsbl
8 fi
9
10
11 #####################
12 # build the milter
13 # add compiler flags - suggested by Nigel Horne
14 g++ -c $CXXFLAGS -pthread dnsbl.cpp scanner.cpp context.cpp tokenizer.cpp
15 if [ $? -ne 0 ]; then
16 echo "compiler errors"
17 exit
18 fi
19 g++ -o dnsbl dnsbl.o scanner.o context.o tokenizer.o /usr/lib/libresolv.a -lmilter -pthread
20 if [ $? -ne 0 ]; then
21 echo "linker errors"
22 exit
23 fi
24
25
26 #####################
27 # ensure the user is created
28 /usr/bin/getent passwd dnsbl || /usr/sbin/useradd -r -d /etc/dnsbl -M -c "dnsbl pseudo-user" -s /sbin/nologin dnsbl
29 # install the milter
30 DST=/etc/dnsbl
31 mkdir -p $DST
32 if [ -f /var/dnsbl/dnsbl.conf ]; then
33 # move the conf files to the new location
34 mv /var/dnsbl/*conf $DST
35 rm /var/dnsbl/dnsbl # remove the old binary
36 rmdir /var/dnsbl
37 fi
38 CONF=$DST/dnsbl.conf
39 if [ -f $CONF ]; then
40 grep '^context' $CONF >/dev/null
41 if [ $? -eq 1 ]; then
42 # config file exists, but it is for the older version
43 # preserve it and start over
44 suf=4.old
45 for i in dnsbl hosts-ignore html-tags tld; do
46 j=$DST/$i.conf
47 if [ -f $j ]; then
48 mv -f $j $j.$suf
49 fi
50 done
51 fi
52 fi
53 if [ ! -f $CONF ]; then
54 cp dnsbl.conf $DST
55 cp hosts-ignore.conf $DST
56 cp html-tags.conf $DST
57 cp tld.conf $DST
58 fi
59 if [ ! -f $DST/hosts-ignore.conf ]; then
60 cp hosts-ignore.conf $DST
61 fi
62 if [ ! -f $DST/html-tags.conf ]; then
63 cp html-tags.conf $DST
64 fi
65 rm -f $DST/tld.conf # new tld list
66 if [ ! -f $DST/tld.conf ]; then
67 cp tld.conf $DST
68 fi
69
70 # make the directory for the socket
71 mkdir -p /var/run/dnsbl
72 chown dnsbl:dnsbl /var/run/dnsbl
73 chmod 700 /var/run/dnsbl
74
75 # install the binaries
76 mv -f dnsbl /usr/sbin/dnsbl
77 cp dnsbl.rc /etc/rc.d/init.d/dnsbl
78 chmod 755 /etc/rc.d/init.d/dnsbl
79 /sbin/chkconfig --add dnsbl
80 /sbin/chkconfig --level 2345 dnsbl on
81 /etc/rc.d/init.d/dnsbl start