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