apache: remove php5-cgi support, always generate php config
[hcoop/domtool2.git] / scripts / domtool-publish
index 3450703..31cc351 100755 (executable)
@@ -1,6 +1,13 @@
 #!/bin/sh -e
 
+# grab tokens in case they were dropped by sudo
+if [ -x "$(which aklog)" ]; then
+    # ignore exit code, may fail on older versions
+    aklog || true
+fi
+
 redo_exim() {
+        sudo -u domtool touch /var/domtool/local_domains.cfg /var/domtool/relay_domains.cfg /var/domtool/mailman_domains.cfg
        /bin/echo -n "domainlist local_domains = " >/etc/exim4/conf.d/main/10_domtool-domains
        /bin/cat /var/domtool/local_domains.cfg >>/etc/exim4/conf.d/main/10_domtool-domains
        /bin/echo "" >>/etc/exim4/conf.d/main/10_domtool-domains
@@ -10,31 +17,31 @@ redo_exim() {
        /bin/echo -n "domainlist mm_domains = " >>/etc/exim4/conf.d/main/10_domtool-domains
        /bin/cat /var/domtool/mailman_domains.cfg >>/etc/exim4/conf.d/main/10_domtool-domains
        /bin/echo "" >>/etc/exim4/conf.d/main/10_domtool-domains
-       /etc/init.d/exim4 reload
+       service exim4 reload
 }
 
 case $1 in
        apache)
                /usr/bin/rsync -r --delete /var/domtool/vhosts/ /etc/apache2/vhosts/
-               /etc/init.d/apache2 reload
+               service apache2 reload
        ;;
        apache-down)
-               /etc/init.d/apache2 stop
+               service apache2 stop
        ;;
        apache-undown)
                /usr/bin/rsync -r --delete /var/domtool/vhosts/ /etc/apache2/vhosts/
-               /etc/init.d/apache2 start
+               service apache2 start
        ;;
        apache1.3)
                /usr/bin/rsync -r --delete /var/domtool/vhosts/ /etc/apache/vhosts/
-               /etc/init.d/apache reload
+               service apache reload
        ;;
        apache1.3-down)
-               /etc/init.d/apache stop
+               service apache stop
        ;;
        apache1.3-undown)
                /usr/bin/rsync -r --delete /var/domtool/vhosts/ /etc/apache/vhosts/
-               /etc/init.d/apache start
+               service apache start
        ;;
        bind)
                /usr/bin/rsync -r --delete /var/domtool/zones/ /etc/bind/zones/
@@ -42,9 +49,10 @@ case $1 in
                /bin/cp /var/domtool/named.conf.local /etc/bind/
                /bin/chown root:bind /etc/bind/named.conf.local
                /bin/chmod 644 /etc/bind/named.conf.local
-               /etc/init.d/bind9 restart
+               service bind9 restart
        ;;
        exim)
+               sudo -u domtool touch /var/domtool/aliases /var/domtool/aliases.default
                /bin/cp /var/domtool/aliases /etc/aliases.hosted
                /bin/cp /var/domtool/aliases.default /etc/aliases.wildcard
                redo_exim
@@ -53,7 +61,7 @@ case $1 in
                 /bin/echo "HCOOP_VHOSTS = {" >/etc/mailman/vhosts_cfg.py
                /bin/cat /var/domtool/mailman.map >>/etc/mailman/vhosts_cfg.py
                 /bin/echo "}" >>/etc/mailman/vhosts_cfg.py
-               /etc/init.d/mailman reload
+               service mailman reload
                redo_exim
        ;;
        courier)
@@ -86,7 +94,7 @@ case $1 in
         ;;
         users)
                 /bin/cp /var/domtool/waklog.conf /etc/apache2/
-               /etc/init.d/apache2 reload
+               service apache2 reload
         ;;
         firewall)
               # Ideally this would check if the config worked first
@@ -94,14 +102,14 @@ case $1 in
               # least). Does it need to chown/chmod the generated
               # rules?
               /bin/cp /var/domtool/firewall/*.conf /etc/ferm/
-              /etc/init.d/ferm reload
+              service ferm reload
               ;;
        firewallpuppet)
               # new firewall publishing method that integrates with puppet (sort of)
               /bin/cp /var/domtool/firewall/*.conf /etc/ferm/
               if [ ! -d /etc/puppetlabs ]; then
                   # legacy node
-                  /etc/init.d/ferm reload
+                  service ferm reload
                   exit
               fi
               if ( /usr/sbin/ferm --noexec /etc/ferm/ferm.conf ); then