Exemplo n.º 1
0
function BuildNetWorksRedhat()
{
    echo "Starting......: Building networks mode RedHat\n";
    $nic = new system_nic();
    $datas = $nic->root_build_redhat_config();
    bridges_build();
    $unix = new unix();
    $unix->THREAD_COMMAND_SET($unix->LOCATE_PHP5_BIN() . " /usr/share/artica-postfix/exec.ip-rotator.php --build");
    if (!$GLOBALS["NO_GLOBAL_RELOAD"]) {
        $unix->NETWORK_REDHAT_RESTART();
    }
}
Exemplo n.º 2
0
function install_bridge()
{
    @unlink("/usr/share/artica-postfix/ressources/logs/vserver.daemon.log");
    echo2("Starting......: VPS server: install bridge");
    shell_exec("/bin/chmod 777 /usr/share/artica-postfix/ressources/logs/vserver.daemon.log");
    $sock = new sockets();
    $users = new usersMenus();
    $unix = new unix();
    $breth = "br5";
    $LXCINterface = $sock->GET_INFO("LXCInterface");
    $routebin = $unix->find_program("route");
    $ifconfig = $unix->find_program("ifconfig");
    $brctl = $unix->find_program("brctl");
    if (!is_file($brctl)) {
        echo2("Starting......: VPS server:{$breth} brctl no such binary");
        return;
    }
    $ifdown = $unix->find_program("ifdown");
    $lxcstart = $unix->find_program("lxc-start");
    if (!is_file($lxcstart)) {
        echo2("Starting......: VPS server:{$breth} lx-start no such binary");
        return;
    }
    if ($LXCINterface == null) {
        echo2("Starting......: VPS server:{$breth} no interface set...");
        return;
    }
    $nics = new system_nic();
    echo2("Starting......: VPS server: {$breth} interface \"{$LXCINterface}\" set...");
    if (!$nics->CreateLXCBridge($LXCINterface, $breth)) {
        echo2("Starting......: VPS server: {$breth} CreateLXCBridge() failed");
        return;
    }
    echo2("Starting......: VPS server: lock Artica Interface");
    $sock->SET_INFO("LXCEthLocked", 1);
    $sock->SET_INFO("LXCEnabled", 1);
    $sock->SET_INFO("LXCBridged", 1);
    $q = new mysql();
    $sql = "UPDATE nics_virtuals SET nic='{$breth}' WHERE nic='{$LXCINterface}'";
    $q->QUERY_SQL($sql, "artica_backup");
    $sql = "UPDATE nics_vlan SET nic='{$breth}' WHERE nic='{$LXCINterface}'";
    $q->QUERY_SQL($sql, "artica_backup");
    if (!$q->ok) {
        echo2("Starting......: VPS server: mysql error {$q->mysql_error}");
    }
    echo2("Starting......: VPS server: {$breth} linking bridge");
    preup_checkbridgre($breth, $LXCINterface);
    echo2("Starting......: VPS server: {$breth} linking bridge done..");
    $nicsAll = ifconfiglisteth();
    echo2("Starting......: VPS server: {$breth} " . count($nicsAll) . " Listed interface(s)");
    while (list($ethL, $eth2) = each($nicsAll)) {
        if (preg_match("#{$LXCINterface}#", $ethL)) {
            echo2("Starting......: VPS server: shutdown {$ethL}");
            shell_exec("{$ifconfig} {$ethL} down >/dev/null 2>&1");
            continue;
        }
        if (preg_match("#vlan#", $ethL)) {
            echo2("Starting......: VPS server: shutdown {$ethL}");
            shell_exec("{$ifconfig} {$ethL} down >/dev/null 2>&1");
            continue;
        }
        echo2("Starting......: VPS server: keep {$ethL}");
    }
    $nets = new system_nic();
    if ($users->AS_DEBIAN_FAMILY) {
        echo2("Starting......: VPS server: Building network configuration (debian mode)");
        $datas = $nets->root_build_debian_config();
        @file_put_contents("/etc/network/interfaces", $datas);
    } else {
        echo2("Starting......: VPS server: Building network configuration (redhat mode)");
        $nets->root_build_redhat_config();
    }
    $ip = $unix->find_program("ip");
    exec("{$ip} route 2>&1", $results);
    while (list($index, $line) = each($results)) {
        if (preg_match("#dev {$LXCINterface}#", $line)) {
            echo2("Starting......: VPS server: remove route {$line}");
            shell_exec("{$ip} route del {$line}");
        }
    }
    shell_exec2("{$ifconfig} {$LXCINterface} down");
    shell_exec2("{$ifconfig} {$LXCINterface} 0.0.0.0 up");
    if ($users->AS_DEBIAN_FAMILY) {
        $unix->NETWORK_DEBIAN_RESTART();
    } else {
        $unix->NETWORK_REDHAT_RESTART();
    }
}