apache: remove php5-cgi support, always generate php config
[hcoop/domtool2.git] / scripts / domtool-publish
1 #!/bin/sh -e
2
3 # grab tokens in case they were dropped by sudo
4 if [ -x "$(which aklog)" ]; then
5 # ignore exit code, may fail on older versions
6 aklog || true
7 fi
8
9 redo_exim() {
10 sudo -u domtool touch /var/domtool/local_domains.cfg /var/domtool/relay_domains.cfg /var/domtool/mailman_domains.cfg
11 /bin/echo -n "domainlist local_domains = " >/etc/exim4/conf.d/main/10_domtool-domains
12 /bin/cat /var/domtool/local_domains.cfg >>/etc/exim4/conf.d/main/10_domtool-domains
13 /bin/echo "" >>/etc/exim4/conf.d/main/10_domtool-domains
14 /bin/echo -n "domainlist relay_to_domains = " >>/etc/exim4/conf.d/main/10_domtool-domains
15 /bin/cat /var/domtool/relay_domains.cfg >>/etc/exim4/conf.d/main/10_domtool-domains
16 /bin/echo "" >>/etc/exim4/conf.d/main/10_domtool-domains
17 /bin/echo -n "domainlist mm_domains = " >>/etc/exim4/conf.d/main/10_domtool-domains
18 /bin/cat /var/domtool/mailman_domains.cfg >>/etc/exim4/conf.d/main/10_domtool-domains
19 /bin/echo "" >>/etc/exim4/conf.d/main/10_domtool-domains
20 service exim4 reload
21 }
22
23 case $1 in
24 apache)
25 /usr/bin/rsync -r --delete /var/domtool/vhosts/ /etc/apache2/vhosts/
26 service apache2 reload
27 ;;
28 apache-down)
29 service apache2 stop
30 ;;
31 apache-undown)
32 /usr/bin/rsync -r --delete /var/domtool/vhosts/ /etc/apache2/vhosts/
33 service apache2 start
34 ;;
35 apache1.3)
36 /usr/bin/rsync -r --delete /var/domtool/vhosts/ /etc/apache/vhosts/
37 service apache reload
38 ;;
39 apache1.3-down)
40 service apache stop
41 ;;
42 apache1.3-undown)
43 /usr/bin/rsync -r --delete /var/domtool/vhosts/ /etc/apache/vhosts/
44 service apache start
45 ;;
46 bind)
47 /usr/bin/rsync -r --delete /var/domtool/zones/ /etc/bind/zones/
48 /bin/chown -R bind /etc/bind/zones
49 /bin/cp /var/domtool/named.conf.local /etc/bind/
50 /bin/chown root:bind /etc/bind/named.conf.local
51 /bin/chmod 644 /etc/bind/named.conf.local
52 service bind9 restart
53 ;;
54 exim)
55 sudo -u domtool touch /var/domtool/aliases /var/domtool/aliases.default
56 /bin/cp /var/domtool/aliases /etc/aliases.hosted
57 /bin/cp /var/domtool/aliases.default /etc/aliases.wildcard
58 redo_exim
59 ;;
60 mailman)
61 /bin/echo "HCOOP_VHOSTS = {" >/etc/mailman/vhosts_cfg.py
62 /bin/cat /var/domtool/mailman.map >>/etc/mailman/vhosts_cfg.py
63 /bin/echo "}" >>/etc/mailman/vhosts_cfg.py
64 service mailman reload
65 redo_exim
66 ;;
67 courier)
68 VMAILDB=`domtool-config -path vmaildb`
69 if [ -z "$VMAILDB" ]; then
70 echo "domtool-config not found, not syncing courier vmail userdb"
71 exit 1
72 fi
73 /usr/bin/rsync -r --delete ${VMAILDB}/ /etc/courier/userdb
74 /usr/sbin/makeuserdb
75 /bin/chown -R domtool:nogroup /etc/courier/userdb
76 /bin/cat /etc/courier/userdb/* >/etc/courier/exim
77 /bin/chmod o-r /etc/courier/exim
78 /usr/sbin/exim_dbmbuild /etc/courier/exim /etc/courier/exim.dat
79 /bin/chgrp mail /etc/courier/exim.dat
80 /bin/chmod o-r /etc/courier/exim.dat
81 ;;
82 spamassassin)
83 SHAREDROOT=`domtool-config -path shared-root`
84 /usr/bin/rsync -r --delete ${SHAREDROOT}/email/spamassassin/addrs/ /etc/spamassassin/addrs
85 ;;
86 smtplog)
87 /bin/grep $2 /var/log/exim4/mainlog
88 ;;
89 apache-fixperms)
90 /bin/chown -R domtool:nogroup /var/log/apache2/user
91 ;;
92 apache1.3-fixperms)
93 /bin/chown -R domtool:nogroup /var/log/apache/user
94 ;;
95 users)
96 /bin/cp /var/domtool/waklog.conf /etc/apache2/
97 service apache2 reload
98 ;;
99 firewall)
100 # Ideally this would check if the config worked first
101 # (ferm failing just uses the previous config at
102 # least). Does it need to chown/chmod the generated
103 # rules?
104 /bin/cp /var/domtool/firewall/*.conf /etc/ferm/
105 service ferm reload
106 ;;
107 firewallpuppet)
108 # new firewall publishing method that integrates with puppet (sort of)
109 /bin/cp /var/domtool/firewall/*.conf /etc/ferm/
110 if [ ! -d /etc/puppetlabs ]; then
111 # legacy node
112 service ferm reload
113 exit
114 fi
115 if ( /usr/sbin/ferm --noexec /etc/ferm/ferm.conf ); then
116 for chain in FERM-INPUT FERM-OUTPUT; do
117 /sbin/iptables -F $chain
118 /sbin/ip6tables -F $chain
119
120 /usr/sbin/ferm --domain ip --noexec --lines /etc/ferm/ferm.conf | iptables-restore --noflush
121 /usr/sbin/ferm --domain ip6 --noexec --lines /etc/ferm/ferm.conf | ip6tables-restore --noflush
122 done
123 else
124 echo "firewall: ferm failed, aborting regeneration."
125 fi
126 ;;
127 *)
128 echo "Usage: domtool-publish [apache|bind|courier|exim|mailman|smtplog STRING|users|firewall]"
129 ;;
130 esac