Ejemplo n.º 1
0
function uninstall_bridge()
{
    @unlink("/usr/share/artica-postfix/ressources/logs/vserver.daemon.log");
    echo2("Starting......: VPS server: Installing bridge...");
    shell_exec("/bin/chmod 777 /usr/share/artica-postfix/ressources/logs/vserver.daemon.log");
    $sock = new sockets();
    $unix = new unix();
    $users = new usersMenus();
    $dhcp = false;
    $ifconfig = $unix->find_program("ifconfig");
    $LXCEnabled = $sock->GET_INFO("LXCEnabled");
    $routebin = $unix->find_program("route");
    $brctl = $unix->find_program("brctl");
    $ifdown = $unix->find_program("ifdown");
    if (!is_numeric($LXCEnabled)) {
        $LXCEnabled = 0;
    }
    $LXCINterface = $sock->GET_INFO("LXCInterface");
    $breth = "br5";
    echo2("Starting......: VPS server: check interfaces {$breth}");
    echo2("Starting......: VPS server: upgrading virtual networks");
    while (list($ethIndex, $array) = each($interfaces)) {
        if (preg_match("#{$breth}:[0-9]+#", $ethIndex)) {
            $array_eth = array();
            $array_eth["UNSET"] = true;
            echo2("Starting......: VPS server: Deleting {$ethIndex}");
            shell_exec("{$ifconfig} {$ethIndex} down >/dev/null 2>&1");
            $unix->NETWORK_DEBIAN_SAVE($ethIndex, $array_eth, true);
        }
    }
    echo2("Starting......: VPS server: upgrading virtual networks (if set)");
    $sql = "UPDATE nics_virtuals SET nic='{$LXCINterface}' WHERE nic='{$breth}'";
    $q = new mysql();
    $q->QUERY_SQL($sql, "artica_backup");
    echo2("Starting......: VPS server: upgrading VLANs (if set)");
    $sql = "UPDATE nics_vlan SET nic='{$LXCINterface}' WHERE nic='{$breth}'";
    $q->QUERY_SQL($sql, "artica_backup");
    if (!$q->ok) {
        echo2("Starting......: VPS server: mysql error {$q->mysql_error}");
    }
    echo2("Starting......: VPS server: Removing {$breth} config in memory");
    shell_exec2("{$brctl} delif {$breth} {$LXCINterface}");
    shell_exec2("{$ifconfig} {$breth} 0.0.0.0");
    shell_exec2("{$ifconfig} {$breth} down");
    shell_exec2("{$brctl} delbr {$brctl}");
    $nics = new system_nic();
    $nics->RemoveLXCBridge($LXCINterface, $breth);
    echo2("Starting......: VPS server: Unlock Artica Interface");
    $sock->SET_INFO("LXCEthLocked", 0);
    $sock->SET_INFO("LXCBridged", 0);
    echo2("Starting......: VPS server: Scheduling to restart network");
    $nicsAll = ifconfiglisteth();
    echo2("Starting......: VPS server: " . count($nicsAll) . " Listed interface(s)");
    while (list($ethL, $eth2) = each($nicsAll)) {
        if (preg_match("#{$breth}#", $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}");
    }
    $ip = $unix->find_program("ip");
    exec("{$ip} route 2>&1", $results);
    while (list($index, $line) = each($results)) {
        if (preg_match("#dev {$breth}#", $line)) {
            echo2("Starting......: VPS server: remove route {$line}");
            shell_exec("{$ip} route del {$line}");
        }
    }
    $nets = new system_nic();
    if ($users->AS_DEBIAN_FAMILY) {
        echo2("Starting......: VPS server: reconfigure network (debian mode)");
        $datas = $nets->root_build_debian_config();
        @file_put_contents("/etc/network/interfaces", $datas);
        $unix->NETWORK_DEBIAN_RESTART();
        return;
    }
    echo2("Starting......: VPS server: reconfigure network (redhat mode)");
    $nets->root_build_redhat_config();
    $unix->NETWORK_REDHAT_RESTART();
}