Esempio n. 1
0
function PID_NUM()
{
    $unix = new unix();
    $pid = $unix->get_pid_from_file("/var/run/zarafa-web/httpd.pid");
    if ($unix->process_exists($pid)) {
        return $pid;
    }
    $apachebin = $unix->LOCATE_APACHE_BIN_PATH();
    return $unix->PIDOF_PATTERN("{$apachebin}.*?/etc/zarafa/httpd.conf");
}
Esempio n. 2
0
function build()
{
    $unix = new unix();
    $sock = new sockets();
    $EnableSNMPD = $sock->GET_INFO("EnableSNMPD");
    $SNMPDNetwork = $sock->GET_INFO("SNMPDNetwork");
    if ($SNMPDNetwork == null) {
        $SNMPDNetwork = "default";
    }
    if (!is_numeric($EnableSNMPD)) {
        $EnableSNMPD = 0;
    }
    $SNMPDCommunity = $sock->GET_INFO("SNMPDCommunity");
    if ($SNMPDCommunity == null) {
        $SNMPDCommunity = "public";
    }
    $EnableProxyInSNMPD = intval($sock->GET_INFO("EnableProxyInSNMPD"));
    $WizardSavedSettings = unserialize(base64_decode($sock->GET_INFO("WizardSavedSettings")));
    $organization = $WizardSavedSettings["organization"];
    $mail = $WizardSavedSettings["mail"];
    $f[] = "agentAddress 161";
    $f[] = "view   systemonly  included   .1.3.6.1.2.1.1";
    $f[] = "view   systemonly  included   .1.3.6.1.2.1.25.1";
    $f[] = "rwcommunity {$SNMPDCommunity}  {$SNMPDNetwork}";
    $f[] = "rouser   authOnlyUser";
    $f[] = "#rwuser   authPrivUser   priv";
    $f[] = "sysLocation    {$organization}";
    $f[] = "sysContact     Manager <{$mail}>";
    $f[] = "sysServices    72";
    $f[] = "proc  mountd";
    $f[] = "proc  ntalkd";
    $apache = $unix->LOCATE_APACHE_BIN_PATH();
    if ($apache != null) {
        $f[] = "proc  {$apache}";
    }
    $ufdbguardd = $unix->find_program("ufdbguardd");
    if ($ufdbguardd != null) {
        $f[] = "proc  {$ufdbguardd}";
    }
    $f[] = "proc  " . $unix->LOCATE_PHP5_BIN();
    $mysqld = $unix->find_program("mysqld");
    if ($mysqld != null) {
        $f[] = "proc  {$mysqld}";
    }
    $lighttpd = $unix->find_program("lighttpd");
    if ($lighttpd != null) {
        $f[] = "proc  {$lighttpd}";
    }
    $clamd = $unix->find_program("clamd");
    if ($clamd != null) {
        $f[] = "proc  {$clamd}";
    }
    $f[] = "disk       /     10000";
    $f[] = "disk       /var  5%";
    $f[] = "includeAllDisks  10%";
    $f[] = "load   12 10 5";
    $f[] = "iquerySecName   internalUser       ";
    $f[] = "rouser          internalUser";
    $f[] = "defaultMonitors          yes";
    $unix = new unix();
    if ($EnableProxyInSNMPD == 1) {
        $squid = $unix->LOCATE_SQUID_BIN();
        if ($squid != null) {
            $f[] = "proc  {$squid}";
            $SquidSNMPPort = intval($sock->GET_INFO("SquidSNMPPort"));
            $SquidSNMPComunity = $sock->GET_INFO("SquidSNMPComunity");
            if ($SquidSNMPPort == 0) {
                $SquidSNMPPort = intval($squid->snmp_port);
            }
            if ($SquidSNMPPort == 0) {
                $SquidSNMPPort = 3401;
            }
            if ($SquidSNMPComunity == null) {
                $SquidSNMPComunity = $squid->snmp_community;
            }
            if ($SquidSNMPComunity == null) {
                $SquidSNMPComunity = "public";
            }
            if (is_file("/usr/share/squid3/mib.txt")) {
                $moib = " -m /usr/share/squid3/mib.txt";
            }
            $f[] = "proxy{$moib} -v 1 -c {$SquidSNMPComunity} 127.0.0.1:{$SquidSNMPPort} .1.3.6.1.4.1.3495.1";
        }
    }
    $f[] = "master          agentx";
    $f[] = "#agentXSocket    tcp:localhost:705";
    @mkdir("/etc/snmp", 0755, true);
    @file_put_contents("/etc/snmp/snmpd.conf", @implode("\n", $f));
    if ($GLOBALS["OUTPUT"]) {
        echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} /etc/snmp/snmpd.conf done\n";
    }
}
Esempio n. 3
0
function PID_NUM()
{
    $unix = new unix();
    $pid = $unix->get_pid_from_file($GLOBALS["APACHE_PID_PATH"]);
    if ($unix->process_exists($pid)) {
        return $pid;
    }
    $apache2ctl = $unix->LOCATE_APACHE_BIN_PATH();
    return $unix->PIDOF_PATTERN($apache2ctl . " -f {$GLOBALS["APACHE_CONFIG_PATH"]}");
}
Esempio n. 4
0
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";
        }
    }
}
Esempio n. 5
0
function reconfigure()
{
    if ($GLOBALS["VERBOSE"]) {
        writelogs("starting reconfigure()", __FUNCTION__, __FILE__, __LINE__);
    }
    $unix = new unix();
    $sock = new sockets();
    if ($GLOBALS["VERBOSE"]) {
        writelogs("->clladp()", __FUNCTION__, __FILE__, __LINE__);
    }
    $ldap = new clladp();
    $smbpasswd = $unix->find_program("smbpasswd");
    if ($GLOBALS["VERBOSE"]) {
        writelogs("smbpasswd={$smbpasswd} -->samba()", __FUNCTION__, __FILE__, __LINE__);
    }
    $samba = new samba();
    $net = $unix->LOCATE_NET_BIN_PATH();
    $ldap_passwd = $ldap->ldap_password;
    $EnableSambaActiveDirectory = $sock->GET_INFO("EnableSambaActiveDirectory");
    $EnableSambaRemoteLDAP = $sock->GET_INFO("EnableSambaRemoteLDAP");
    if ($EnableSambaRemoteLDAP == 1) {
        $SambaRemoteLDAPInfos = unserialize(base64_decode($sock->GET_INFO("SambaRemoteLDAPInfos")));
        $ldap_passwd = $SambaRemoteLDAPInfos["user_dn_password"];
    }
    if ($EnableSambaActiveDirectory == 1) {
        activedirectory();
    }
    CheckFilesAndDirectories();
    FixsambaDomainName();
    echo "Starting......: Samba building main configuration...\n";
    @file_put_contents("/etc/samba/smb.conf", $samba->BuildConfig());
    echo "Starting......: Samba {$smbpasswd} -w ****\n";
    shell_exec("{$smbpasswd} -w \"{$ldap_passwd}\"");
    SambaAudit();
    fixEtcHosts();
    $master_password = $samba->GetAdminPassword("administrator");
    $SambaEnableEditPosixExtension = $sock->GET_INFO("SambaEnableEditPosixExtension");
    if ($SambaEnableEditPosixExtension == 1) {
        $cmd = "{$net} idmap secret {$samba->main_array["global"]["workgroup"]} \"{$ldap_passwd}\" >/dev/null 2>&1 &";
        shell_exec($cmd);
        $cmd = "{$net} idmap secret alloc \"{$ldap_passwd}\" >/dev/null 2>&1 &";
        shell_exec($cmd);
    }
    if ($EnableSambaActiveDirectory == 1) {
        kinit();
    }
    shell_exec($unix->LOCATE_APACHE_BIN_PATH() . " /usr/share/artica-postfix/exec.pam.php --build");
    $unix->THREAD_COMMAND_SET(LOCATE_PHP5_BIN2() . " " . __FILE__ . " --check-dirs");
    $unix->THREAD_COMMAND_SET("/usr/share/artica-postfix/bin/artica-install --samba-reconfigure");
    reload();
}
Esempio n. 6
0
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/*");
}
Esempio n. 7
0
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";
        }
    }
}