Beispiel #1
0
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);
}
Beispiel #2
0
function restart($nopid = false)
{
    $unix = new unix();
    $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
    if (!$nopid) {
        $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]: Already Artica task running PID {$pid} since {$time}mn\n";
            }
            return;
        }
    }
    @file_put_contents($pidfile, getmypid());
    build_progress_reconfigure("{stopping_service} {webserver}", 50);
    apache_stop(true);
    build_progress_reconfigure("{reconfiguring} {webserver}", 60);
    apache_config();
    build_progress_reconfigure("{starting_service} {webserver}", 80);
    apache_start(true);
    build_progress_reconfigure("{starting_service} {webserver} {done}", 85);
    build_progress_reconfigure2("{starting_service} {webserver} {done}", 100);
}
Beispiel #3
0
function installapt()
{
    if (!is_file("/etc/artica-postfix/settings/Daemons/SQUIDEnable")) {
        @file_put_contents("/etc/artica-postfix/settings/Daemons/SQUIDEnable", 1);
    }
    $GLOBALS["OUTPUT"] = true;
    @unlink($GLOBALS["LOGFILE"]);
    $unix = new unix();
    $mount = $unix->find_program("mount");
    $umount = $unix->find_program("umount");
    $tar = $unix->find_program("tar");
    $rm = $unix->find_program("rm");
    $git_proxy = null;
    $gem_proxy = null;
    $curl_proxy = null;
    $squidbin = $unix->LOCATE_SQUID_BIN();
    $SQUIDEnable = intval(@file_get_contents("/etc/artica-postfix/settings/Daemons/SQUIDEnable"));
    if ($SQUIDEnable == 1) {
        $SquidMgrListenPort = trim(@file_get_contents("/etc/artica-postfix/settings/Daemons/SquidMgrListenPort"));
        echo "* * * Force git to use http.proxy http://127.0.0.1:{$SquidMgrListenPort} * * *\n";
        $gem_proxy = "--http-proxy 127.0.0.1:{$SquidMgrListenPort}";
        $curl_proxy = "--proxy http://127.0.0.1:{$SquidMgrListenPort}";
        $git_proxy = "--global http.proxy http://127.0.0.1:{$SquidMgrListenPort}";
    }
    $prc = 20;
    echo "Please wait...\n";
    //-------------------------------------------------------------------------------------------------
    $prc++;
    if (!is_file("/usr/lib/x86_64-linux-gnu/libyaml.so")) {
        build_progress("{install_package} libyaml", $prc);
        build_progress_reconfigure("{install_package} libyaml", 46);
        $unix->DEBIAN_INSTALL_PACKAGE("libyaml-dev");
        if (!is_file("/usr/lib/x86_64-linux-gnu/libyaml.so")) {
            build_progress("{install_package} libyaml {failed_to_install}", 110);
            return;
        } else {
            echo "libyaml..........: OK\n";
        }
    }
    //-------------------------------------------------------------------------------------------------
    //-------------------------------------------------------------------------------------------------
    $prc++;
    if (!is_file("/usr/lib/perl5/Crypt/SSLeay.pm")) {
        build_progress("{install_package} libcrypt-ssleay-perl", $prc);
        build_progress_reconfigure("{install_package} libcrypt-ssleay-perl", 46);
        $unix->DEBIAN_INSTALL_PACKAGE("libcrypt-ssleay-perl");
        if (!is_file("/usr/lib/perl5/Crypt/SSLeay.pm")) {
            build_progress("{install_package} libcrypt-ssleay-perl {failed_to_install}", 110);
            return;
        } else {
            echo "libcrypt-ssleay-perl OK\n";
        }
    }
    //-------------------------------------------------------------------------------------------------
    $prc++;
    if (!is_file("/usr/lib/x86_64-linux-gnu/libpng.so")) {
        build_progress("{install_package} libpng12-dev", $prc);
        build_progress_reconfigure("{install_package} libpng12-dev", 46);
        $unix->DEBIAN_INSTALL_PACKAGE("libpng12-dev");
        if (!is_file("/usr/lib/x86_64-linux-gnu/libpng.so")) {
            build_progress("{install_package} libpng12-dev {failed_to_install}", 110);
            return;
        } else {
            echo "libpng12-dev.....: OK\n";
        }
    }
    $prc++;
    if (!is_file("/usr/lib/x86_64-linux-gnu/libgd.so")) {
        build_progress("{install_package} libgd2-xpm-dev", $prc);
        build_progress_reconfigure("{install_package} libgd2-xpm-dev", 46);
        $unix->DEBIAN_INSTALL_PACKAGE("libgd2-xpm-dev");
        if (!is_file("/usr/lib/x86_64-linux-gnu/libgd.so")) {
            build_progress("{install_package} libgd2-xpm-dev {failed_to_install}", 110);
            return;
        } else {
            echo "libgd2-xpm-dev.: OK\n";
        }
    }
    $prc++;
    if (!is_file("/usr/lib/x86_64-linux-gnu/libjansson.so.4")) {
        build_progress("{install_package} libjansson4", $prc);
        build_progress_reconfigure("{install_package} libjansson4", 47);
        $unix->DEBIAN_INSTALL_PACKAGE("libjansson4");
        if (!is_file("/usr/lib/x86_64-linux-gnu/libjansson.so.4")) {
            build_progress("{install_package} libjansson {failed_to_install}", 110);
            return;
        } else {
            echo "libjansson4......: OK\n";
        }
    }
    $prc++;
    if (!is_file("/usr/lib/x86_64-linux-gnu/libnss3.so")) {
        build_progress("{install_package} libnss3", $prc);
        build_progress_reconfigure("{install_package} libnss3", 47);
        $unix->DEBIAN_INSTALL_PACKAGE("libnss3");
        if (!is_file("/usr/lib/x86_64-linux-gnu/libnss3.so")) {
            build_progress("{install_package} libnss3 {failed_to_install}", 110);
            return;
        } else {
            echo "libnss3..........: OK\n";
        }
    }
    $prc++;
    if (!is_file("/usr/share/pyshared/yaml/__init__.py")) {
        build_progress("{install_package} python-yaml", $prc);
        build_progress_reconfigure("{install_package} python-yaml", 47);
        $unix->DEBIAN_INSTALL_PACKAGE("python-yaml");
        if (!is_file("/usr/share/pyshared/yaml/__init__.py")) {
            build_progress("{install_package} python-yaml {failed_to_install}", 110);
            return;
        } else {
            echo "python-yaml......: OK\n";
        }
    }
    $prc++;
    if (!is_file("/usr/share/pyshared/MySQLdb/__init__.py")) {
        build_progress("{install_package} python-mysqldb", $prc);
        build_progress_reconfigure("{install_package} python-mysqldb", 47);
        $unix->DEBIAN_INSTALL_PACKAGE("python-mysqldb");
        if (!is_file("/usr/share/pyshared/MySQLdb/__init__.py")) {
            build_progress("{install_package} python-mysqldb {failed_to_install}", 110);
            return;
        } else {
            echo "python-mysqldb...: OK\n";
        }
    }
    $prc++;
    if (!is_file("/usr/share/pyshared/psycopg2/__init__.py")) {
        build_progress("{install_package} python-psycopg2", $prc);
        build_progress_reconfigure("{install_package} python-psycopg2", 47);
        $unix->DEBIAN_INSTALL_PACKAGE("python-psycopg2");
        if (!is_file("/usr/share/pyshared/psycopg2/__init__.py")) {
            build_progress("{install_package} python-psycopg2 {failed_to_install}", 110);
            return;
        } else {
            echo "python-psycopg2..: OK\n";
        }
    }
    $prc++;
    if (!is_file("/usr/sbin/oinkmaster")) {
        build_progress_reconfigure("{install_package} oinkmaster", 48);
        build_progress("{install_package} oinkmaster", $prc);
        $unix->DEBIAN_INSTALL_PACKAGE("oinkmaster");
        if (!is_file("/usr/sbin/oinkmaster")) {
            build_progress("{install_package} oinkmaster {failed_to_install}", 110);
            return;
        } else {
            echo "oinkmaster.......: OK\n";
        }
    }
    //-------------------------------------------------------------------------------------------------
    return true;
}