function apache_start() { $unix = new unix(); $apachebin = $unix->LOCATE_APACHE_BIN_PATH(); $sock = new sockets(); $pid = apache_pid(); $EnableArticaHotSpot = intval($sock->GET_INFO("EnableArticaHotSpot")); $SquidHotSpotPort = $sock->GET_INFO("SquidHotSpotPort"); $ArticaHotSpotPort = $sock->GET_INFO("ArticaHotSpotPort"); $ArticaSSLHotSpotPort = $sock->GET_INFO("ArticaSSLHotSpotPort"); $ArticaSplashHotSpotPort = $sock->GET_INFO("ArticaSplashHotSpotPort"); $ArticaSplashHotSpotPortSSL = $sock->GET_INFO("ArticaSplashHotSpotPortSSL"); if (!is_numeric($ArticaHotSpotPort)) { $ArticaHotSpotPort = 0; } if (!is_numeric($ArticaSplashHotSpotPort)) { $ArticaSplashHotSpotPort = 16080; } if (!is_numeric($ArticaSplashHotSpotPortSSL)) { $ArticaSplashHotSpotPortSSL = 16443; } if ($unix->process_exists($pid)) { $timepid = $unix->PROCCESS_TIME_MIN($pid); if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} already started {$pid} since {$timepid}Mn...\n"; } if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} Listen HTTP on {$ArticaSplashHotSpotPort} SSL on {$ArticaSplashHotSpotPortSSL}\n"; } return; } if ($EnableArticaHotSpot == 0) { if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} disabled (see EnableArticaHotSpot)\n"; } apache_stop(true); return; } $nohup = $unix->find_program("nohup"); $php5 = $unix->LOCATE_PHP5_BIN(); $apache2ctl = $unix->LOCATE_APACHE_BIN_PATH(); $rm = $unix->find_program("rm"); apache_config(); if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} removing caches and sessions\n"; } shell_exec("{$rm} -rf /home/artica/hotspot/caches/*"); shell_exec("{$rm} -rf /home/artica/hotspot/sessions/*"); $cmd = "{$apache2ctl} -f /etc/artica-postfix/hotspot-httpd.conf -k start"; shell_exec($cmd); for ($i = 0; $i < 6; $i++) { $pid = apache_pid(); if ($unix->process_exists($pid)) { break; } if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} waiting {$i}/6...\n"; } sleep(1); } $pid = apache_pid(); if ($unix->process_exists($pid)) { if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} Success service started pid:{$pid}...\n"; } } else { if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} failed...\n"; } if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]: {$cmd}\n"; } } }
function apache_start() { $unix = new unix(); $apachebin = $unix->LOCATE_APACHE_BIN_PATH(); $sock = new sockets(); $pid = apache_pid(); $SquidEnforceRules = intval($sock->GET_INFO("SquidEnforceRules")); $HyperCacheHTTPListenPort = $sock->GET_INFO("HyperCacheHTTPListenPort"); $HyperCacheHTTPListenPortSSL = $sock->GET_INFO("HyperCacheHTTPListenPortSSL"); if (!is_numeric($HyperCacheHTTPListenPort)) { $HyperCacheHTTPListenPort = 8700; } if (!is_numeric($HyperCacheHTTPListenPortSSL)) { $HyperCacheHTTPListenPortSSL = 8900; } if ($unix->process_exists($pid)) { $timepid = $unix->PROCCESS_TIME_MIN($pid); if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} already started {$pid} since {$timepid}Mn...\n"; } if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} Listen HTTP on {$HyperCacheHTTPListenPort} SSL on {$HyperCacheHTTPListenPortSSL}\n"; } return; } if ($SquidEnforceRules == 0) { if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} disabled (see SquidEnforceRules)\n"; } apache_stop(true); return; } $nohup = $unix->find_program("nohup"); $php5 = $unix->LOCATE_PHP5_BIN(); $apache2ctl = $unix->LOCATE_APACHE_BIN_PATH(); apache_config(); $cmd = "{$apache2ctl} -f /etc/artica-postfix/HyperCacheHTTPD.conf -k start"; shell_exec($cmd); for ($i = 0; $i < 6; $i++) { $pid = apache_pid(); if ($unix->process_exists($pid)) { break; } if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} waiting {$i}/6...\n"; } sleep(1); } $pid = apache_pid(); if ($unix->process_exists($pid)) { if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} Success service started pid:{$pid}...\n"; } } else { if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} failed...\n"; } if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]: {$cmd}\n"; } } }
function apache_start() { $unix = new unix(); $GLOBALS["SERVICE_NAME"] = "Artica Apache service"; $apachebin = $unix->LOCATE_APACHE_BIN_PATH(); $pid = apache_pid(); if ($unix->process_exists($pid)) { $timepid = $unix->PROCCESS_TIME_MIN($pid); if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} already started {$pid} since {$timepid}Mn...\n"; } return; } $nohup = $unix->find_program("nohup"); $php5 = $unix->LOCATE_PHP5_BIN(); $rm = $unix->find_program("rm"); $apache2ctl = $unix->LOCATE_APACHE_CTL(); apache_config(); $cmd = "{$nohup} {$php5} /usr/share/artica-postfix/exec.web-community-filter.php --register-lic >/dev/null 2>&1 &"; if ($GLOBALS["VERBOSE"]) { echo "{$cmd}\n"; } shell_exec($cmd); $cmd = "{$apache2ctl} -f /etc/artica-postfix/httpd.conf -k start"; shell_exec($cmd); for ($i = 0; $i < 6; $i++) { $pid = apache_pid(); if ($unix->process_exists($pid)) { break; } if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} waiting {$i}/6...\n"; } sleep(1); } $pid = apache_pid(); if ($unix->process_exists($pid)) { if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} Success service started pid:{$pid}...\n"; } shell_exec("{$php5} /usr/share/artica-postfix/exec.apc.compile.php"); if (!is_file('/etc/init.d/artica-memcache')) { shell_exec("{$php5} /usr/share/artica-postfix/exec.initslapd.php --memcache"); } shell_exec("{$nohup} {$php5} /usr/share/artica-postfix/exec.shm.php --SessionMem >/dev/null 2>&1 &"); shell_exec("{$nohup} {$php5} /usr/share/artica-postfix/exec.shm.php --service-up >/dev/null 2>&1 &"); shell_exec("{$nohup} {$php5} /usr/share/artica-postfix/exec.initslapd.php --phppfm-restart-back >/dev/null 2>&1 &"); shell_exec("{$nohup} /etc/init.d/artica-memcached start >/dev/null 2>&1 &"); shell_exec("{$nohup} /etc/init.d/monit restart >/dev/null 2>&1 &"); } else { if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} failed...\n"; } if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]: {$cmd}\n"; } apache_troubleshoot(); } $APACHE_SRC_ACCOUNT = $unix->APACHE_SRC_ACCOUNT(); $APACHE_SRC_GROUP = $unix->APACHE_SRC_GROUP(); $unix->chown_func($APACHE_SRC_ACCOUNT, $APACHE_SRC_GROUP, "/var/lib/php5/*"); }
function RECONFIGURE_PROGRESS() { $unix = new unix(); $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid"; $pid = $unix->get_pid_from_file($pidfile); if ($unix->process_exists($pid, basename(__FILE__))) { $time = $unix->PROCCESS_TIME_MIN($pid); if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]}: Already Artica task running PID {$pid} since {$time}mn\n"; } build_progress_reconfigure("{failed}", 110); return; } $sock = new sockets(); $ArticaHotSpotEnableMIT = $sock->GET_INFO("ArticaHotSpotEnableMIT"); $ArticaHotSpotEnableProxy = $sock->GET_INFO("ArticaHotSpotEnableProxy"); if (!is_numeric($ArticaHotSpotEnableMIT)) { $ArticaHotSpotEnableMIT = 1; } if (!is_numeric($ArticaHotSpotEnableProxy)) { $ArticaHotSpotEnableProxy = 1; } $proxyRestart = 0; if ($ArticaHotSpotEnableMIT == 1) { $proxyRestart = 1; } if ($ArticaHotSpotEnableProxy == 1) { $proxyRestart = 1; } $php = $unix->LOCATE_PHP5_BIN(); build_progress_reconfigure("{reconfigure_hostpot_service}", 5); build_progress_reconfigure("{stopping_service} Hostpot", 10); stop(true); build_progress_reconfigure("Building templates", 20); sleep(2); shell_exec("{$php} /usr/share/artica-postfix/hostpot.php --templates"); build_progress_reconfigure("{building_parameters}", 30); buildconfig(); sleep(2); build_progress_reconfigure("{starting_service} Hostpot", 40); start(true); if ($proxyRestart == 1) { build_progress_reconfigure("{reconfigure_proxy_service}", 50); system("{$php} /usr/share/artica-postfix/exec.squid.php --build --force"); } build_progress_reconfigure("{reconfiguring} {webserver}", 60); system("{$php} /usr/share/artica-postfix/exec.hostpot-web.php --build"); sleep(2); build_progress_reconfigure("{restarting} {webserver}", 70); system("{$php} /usr/share/artica-postfix/exec.hostpot-web.php --restart --force"); sleep(2); $pid = PID_NUM(); if (!$unix->process_exists($pid)) { build_progress_reconfigure("{starting_service} HotSpot {failed}", 110); return; } build_progress_reconfigure("{starting_service} HotSpot {success}", 95); $pid = apache_pid(); if (!$unix->process_exists($pid)) { build_progress_reconfigure("{starting_service} {webserver} {failed}", 110); return; } build_progress_reconfigure("{starting_service} {webserver} {success}", 98); sleep(3); build_progress_reconfigure("{reconfigure_hostpot_service} {done}", 100); }