diff --git a/config.inc.php b/config.inc.php
index eb13fe2d..ab0670fd 100644
--- a/config.inc.php
+++ b/config.inc.php
@@ -306,6 +306,13 @@ $CONF['show_custom_colors']=array("lightgreen","lightblue");
// prevent the web-server from executing external scripts.
// $CONF['mailbox_postdeletion_script']='sudo -u courier /usr/local/bin/postfixadmin-mailbox-postdeletion.sh';
+// Optional:
+// Script to run after creation of domains.
+// Note that this may fail if PHP is run in "safe mode", or if
+// operating system features (such as SELinux) or limitations
+// prevent the web-server from executing external scripts.
+$CONF['domain_postcreation_script']='sudo -u courier /usr/local/bin/postfixadmin-domain-postcreation.sh';
+
// Optional:
// Script to run after deletion of domains.
// Note that this may fail if PHP is run in "safe mode", or if
diff --git a/create-domain.php b/create-domain.php
index b6758c70..97beacf1 100644
--- a/create-domain.php
+++ b/create-domain.php
@@ -136,6 +136,10 @@ if ($_SERVER['REQUEST_METHOD'] == "POST")
}
$tMessage = $PALANG['pAdminCreate_domain_result_success'] . "
($fDomain)";
}
+ if (!domain_postcreation($fDomain))
+ {
+ $tMessage = $PALANG['pAdminCreate_domain_error'];
+ }
}
}
diff --git a/functions.inc.php b/functions.inc.php
index 4779d32a..27310414 100644
--- a/functions.inc.php
+++ b/functions.inc.php
@@ -1804,6 +1804,42 @@ function mailbox_postdeletion($username,$domain)
return TRUE;
}
+/*
+ Called after a domain has been added in the DBMS.
+ Returns: boolean.
+ */
+function domain_postcreation($domain)
+{
+ global $CONF;
+ $confpar='domain_postcreation_script';
+
+ if (!isset($CONF[$confpar]) || empty($CONF[$confpar]))
+ {
+ return true;
+ }
+
+ if (empty($domain))
+ {
+ print '
Warning: empty domain parameter.
'; + return false; + } + + $cmdarg1=escapeshellarg($domain); + $command=$CONF[$confpar]." $cmdarg1"; + $retval=0; + $output=array(); + $firstline=''; + $firstline=exec($command,$output,$retval); + if (0!=$retval) + { + error_log("Running $command yielded return value=$retval, first line of output=$firstline"); + print 'WARNING: Problems running domain postcreation script!
'; + return FALSE; + } + + return TRUE; +} + /* Called after a domain has been deleted in the DBMS. Returns: boolean.