function start() { $unix = new unix(); $pidfile = $GLOBALS["MYPID"]; $WORKDIR = $GLOBALS["WORKDIR"]; $SERV_NAME = $GLOBALS["SERV_NAME"]; $mysql_pid_file = "/var/run/amavis-db.pid"; $MYSQL_SOCKET = "/var/run/mysqld/amavis-db.sock"; $mysqlserv = new mysql_services(); $mysqlserv->WORKDIR = $GLOBALS["WORKDIR"]; $mysqlserv->MYSQL_PID_FILE = $mysql_pid_file; $mysqlserv->MYSQL_SOCKET = $MYSQL_SOCKET; $mysqlserv->SERV_NAME = $SERV_NAME; $mysqlserv->TokenParams = "AmavisDBMysqlParams"; $mysqlserv->InnoDB = true; $pid = $unix->get_pid_from_file($pidfile); $sock = new sockets(); $AmavisPerUser = $sock->GET_INFO("AmavisPerUser"); if (!is_numeric($AmavisPerUser)) { $AmavisPerUser = 0; } $EnableStopPostfix = $sock->GET_INFO("EnableStopPostfix"); if (!is_numeric($EnableStopPostfix)) { $EnableStopPostfix = 0; } if ($EnableStopPostfix == 1) { $AmavisPerUser = 0; } if ($unix->process_exists($pid, basename(__FILE__))) { $time = $unix->PROCCESS_TIME_MIN($pid); if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]: Starting Task Already running PID {$pid} since {$time}mn\n"; } return; } @file_put_contents($pidfile, getmypid()); $mysql_install_db = $unix->find_program("mysql_install_db"); if ($AmavisPerUser == 0) { if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]:{$SERV_NAME} is disabled...\n"; } stop(); die(0); } $mysqld = $unix->find_program("mysqld"); if (!is_file($mysqld)) { if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]:{$SERV_NAME} is not installed...\n"; } return; } if (!is_file($mysql_install_db)) { if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]:{$SERV_NAME} mysql_install_db no such binary...\n"; } return; } $pid = DBPID(); if ($unix->process_exists($pid)) { $time = $unix->PROCCESS_TIME_MIN($pid); if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]:{$SERV_NAME} MySQL Database Engine already running pid {$pid} since {$time}mn\n"; } return; } if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]:{$SERV_NAME} writing init.d\n"; } initd(); $TMP = $unix->FILE_TEMP(); $cmdline = $mysqlserv->BuildParams(); $nohup = $unix->find_program("nohup"); if ($GLOBALS["VERBOSE"]) { echo $cmdline . "\n"; } if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]:{$SERV_NAME} Starting MySQL daemon ({$SERV_NAME})\n"; } shell_exec("{$nohup} {$cmdline} >{$TMP} 2>&1 &"); sleep(1); for ($i = 0; $i < 10; $i++) { $pid = DBPID(); if ($unix->process_exists($pid)) { if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]:{$SERV_NAME} MySQL daemon ({$SERV_NAME}) started pid .{$pid}..\n"; } break; } if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]: MySQL daemon wait {$i}/10\n"; } sleep(1); } sleep(1); $pid = DBPID(); if (!$unix->process_exists($pid)) { if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]:{$SERV_NAME} MySQL daemon ({$SERV_NAME}) failed to start\n"; } $f = explode("\n", @file_get_contents($TMP)); while (list($num, $ligne) = each($TMP)) { if (trim($ligne) == null) { continue; } if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]:{$SERV_NAME} {$ligne}\n"; } } } else { if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]:{$SERV_NAME} MySQL daemon ({$SERV_NAME}) success\n"; } $q = new amavisdb(); $q->checkTables(); } if (!$unix->process_exists($pid)) { if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]:{$SERV_NAME} {$cmdline}\n"; } } $unix->THREAD_COMMAND_SET($unix->LOCATE_PHP5_BIN() . " " . __FILE__ . " --databasesize"); }
function tabs() { $amavisdb = new amavisdb(); $amavisdb->checkTables(); $page = CurrentPageName(); $tpl = new templates(); $t = time(); $boot = new boostrap_form(); $array["{policies}"] = "{$page}?policies=yes"; $array["{domains_policies}"] = "miniadm.messaging.ou.amavis.domains.php"; echo $boot->build_tab($array); }