Пример #1
0
function uncompress()
{
    $unix = new unix();
    $php5 = $unix->LOCATE_PHP5_BIN();
    $tar = $unix->find_program("tar");
    $filename = $_GET["uncompress"];
    $nohup = $unix->find_program("nohup");
    $FilePath = "/usr/share/artica-postfix/ressources/conf/upload/{$filename}";
    if (!is_file($FilePath)) {
        echo "<articadatascgi>" . base64_encode(serialize(array("R" => false, "T" => "{failed}: {$FilePath} no such file"))) . "</articadatascgi>";
        return;
    }
    $cmd = "{$tar} -xf {$FilePath} -C /";
    writelogs_framework($cmd, __FUNCTION__, __FILE__, __LINE__);
    shell_exec($cmd);
    $VERSION = snmpd_version();
    shell_exec("{$nohup} {$php5} /usr/share/artica-postfix/exec.initslapd.php --snmpd >/dev/null 2>&1 &");
    echo "<articadatascgi>" . base64_encode(serialize(array("R" => true, "T" => "{success}: v.{$VERSION}"))) . "</articadatascgi>";
}
Пример #2
0
function snmpd()
{
    if (!extension_loaded('snmp')) {
        shell_exec2("{$GLOBALS["nohup"]} {$GLOBALS["NICE"]} {$GLOBALS["PHP5"]} /usr/share/artica-postfix/exec.snmp.install.php >/dev/null 2>&1 &");
    }
    $snmpd = $GLOBALS["CLASS_UNIX"]->find_program("snmpd");
    if (!is_file($snmpd)) {
        return;
    }
    $enabled = $GLOBALS["CLASS_SOCKETS"]->GET_INFO("EnableSNMPD");
    if (!is_numeric($enabled)) {
        $enabled = 0;
    }
    $pid_path = "/var/run/snmpd.pid";
    $master_pid = snmpd_pid();
    $l[] = "[APP_SNMPD]";
    $l[] = "service_name=APP_SNMPD";
    $l[] = "master_version=" . snmpd_version();
    $l[] = "service_cmd=/etc/init.d/snmpd";
    $l[] = "service_disabled={$enabled}";
    $l[] = "family=system";
    $l[] = "pid_path={$pid_path}";
    $l[] = "watchdog_features=1";
    if ($enabled == 0) {
        return implode("\n", $l);
        return;
    }
    if (!$GLOBALS["CLASS_UNIX"]->process_exists($master_pid)) {
        if (!$GLOBALS["DISABLE_WATCHDOG"]) {
            $cmd = trim("{$GLOBALS["NICE"]}{$GLOBALS["PHP5"]} " . dirname(__FILE__) . "/exec.snmpd.php --start");
            shell_exec2($cmd);
        }
        $l[] = "running=0\ninstalled=1";
        $l[] = "";
        return implode("\n", $l);
        return;
    } else {
        if ($enabled == 0) {
            shell_exec2("{$GLOBALS["nohup"]} /etc/init.d/snmpd stop >/dev/null 2>&1 &");
        }
    }
    $l[] = "running=1";
    $l[] = GetMemoriesOf($master_pid);
    $l[] = "";
    return implode("\n", $l);
    return;
}
Пример #3
0
function buildpackage()
{
    $version = snmpd_version();
    if ($version == null) {
        echo "version is null\n";
        return;
    }
    $Architecture = Architecture();
    $f["/usr/include/net-snmp"] = true;
    $f["/usr/share/snmp"] = true;
    $f["/etc/snmp"] = true;
    $f["/usr/lib/libnetsnmp.so.30.0.2"] = true;
    $f["/usr/lib/libnetsnmp.so.30"] = true;
    $f["/usr/lib/libnetsnmp.la"] = true;
    $f["/usr/lib/libnetsnmp.so"] = true;
    $f["/usr/lib/libnetsnmp.a"] = true;
    $f["/usr/lib/libnetsnmpagent.so.30.0.2"] = true;
    $f["/usr/lib/libnetsnmpagent.so.30"] = true;
    $f["/usr/lib/libnetsnmpagent.so"] = true;
    $f["/usr/lib/libnetsnmpagent.la"] = true;
    $f["/usr/lib/libnetsnmpagent.a"] = true;
    $f["/usr/lib/libnetsnmphelpers.so.30.0.2"] = true;
    $f["/usr/lib/libnetsnmphelpers.so.30"] = true;
    $f["/usr/lib/libnetsnmphelpers.so"] = true;
    $f["/usr/lib/libnetsnmphelpers.la"] = true;
    $f["/usr/lib/libnetsnmphelpers.a"] = true;
    $f["/usr/lib/libnetsnmpmibs.so.30.0.2"] = true;
    $f["/usr/lib/libnetsnmpmibs.so.30"] = true;
    $f["/usr/lib/libnetsnmpmibs.so"] = true;
    $f["/usr/lib/libnetsnmpmibs.la"] = true;
    $f["/usr/lib/libnetsnmpmibs.a"] = true;
    $f["/usr/lib/libnetsnmptrapd.so.30.0.2"] = true;
    $f["/usr/lib/libnetsnmptrapd.so.30"] = true;
    $f["/usr/lib/libnetsnmptrapd.so"] = true;
    $f["/usr/lib/libnetsnmptrapd.la"] = true;
    $f["/usr/lib/libnetsnmptrapd.a"] = true;
    $f["/usr/lib/libnetsnmp.so.30.0.2"] = true;
    $f["/usr/lib/libnetsnmp.so.30"] = true;
    $f["/usr/lib/libnetsnmp.so"] = true;
    $f["/usr/lib/libnetsnmp.la"] = true;
    $f["/usr/lib/libnetsnmp.a"] = true;
    $f["/usr/lib/libnetsnmpagent.so.30.0.2"] = true;
    $f["/usr/lib/libnetsnmpagent.so.30"] = true;
    $f["/usr/lib/libnetsnmpagent.so"] = true;
    $f["/usr/lib/libnetsnmpagent.la"] = true;
    $f["/usr/lib/libnetsnmpagent.a"] = true;
    $f["/usr/lib/libnetsnmphelpers.so.30.0.2"] = true;
    $f["/usr/lib/libnetsnmphelpers.so.30"] = true;
    $f["/usr/lib/libnetsnmphelpers.so"] = true;
    $f["/usr/lib/libnetsnmphelpers.la"] = true;
    $f["/usr/lib/libnetsnmphelpers.a"] = true;
    $f["/usr/lib/libnetsnmpmibs.so.30.0.2"] = true;
    $f["/usr/lib/libnetsnmpmibs.so.30"] = true;
    $f["/usr/lib/libnetsnmpmibs.so"] = true;
    $f["/usr/lib/libnetsnmpmibs.la"] = true;
    $f["/usr/lib/libnetsnmpmibs.a"] = true;
    $f["/usr/lib/libnetsnmptrapd.so.30.0.2"] = true;
    $f["/usr/lib/libnetsnmptrapd.so.30"] = true;
    $f["/usr/lib/libnetsnmptrapd.so"] = true;
    $f["/usr/lib/libnetsnmptrapd.la"] = true;
    $f["/usr/lib/libnetsnmptrapd.a"] = true;
    $f["/usr/bin/snmpdelta"] = true;
    $f["/usr/bin/snmpdf"] = true;
    $f["/usr/sbin/snmpd"] = true;
    $f["/usr/sbin/snmptrapd"] = true;
    $f["/usr/bin/snmpget"] = true;
    $f["/usr/bin/snmpgetnext"] = true;
    $f["/usr/bin/snmpset"] = true;
    $f["/usr/bin/snmpwalk"] = true;
    $f["/usr/bin/snmpbulkwalk"] = true;
    $f["/usr/bin/snmptable"] = true;
    $f["/usr/bin/snmptrap"] = true;
    $f["/usr/bin/snmpbulkget"] = true;
    $f["/usr/bin/snmptranslate"] = true;
    $f["/usr/bin/snmpstatus"] = true;
    $f["/usr/bin/snmpdelta"] = true;
    $f["/usr/bin/snmptest"] = true;
    $f["/usr/bin/snmpdf"] = true;
    $f["/usr/bin/agentxtrap"] = true;
    $f["/usr/bin/snmpvacm"] = true;
    $f["/usr/bin/snmpusm"] = true;
    $f["/usr/bin/encode_keychange"] = true;
    $f["/usr/bin/snmpnetstat"] = true;
    $f["/usr/bin/snmpinform"] = true;
    $f["/usr/bin/snmpcheck"] = true;
    $f["/usr/bin/tkmib"] = true;
    $f["/usr/bin/mib2c"] = true;
    $f["/usr/bin/fixproc"] = true;
    $f["/usr/bin/ipf-mod.pl"] = true;
    $f["/usr/bin/snmpconf"] = true;
    $f["/usr/bin/traptoemail"] = true;
    $f["/usr/bin/snmp-bridge-mib"] = true;
    $f["/usr/bin/net-snmp-cert"] = true;
    $f["/usr/bin/mib2c-update"] = true;
    $f["/usr/local/lib/perl/5.10.1/auto/SNMP/SNMP.bs"] = true;
    $f["/usr/local/lib/perl/5.10.1/auto/SNMP/SNMP.so"] = true;
    $f["/usr/local/lib/perl/5.10.1/auto/NetSNMP/OID/OID.bs"] = true;
    $f["/usr/local/lib/perl/5.10.1/auto/NetSNMP/OID/OID.so"] = true;
    $f["/usr/local/lib/perl/5.10.1/auto/NetSNMP/agent/agent.so"] = true;
    $f["/usr/local/lib/perl/5.10.1/auto/NetSNMP/agent/agent.bs"] = true;
    $f["/usr/local/lib/perl/5.10.1/auto/NetSNMP/agent/default_store/default_store.so"] = true;
    $f["/usr/local/lib/perl/5.10.1/auto/NetSNMP/agent/default_store/default_store.bs"] = true;
    $f["/usr/local/lib/perl/5.10.1/auto/NetSNMP/default_store/default_store.so"] = true;
    $f["/usr/local/lib/perl/5.10.1/auto/NetSNMP/default_store/default_store.bs"] = true;
    $f["/usr/local/lib/perl/5.10.1/auto/NetSNMP/ASN/ASN.so"] = true;
    $f["/usr/local/lib/perl/5.10.1/auto/NetSNMP/ASN/ASN.bs"] = true;
    $f["/usr/local/lib/perl/5.10.1/auto/NetSNMP/TrapReceiver/TrapReceiver.bs"] = true;
    $f["/usr/local/lib/perl/5.10.1/auto/NetSNMP/TrapReceiver/TrapReceiver.so"] = true;
    $f["/usr/local/lib/perl/5.10.1/SNMP.pm"] = true;
    $f["/usr/local/lib/perl/5.10.1/NetSNMP/OID.pm"] = true;
    $f["/usr/local/lib/perl/5.10.1/NetSNMP/TrapReceiver.pm"] = true;
    $f["/usr/local/lib/perl/5.10.1/NetSNMP/ASN.pm"] = true;
    $f["/usr/local/lib/perl/5.10.1/NetSNMP/default_store.pm"] = true;
    $f["/usr/local/lib/perl/5.10.1/NetSNMP/agent.pm"] = true;
    $f["/usr/local/lib/perl/5.10.1/NetSNMP/agent/netsnmp_request_infoPtr.pm"] = true;
    $f["/usr/local/lib/perl/5.10.1/NetSNMP/agent/Support.pm"] = true;
    $f["/usr/local/lib/perl/5.10.1/NetSNMP/agent/default_store.pm"] = true;
    $f["/usr/local/lib/perl/5.10.1/auto/SNMP/autosplit.ix"] = true;
    $f["/usr/local/lib/perl/5.10.1/auto/NetSNMP/OID/autosplit.ix"] = true;
    $f["/usr/local/lib/perl/5.10.1/auto/NetSNMP/agent/autosplit.ix"] = true;
    $f["/usr/local/lib/perl/5.10.1/auto/NetSNMP/agent/default_store/autosplit.ix"] = true;
    $f["/usr/local/lib/perl/5.10.1/auto/NetSNMP/default_store/autosplit.ix"] = true;
    $f["/usr/local/lib/perl/5.10.1/auto/NetSNMP/ASN/autosplit.ix"] = true;
    $f["/usr/local/lib/perl/5.10.1/auto/NetSNMP/TrapReceiver/autosplit.ix"] = true;
    $f["/usr/local/lib/perl/5.10.1/Bundle/Makefile.subs.pl"] = true;
    $f["/usr/local/man/man3/NetSNMP::agent.3pm"] = true;
    $f["/usr/local/man/man3/NetSNMP::OID.3pm"] = true;
    $f["/usr/local/man/man3/NetSNMP::ASN.3pm"] = true;
    $f["/usr/local/man/man3/NetSNMP::agent::default_store.3pm"] = true;
    $f["/usr/local/man/man3/NetSNMP::default_store.3pm"] = true;
    $f["/usr/local/man/man3/NetSNMP::TrapReceiver.3pm"] = true;
    $f["/usr/local/man/man3/SNMP.3"] = true;
    $f["/usr/local/man/man3/NetSNMP::netsnmp_request_infoPtr.3pm"] = true;
    $root = "/root/SNMPD-{$version}";
    while (list($filename, $none) = each($f)) {
        if (is_dir($filename)) {
            @mkdir("{$root}/{$filename}", 0755, true);
            echo "Installing {$filename}/* in {$root}/{$filename}/\n";
            shell_exec("/bin/cp -rfd {$filename}/* {$root}/{$filename}/");
            continue;
        }
        if (!is_file($filename)) {
            echo "{$filename} no such file\n";
            continue;
        }
        $dir = dirname($filename);
        @mkdir("{$root}/{$dir}", 0755, true);
        echo "Installing {$filename} in {$root}/{$dir}/\n";
        shell_exec("/bin/cp -fd {$filename} {$root}/{$dir}/");
    }
    $unix = new unix();
    $tar = $unix->find_program("tar");
    @chdir($root);
    echo "Compressing snmpd-{$Architecture}-{$version}.tar.gz\n";
    shell_exec("{$tar} -czf snmpd-{$Architecture}-{$version}.tar.gz *");
    echo "Compressing {$root}/snmpd-{$Architecture}-{$version}.tar.gz Done...\n";
}