Пример #1
0
function checkParams()
{
    progress_logs(5, "{apply_settings}", "Checks settings..");
    $sock = new sockets();
    $array = unserialize(base64_decode($sock->GET_INFO("KerbAuthInfos")));
    if ($array["WINDOWS_DNS_SUFFIX"] == null) {
        progress_logs(20, "{apply_settings}", "Auth Winbindd, misconfiguration failed WINDOWS_DNS_SUFFIX = NULL");
        return false;
    }
    if ($array["WINDOWS_SERVER_NETBIOSNAME"] == null) {
        progress_logs(20, "{apply_settings}", "Auth Winbindd, misconfiguration failed WINDOWS_SERVER_NETBIOSNAME = NULL");
        return false;
    }
    if ($array["WINDOWS_SERVER_TYPE"] == null) {
        progress_logs(20, "{apply_settings}", "Auth Winbindd, misconfiguration failed WINDOWS_SERVER_TYPE = NULL");
        return false;
    }
    if ($array["WINDOWS_SERVER_ADMIN"] == null) {
        progress_logs(20, "{apply_settings}", "Auth Winbindd, misconfiguration failed WINDOWS_SERVER_ADMIN = NULL");
        return false;
    }
    if ($array["WINDOWS_SERVER_PASS"] == null) {
        progress_logs(20, "{apply_settings}", "Auth Winbindd, misconfiguration failed WINDOWS_SERVER_PASS = NULL");
        return false;
    }
    $ADNETIPADDR = $array["ADNETIPADDR"];
    $UseADAsNameServer = $sock->GET_INFO("UseADAsNameServer");
    if (!$UseADAsNameServer) {
        $UseADAsNameServer = 0;
    }
    if ($UseADAsNameServer == 1) {
        $resolve = new resolv_conf();
        progress_logs(20, "{apply_settings}", "Auth Winbindd, SET {$ADNETIPADDR} as 1st DNS in line " . __LINE__);
        $resolve->MainArray["DNS1"] = $ADNETIPADDR;
        progress_logs(20, "{apply_settings}", "Auth Winbindd, Building configuration " . __LINE__);
        $REX = $resolve->build();
        progress_logs(20, "{apply_settings}", "Auth Winbindd, saving /etc/resolv.conf " . __LINE__);
        @file_put_contents("/etc/resolv.conf", $resolve->build());
        progress_logs(20, "{apply_settings}", "Auth Winbindd, saving new configuration " . __LINE__);
        $resolve->save();
    }
    $hostname = strtolower(trim($array["WINDOWS_SERVER_NETBIOSNAME"])) . "." . strtolower(trim($array["WINDOWS_DNS_SUFFIX"]));
    progress_logs(20, "{apply_settings}", "Trying to resolve host {$hostname} ...." . __LINE__);
    $ip = gethostbyname($hostname);
    progress_logs(20, "{apply_settings}", "host {$hostname} = {$ip}...." . __LINE__);
    if ($ip == $hostname) {
        progress_logs(7, "{apply_settings}", "!!!!! {$ip} gethostbyname({$hostname}) failed !!!!!");
        return false;
    }
    progress_logs(7, "{apply_settings}", "Checks settings success..");
    return true;
}
Пример #2
0
function savedns()
{
    $DNS1 = @file_get_contents("/etc/artica-postfix/WIZARDMASK_DNS1");
    $DNS2 = @file_get_contents("/etc/artica-postfix/WIZARDMASK_DNS2");
    $resolv = new resolv_conf();
    echo "92%] Set DNS to {$DNS1} - {$DNS2}\n";
    $resolv->MainArray["DNS1"] = $DNS1;
    $resolv->MainArray["DNS2"] = $DNS1;
    $resolv->output = true;
    echo "93%] Saving config\n";
    $resolvDatas = $resolv->build();
    echo "94%] Saving /etc/resolv.conf\n";
    @file_put_contents("/etc/resolv.conf", $resolvDatas);
    echo "###################################################\n";
    echo "############                          #############\n";
    echo "############         SUCCESS          #############\n";
    echo "############                          #############\n";
    echo "###################################################\n\n\n\n";
}
function ACTION_NETWORK()
{
    $unix = new unix();
    $clear = $unix->find_program("clear");
    if (is_file($clear)) {
        system("{$clear}");
    }
    $users = new usersMenus();
    $q = new mysql();
    if (!$q->BD_CONNECT(true)) {
        echo "There is an issue while connecting to MySQL\n{$q->mysql_error}\nPress Key to exit.\n";
        $line = fgets(STDIN);
        return;
    }
    $DEFAULT = null;
    $net = new networking();
    $interfaces = $net->Local_interfaces();
    unset($interfaces["lo"]);
    if (isset($interfaces["eth0"])) {
        $DEFAULT = "eth0";
    }
    while (list($num, $letter) = each($interfaces)) {
        $int[] = "\"{$num}\"";
    }
    if ($DEFAULT == null) {
        $DEFAULT = $int[0];
    }
    $q->BuildTables();
    echo "This wizard will help to configure network.\n";
    echo "Press q letter to exit or any key to continue:";
    $answer = trim(strtolower(fgets(STDIN)));
    if ($answer == "q") {
        return;
    }
    if (is_file($clear)) {
        system("{$clear}");
    }
    echo "Give here the interface name of the network interface\n";
    echo "you need to setup.\n\n";
    echo "Should be one of :" . @implode(", ", $int) . "\n";
    echo "Default: [{$DEFAULT}]\n";
    $NIC = trim(strtolower(fgets(STDIN)));
    if ($NIC == null) {
        $NIC = $DEFAULT;
    }
    if (!preg_match("#([a-z])([0-9+)\$#", $NIC)) {
        $NIC = $DEFAULT;
    }
    $ETH_IP = trim(ASK_ETH_IP($NIC));
    $GATEWAY = trim(ASK_GATEWAY($NIC));
    $NETMASK = trim(ASK_NETMASK($NIC));
    $DNS = trim(ASK_DNS1($NIC));
    if (is_file($clear)) {
        system("{$clear}");
    }
    echo "Your Settings:\n";
    echo "Interface.........: \"{$NIC}\"\n";
    echo "IP address........: \"{$ETH_IP}\"\n";
    echo "Gateway...........: \"{$GATEWAY}\"\n";
    echo "Netmask...........: \"{$NETMASK}\"\n";
    echo "DNS server 1......: \"{$DNS}\"\n";
    echo "\n";
    //ini_set('display_errors', 1);ini_set('error_reporting', E_ALL);ini_set('error_prepend_string',null);ini_set('error_append_string',null);
    echo "If your are agree with these settings\n";
    echo "Press any key to apply settings or press \"q\" to return to menu.\n";
    $answer = trim(strtolower(fgets(STDIN)));
    if ($answer == "q") {
        return;
    }
    echo "5%] Please Wait, saving configuration...\n";
    $nics = new system_nic($NIC);
    $nics->eth = $NIC;
    $nics->IPADDR = $ETH_IP;
    $nics->NETMASK = $NETMASK;
    $nics->GATEWAY = $GATEWAY;
    $nics->DNS1 = $DNS;
    $nics->dhcp = 0;
    $nics->metric = 1;
    $nics->defaultroute = 1;
    $nics->enabled = 1;
    echo "7%] Please Wait, saving Networks parameters to MySQL DB...\n";
    if (!$nics->SaveNic()) {
        echo "There is an issue while saving your settings\n";
        echo "Press any key to exit.\n";
        $answer = trim(strtolower(fgets(STDIN)));
        return;
    }
    echo "10%] Please Wait, building configuration....\n";
    $php = $unix->LOCATE_PHP5_BIN();
    $nohup = $unix->find_program("nohup");
    $php5 = $php;
    shell_exec2("{$php5} " . dirname(__FILE__) . " /exec.virtuals-ip.php --build --force >/dev/null 2>&1");
    echo "20%] Please Wait, apply network configuration....\n";
    shell_exec2("{$php5} /usr/share/artica-postfix/exec.initslapd.php");
    shell_exec2("/etc/init.d/artica-ifup start");
    echo "30%] Please Wait, restarting services....\n";
    $unix->THREAD_COMMAND_SET("{$php5} /usr/share/artica-postfix/exec.postfix.maincf.php --reconfigure");
    $unix->THREAD_COMMAND_SET("/usr/share/artica-postfix/bin/artica-install --reconfigure-cyrus");
    shell_exec2("{$nohup} /etc/init.d/artica-status reload >/dev/null 2>&1 &");
    shell_exec2("{$nohup} /etc/init.d/nginx restart >/dev/null 2>&1 &");
    shell_exec2("{$nohup} /etc/init.d/monit restart >/dev/null 2>&1 &");
    echo "30%] Please Wait, Changing IP address to {$NIC}....\n";
    $ifconfig = $unix->find_program("ifconfig");
    shell_exec2("{$ifconfig} {$NIC} down");
    shell_exec2("{$ifconfig} {$NIC} {$ETH_IP} netmask {$NETMASK} up");
    shell_exec2("/bin/ip route add 127.0.0.1 dev lo");
    if ($GATEWAY != "0.0.0.0") {
        echo "31%] Please Wait, Define default gateway to {$GATEWAY}....\n";
        shell_exec2("/sbin/route add {$GATEWAY} dev {$NIC}");
        $route = $unix->find_program("route");
        shell_exec("{$route} add -net 0.0.0.0 gw {$GATEWAY} dev {$NIC} metric 1");
    }
    echo "80%] Please Wait, Changing DNS to {$DNS}....\n";
    echo "81%] Please Wait, Loading DNS library\n";
    $GLOBALS["PROGRESS"] = true;
    $resolv = new resolv_conf();
    echo "92%] Set DNS1 to {$DNS}\n";
    $resolv->MainArray["DNS1"] = $DNS;
    $resolv->output = true;
    echo "93%] Saving config\n";
    $resolvDatas = $resolv->build();
    echo "94%] Saving /etc/resolv.conf\n";
    @file_put_contents("/etc/resolv.conf", $resolvDatas);
    echo "95%] Restarting Web Console\n";
    shell_exec2("{$nohup} /etc/init.d/artica-webconsole restart");
    echo "100%] Configuration done.\n";
    echo "Press any key to return to menu.";
    $answer = trim(strtolower(fgets(STDIN)));
    MAIN_MENU();
}
Пример #4
0
function resolvconf()
{
    $resolv = new resolv_conf();
    $resolvDatas = $resolv->build();
    @file_put_contents("/etc/resolv.conf", $resolvDatas);
    if (is_dir("/var/spool/postfix/etc")) {
        @file_put_contents("/var/spool/postfix/etc/resolv.conf", $resolvDatas);
    }
    if (is_dir("/etc/resolvconf")) {
        @mkdir("/etc/resolvconf/resolv.conf.d", 0755, true);
        $f = array();
        if ($resolv->MainArray["DNS1"] != null) {
            $f[] = "nameserver {$resolv->MainArray["DNS1"]}";
        }
        if ($resolv->MainArray["DNS2"] != null) {
            $f[] = "nameserver {$resolv->MainArray["DNS2"]}";
        }
        if ($resolv->MainArray["DNS3"] != null) {
            $f[] = "nameserver {$resolv->MainArray["DNS3"]}";
        }
        if (count($f) > 0) {
            @file_put_contents("/etc/resolvconf/resolv.conf.d/base", @implode("\n", $f));
        }
    }
    $unix = new unix();
    $php5 = $unix->LOCATE_PHP5_BIN();
    $nohup = $unix->find_program("nohup");
    shell_exec("{$nohup} {$php5} " . dirname(__FILE__) . "/exec.dnsmasq.php --build >/dev/null 2>&1 &");
}
Пример #5
0
function ResolvConfChecks()
{
    $unix = new unix();
    $sock = new sockets();
    $EnableDNSMASQ = $sock->GET_INFO("EnableDNSMASQ");
    if (!is_numeric($EnableDNSMASQ)) {
        $EnableDNSMASQ = 0;
    }
    $f = file("/etc/resolv.conf");
    $dnsmasqbin = $unix->find_program("dnsmasq");
    $configured = false;
    while (list($dir, $line) = each($f)) {
        if (preg_match("#^nameserver.+#", $line, $re)) {
            $configured = true;
        }
    }
    if ($configured) {
        return;
    }
    if (file_exists($dnsmasqbin)) {
        if ($EnableDNSMASQ == 0) {
            $resolv = new resolv_conf();
            $resolvConfBuild = $resolv->build();
            echo "Starting......: " . date("H:i:s") . " /etc/resolv.conf not configured, write it...\n";
            @file_put_contents("/etc/resolv.conf", $resolvConfBuild);
        }
        if ($EnableDNSMASQ == 1) {
            reset($f);
            $f[] = "nameserver 127.0.0.1";
            echo "Starting......: " . date("H:i:s") . " /etc/resolv.conf not configured, write it...\n";
            @file_put_contents("/etc/resolv.conf", $resolvConfBuild);
            reload_dnsmasq();
        }
    } else {
        $resolv = new resolv_conf();
        $resolvConfBuild = $resolv->build();
        echo "Starting......: " . date("H:i:s") . " /etc/resolv.conf not configured, write it...\n";
        @file_put_contents("/etc/resolv.conf", $resolvConfBuild);
    }
}