fwtool: initial ipv6 support and puppet integration
[hcoop/domtool2.git] / scripts / domtool-publish
index da032fe..3450703 100755 (executable)
@@ -40,8 +40,8 @@ case $1 in
                /usr/bin/rsync -r --delete /var/domtool/zones/ /etc/bind/zones/
                /bin/chown -R bind /etc/bind/zones
                /bin/cp /var/domtool/named.conf.local /etc/bind/
-               /bin/chown root:bind_config /etc/bind/named.conf.local
-               /bin/chmod u=rw,g=rw,o=r /etc/bind/named.conf.local
+               /bin/chown root:bind /etc/bind/named.conf.local
+               /bin/chmod 644 /etc/bind/named.conf.local
                /etc/init.d/bind9 restart
        ;;
        exim)
@@ -57,22 +57,32 @@ case $1 in
                redo_exim
        ;;
        courier)
+               VMAILDB=`domtool-config -path vmaildb`
+               if [ -z "$VMAILDB" ]; then
+                   echo "domtool-config not found, not syncing courier vmail userdb"
+                   exit 1
+               fi
+               /usr/bin/rsync -r --delete ${VMAILDB}/ /etc/courier/userdb
                /usr/sbin/makeuserdb
-               /bin/chown -R domtool.nogroup /etc/courier/userdb
+               /bin/chown -R domtool:nogroup /etc/courier/userdb
                /bin/cat /etc/courier/userdb/* >/etc/courier/exim
                /bin/chmod o-r /etc/courier/exim
                /usr/sbin/exim_dbmbuild /etc/courier/exim /etc/courier/exim.dat
                /bin/chgrp mail /etc/courier/exim.dat
                /bin/chmod o-r /etc/courier/exim.dat
        ;;
+        spamassassin)
+               SHAREDROOT=`domtool-config -path shared-root`
+               /usr/bin/rsync -r --delete ${SHAREDROOT}/email/spamassassin/addrs/ /etc/spamassassin/addrs
+       ;;
        smtplog)
                /bin/grep $2 /var/log/exim4/mainlog
        ;;
         apache-fixperms)
-                /bin/chown -R domtool.nogroup /var/log/apache2/user
+                /bin/chown -R domtool:nogroup /var/log/apache2/user
         ;;
         apache1.3-fixperms)
-                /bin/chown -R domtool.nogroup /var/log/apache/user
+                /bin/chown -R domtool:nogroup /var/log/apache/user
         ;;
         users)
                 /bin/cp /var/domtool/waklog.conf /etc/apache2/
@@ -85,6 +95,26 @@ case $1 in
               # rules?
               /bin/cp /var/domtool/firewall/*.conf /etc/ferm/
               /etc/init.d/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
+                  exit
+              fi
+              if ( /usr/sbin/ferm --noexec /etc/ferm/ferm.conf ); then
+                  for chain in FERM-INPUT FERM-OUTPUT; do
+                      /sbin/iptables -F $chain
+                      /sbin/ip6tables -F $chain
+
+                      /usr/sbin/ferm --domain ip  --noexec --lines /etc/ferm/ferm.conf | iptables-restore --noflush
+                              /usr/sbin/ferm --domain ip6 --noexec --lines /etc/ferm/ferm.conf | ip6tables-restore --noflush
+                  done
+              else
+                  echo "firewall: ferm failed, aborting regeneration."
+              fi
        ;;
        *)
                echo "Usage: domtool-publish [apache|bind|courier|exim|mailman|smtplog STRING|users|firewall]"