scripts: Fix lazy chown syntax
[hcoop/domtool2.git] / scripts / domtool-publish
1 #!/bin/sh -e
2
3 redo_exim() {
4 /bin/echo -n "domainlist local_domains = " >/etc/exim4/conf.d/main/10_domtool-domains
5 /bin/cat /var/domtool/local_domains.cfg >>/etc/exim4/conf.d/main/10_domtool-domains
6 /bin/echo "" >>/etc/exim4/conf.d/main/10_domtool-domains
7 /bin/echo -n "domainlist relay_to_domains = " >>/etc/exim4/conf.d/main/10_domtool-domains
8 /bin/cat /var/domtool/relay_domains.cfg >>/etc/exim4/conf.d/main/10_domtool-domains
9 /bin/echo "" >>/etc/exim4/conf.d/main/10_domtool-domains
10 /bin/echo -n "domainlist mm_domains = " >>/etc/exim4/conf.d/main/10_domtool-domains
11 /bin/cat /var/domtool/mailman_domains.cfg >>/etc/exim4/conf.d/main/10_domtool-domains
12 /bin/echo "" >>/etc/exim4/conf.d/main/10_domtool-domains
13 /etc/init.d/exim4 reload
14 }
15
16 case $1 in
17 apache)
18 /usr/bin/rsync -r --delete /var/domtool/vhosts/ /etc/apache2/vhosts/
19 /etc/init.d/apache2 reload
20 ;;
21 apache-down)
22 /etc/init.d/apache2 stop
23 ;;
24 apache-undown)
25 /usr/bin/rsync -r --delete /var/domtool/vhosts/ /etc/apache2/vhosts/
26 /etc/init.d/apache2 start
27 ;;
28 apache1.3)
29 /usr/bin/rsync -r --delete /var/domtool/vhosts/ /etc/apache/vhosts/
30 /etc/init.d/apache reload
31 ;;
32 apache1.3-down)
33 /etc/init.d/apache stop
34 ;;
35 apache1.3-undown)
36 /usr/bin/rsync -r --delete /var/domtool/vhosts/ /etc/apache/vhosts/
37 /etc/init.d/apache start
38 ;;
39 bind)
40 /usr/bin/rsync -r --delete /var/domtool/zones/ /etc/bind/zones/
41 /bin/chown -R bind /etc/bind/zones
42 /bin/cp /var/domtool/named.conf.local /etc/bind/
43 /bin/chown root:bind /etc/bind/named.conf.local
44 /bin/chmod 644 /etc/bind/named.conf.local
45 /etc/init.d/bind9 restart
46 ;;
47 exim)
48 /bin/cp /var/domtool/aliases /etc/aliases.hosted
49 /bin/cp /var/domtool/aliases.default /etc/aliases.wildcard
50 redo_exim
51 ;;
52 mailman)
53 /bin/echo "HCOOP_VHOSTS = {" >/etc/mailman/vhosts_cfg.py
54 /bin/cat /var/domtool/mailman.map >>/etc/mailman/vhosts_cfg.py
55 /bin/echo "}" >>/etc/mailman/vhosts_cfg.py
56 /etc/init.d/mailman reload
57 redo_exim
58 ;;
59 courier)
60 VMAILDB=`domtool-config -path vmaildb`
61 if [ -z "$VMAILDB" ]; then
62 echo "domtool-config not found, not syncing courier vmail userdb"
63 exit 1
64 fi
65 /usr/bin/rsync -r --delete ${VMAILDB}/ /etc/courier/userdb
66 /usr/sbin/makeuserdb
67 /bin/chown -R domtool:nogroup /etc/courier/userdb
68 /bin/cat /etc/courier/userdb/* >/etc/courier/exim
69 /bin/chmod o-r /etc/courier/exim
70 /usr/sbin/exim_dbmbuild /etc/courier/exim /etc/courier/exim.dat
71 /bin/chgrp mail /etc/courier/exim.dat
72 /bin/chmod o-r /etc/courier/exim.dat
73 ;;
74 spamassassin)
75 SHAREDROOT=`domtool-config -path shared-root`
76 /usr/bin/rsync -r --delete ${SHAREDROOT}/email/spamassassin/addrs/ /etc/spamassassin/addrs
77 ;;
78 smtplog)
79 /bin/grep $2 /var/log/exim4/mainlog
80 ;;
81 apache-fixperms)
82 /bin/chown -R domtool:nogroup /var/log/apache2/user
83 ;;
84 apache1.3-fixperms)
85 /bin/chown -R domtool:nogroup /var/log/apache/user
86 ;;
87 users)
88 /bin/cp /var/domtool/waklog.conf /etc/apache2/
89 /etc/init.d/apache2 reload
90 ;;
91 firewall)
92 # Ideally this would check if the config worked first
93 # (ferm failing just uses the previous config at
94 # least). Does it need to chown/chmod the generated
95 # rules?
96 /bin/cp /var/domtool/firewall/*.conf /etc/ferm/
97 /etc/init.d/ferm reload
98 ;;
99 *)
100 echo "Usage: domtool-publish [apache|bind|courier|exim|mailman|smtplog STRING|users|firewall]"
101 ;;
102 esac