annotate install.bash @ 1:45c8592d5d13

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