function _start_instance($hostname){ if($hostname=="master"){return;} if(trim($hostname)==null){return;} $unix=new unix(); $main=new maincf_multi($hostname); $PostFixEnableQueueInMemory=$main->GET("PostFixEnableQueueInMemory"); $PostFixQueueInMemory=$main->GET("PostFixQueueInMemory"); $directory="/var/spool/postfix-$hostname"; if($PostFixEnableQueueInMemory==1){ reconfigure_instance_tmpfs($hostname,$PostFixQueueInMemory); }else{ $MOUNTED_TMPFS_MEM=$unix->MOUNTED_TMPFS_MEM($directory); if($MOUNTED_TMPFS_MEM>0){ reconfigure_instance_tmpfs_umount($hostname); } } $pidfile="/var/spool/postfix-$hostname/pid/master.pid"; if($GLOBALS["postmulti"]==null){$GLOBALS["postmulti"]=$unix->find_program("postmulti");} $pid=$unix->get_pid_from_file($pidfile); writelogs("$hostname:: Checking directories",__FUNCTION__,__FILE__,__LINE__); $main->CheckDirectories($hostname); writelogs("$hostname:: $pidfile=$pid",__FUNCTION__,__FILE__,__LINE__); if($unix->process_exists($pid)){ echo "Starting......: Postfix \"$hostname\" reloading\n"; writelogs("$hostname::reloading postfix {$GLOBALS["postmulti"]} -i postfix-$hostname -p reload",__FUNCTION__,__FILE__,__LINE__); exec("{$GLOBALS["postmulti"]} -i postfix-$hostname -p reload 2>&1",$results); while (list ($num, $line) = each ($results) ){ writelogs("$line",__FUNCTION__,__FILE__,__LINE__); echo "Starting......: Postfix \"$hostname\" $line\n"; if(preg_match("#fatal: open /etc/postfix-(.+?)\/main\.cf#",$line,$re)){ echo "Starting......: Postfix reconfigure \"{$re[1]}\"\n"; reconfigure_instance($re[1]); } } return; } echo "Starting......: Postfix starting \"$hostname\"\n"; writelogs("$hostname::Starting postfix {$GLOBALS["postmulti"]} -i postfix-$hostname -p start",__FUNCTION__,__FILE__,__LINE__); exec("{$GLOBALS["postmulti"]} -i postfix-$hostname -p start 2>&1",$results); writelogs("$hostname::Starting LOG=".count($results)." lines",__FUNCTION__,__FILE__,__LINE__); while (list ($num, $line) = each ($results) ){ writelogs("$line",__FUNCTION__,__FILE__,__LINE__); echo "Starting......: Postfix \"$hostname\" $line\n"; if(preg_match("#fatal: open /etc/postfix-(.+?)\/main\.cf#",$line,$re)){ echo "Starting......: Postfix reconfigure \"{$re[1]}\"\n"; reconfigure_instance($re[1]); } } $pid=$unix->get_pid_from_file($pidfile); for($i=0;$i<10;$i++){ if($unix->process_exists($pid)){break;} echo "Starting......: Postfix \"$hostname\" waiting run ($pid)\n"; sleep(1); } if($unix->process_exists($pid)){ echo "Starting......: Postfix \"$hostname\" SUCCESS with PID=$pid\n"; writelogs("$hostname::DONE",__FUNCTION__,__FILE__,__LINE__); return; } echo "Starting......: Postfix \"$hostname\" FAILED\n"; writelogs("$hostname::FAILED",__FUNCTION__,__FILE__,__LINE__); }
function _start_instance($hostname) { if ($hostname == "master") { return; } if (trim($hostname) == null) { return; } $unix = new unix(); $main = new maincf_multi($hostname); $PostFixEnableQueueInMemory = $main->GET("PostFixEnableQueueInMemory"); $PostFixQueueInMemory = $main->GET("PostFixQueueInMemory"); $ifconfig = $unix->find_program("ifconfig"); $ln = $unix->find_program("ln"); $route = $unix->find_program("route"); $directory = "/var/spool/postfix-{$hostname}"; $postfixbin = $unix->find_program("postfix"); if ($PostFixEnableQueueInMemory == 1) { reconfigure_instance_tmpfs($hostname, $PostFixQueueInMemory); } else { $MOUNTED_TMPFS_MEM = $unix->MOUNTED_TMPFS_MEM($directory); if ($MOUNTED_TMPFS_MEM > 0) { reconfigure_instance_tmpfs_umount($hostname); } } if (!is_file("/etc/postfix-{$hostname}/main.cf")) { echo "Starting......: " . date("H:i:s") . " Postfix \"{$hostname}\" /etc/postfix-{$hostname}/main.cf no such file (reconfigure)\n"; ConfigureMainCF($hostname, true); } $pidfile = "/var/spool/postfix-{$hostname}/pid/master.pid"; if ($GLOBALS["postmulti"] == null) { $GLOBALS["postmulti"] = $unix->find_program("postmulti"); } $pid = $unix->get_pid_from_file($pidfile); writelogs("{$hostname}:: Checking directories IP address={$main->ip_addr}", __FUNCTION__, __FILE__, __LINE__); $q = new mysql(); $sql = "SELECT * FROM nics_virtuals WHERE ipaddr='{$main->ip_addr}'"; $ligne = mysql_fetch_array($q->QUERY_SQL($sql, "artica_backup")); echo "Starting......: " . date("H:i:s") . " Postfix \"{$hostname}\" {$main->ip_addr} on {$ligne["nic"]}:{$ligne["ID"]}\n"; if ($ligne["ipv6"] == 0) { if ($ligne["ID"] > 0) { shell_exec("{$ifconfig} {$ligne["nic"]}:{$ligne["ID"]} {$main->ip_addr} >/dev/null 2>&1"); shell_exec("{$route} add -host {$main->ip_addr} dev {$ligne["nic"]}:{$ligne["ID"]} >/dev/null 2>&1"); } } $main->CheckDirectories($hostname); writelogs("{$hostname}:: {$pidfile}={$pid}", __FUNCTION__, __FILE__, __LINE__); if ($unix->process_exists($pid)) { echo "Starting......: " . date("H:i:s") . " Postfix \"{$hostname}\" reloading\n"; writelogs("{$hostname}::reloading postfix {$GLOBALS["postmulti"]} -i postfix-{$hostname} -p reload", __FUNCTION__, __FILE__, __LINE__); exec("{$GLOBALS["postmulti"]} -i postfix-{$hostname} -p reload 2>&1", $results); while (list($num, $line) = each($results)) { if (preg_match("#unused parameter#", $line)) { continue; } writelogs("{$line}", __FUNCTION__, __FILE__, __LINE__); echo "Starting......: " . date("H:i:s") . " Postfix \"{$hostname}\" {$line}\n"; if (preg_match("#fatal: open /etc/postfix-(.+?)\\/main\\.cf#", $line, $re)) { echo "Starting......: " . date("H:i:s") . " Postfix reconfigure \"{$re[1]}\"\n"; reconfigure_instance($re[1]); } } return; } echo "Starting......: " . date("H:i:s") . " Postfix starting \"{$hostname}\"\n"; writelogs("{$hostname}::Starting postfix {$GLOBALS["postmulti"]} -i postfix-{$hostname} -p start", __FUNCTION__, __FILE__, __LINE__); exec("{$GLOBALS["postmulti"]} -i postfix-{$hostname} -p start 2>&1", $results); writelogs("{$hostname}::Starting LOG=" . count($results) . " lines", __FUNCTION__, __FILE__, __LINE__); while (list($num, $line) = each($results)) { if (preg_match("#unused parameter:#", $line)) { continue; } writelogs("{$line}", __FUNCTION__, __FILE__, __LINE__); echo "Starting......: " . date("H:i:s") . " Postfix \"{$hostname}\" {$line}\n"; if (preg_match("#fatal: open /etc/postfix-(.+?)\\/main\\.cf#", $line, $re)) { echo "Starting......: " . date("H:i:s") . " Postfix reconfigure \"{$re[1]}\"\n"; reconfigure_instance($re[1]); } } $pid = $unix->get_pid_from_file($pidfile); for ($i = 0; $i < 10; $i++) { if ($GLOBALS["VERBOSE"]) { echo "Starting......: " . date("H:i:s") . " Postfix \"{$hostname}\" DEBUG open \"{$pidfile}\"\n"; } if ($unix->process_exists($pid)) { break; } echo "Starting......: " . date("H:i:s") . " Postfix \"{$hostname}\" waiting run ({$pid})\n"; sleep(1); $pid = $unix->get_pid_from_file($pidfile); } $pid = $unix->get_pid_from_file($pidfile); if ($unix->process_exists($pid)) { echo "Starting......: " . date("H:i:s") . " Postfix \"{$hostname}\" SUCCESS with PID={$pid}\n"; writelogs("{$hostname}::DONE", __FUNCTION__, __FILE__, __LINE__); return; } echo "Starting......: " . date("H:i:s") . " Postfix \"{$hostname}\" FAILED\n"; writelogs("{$hostname}::FAILED", __FUNCTION__, __FILE__, __LINE__); }
function _start_instance($hostname) { if (trim($hostname) == null) { return; } $pidfile = "/var/spool/postfix-{$hostname}/pid/master.pid"; $unix = new unix(); if ($GLOBALS["postmulti"] == null) { $GLOBALS["postmulti"] = $unix->find_program("postmulti"); } $pid = $unix->get_pid_from_file($pidfile); $main = new maincf_multi(); writelogs("{$hostname}:: Checking directories", __FUNCTION__, __FILE__, __LINE__); $main->CheckDirectories($hostname); writelogs("{$hostname}:: {$pidfile}={$pid}", __FUNCTION__, __FILE__, __LINE__); if ($unix->process_exists($pid)) { echo "Starting......: Postfix reloading \"{$hostname}\"\n"; writelogs("{$hostname}::reloading postfix {$GLOBALS["postmulti"]} -i postfix-{$hostname} -p reload", __FUNCTION__, __FILE__, __LINE__); exec("{$GLOBALS["postmulti"]} -i postfix-{$hostname} -p reload 2>&1", $results); while (list($num, $line) = each($results)) { writelogs("{$line}", __FUNCTION__, __FILE__, __LINE__); echo "Starting......: Postfix \"{$instance}\" {$line}\n"; if (preg_match("#fatal: open /etc/postfix-(.+?)\\/main\\.cf#", $line, $re)) { echo "Starting......: Postfix reconfigure \"{$re[1]}\"\n"; reconfigure_instance($re[1]); } } return; } echo "Starting......: Postfix starting \"{$hostname}\"\n"; writelogs("{$hostname}::Starting postfix {$GLOBALS["postmulti"]} -i postfix-{$hostname} -p start", __FUNCTION__, __FILE__, __LINE__); exec("{$GLOBALS["postmulti"]} -i postfix-{$hostname} -p start 2>&1", $results); writelogs("{$hostname}::Starting LOG=" . count($results) . " lines", __FUNCTION__, __FILE__, __LINE__); while (list($num, $line) = each($results)) { writelogs("{$line}", __FUNCTION__, __FILE__, __LINE__); echo "Starting......: Postfix \"{$hostname}\" {$line}\n"; if (preg_match("#fatal: open /etc/postfix-(.+?)\\/main\\.cf#", $line, $re)) { echo "Starting......: Postfix reconfigure \"{$re[1]}\"\n"; reconfigure_instance($re[1]); } } $pid = $unix->get_pid_from_file($pidfile); for ($i = 0; $i < 10; $i++) { if ($unix->process_exists($pid)) { break; } echo "Starting......: Postfix \"{$hostname}\" waiting run ({$pid})\n"; sleep(1); } if ($unix->process_exists($pid)) { echo "Starting......: Postfix \"{$hostname}\" SUCCESS with PID={$pid}\n"; writelogs("{$hostname}::DONE", __FUNCTION__, __FILE__, __LINE__); return; } echo "Starting......: Postfix \"{$hostname}\" FAILED\n"; writelogs("{$hostname}::FAILED", __FUNCTION__, __FILE__, __LINE__); }