Пример #1
0
 public function database_kvm_terminate($sUser, $sVPS, $sRequested)
 {
     global $database;
     $sUserPermissions = $sUser->sPermissions;
     if ($sUserPermissions == 7) {
         $sServer = new Server($sVPS->sServerId);
         $sSSH = Server::server_connect($sServer);
         $sCommandList .= "virsh autostart --disabled kvm{$sVPS->sContainerId}}";
         $sCommandList .= "virsh destroy kvm{$sVPS->sContainerId};";
         $sCommandList .= "rm -rf /var/feathur/configs/kvm{$sVPS->sContainerId}-vps.xml;rm -rf /var/feathur/configs/kvm{$sVPS->sContainerId}-dhcp.conf;";
         $sCommandList .= "cat /var/feathur/configs/dhcpd.head /var/feathur/configs/*-dhcp.conf > /etc/dhcp/dhcpd.conf;service isc-dhcp-server restart;";
         $sCommandList .= "dd if=/dev/zero of=/dev/{$sServer->sVolumeGroup}/kvm{$sVPS->sContainerId}_img;";
         $sCommandList .= "lvremove -f /dev/{$sServer->sVolumeGroup}/kvm{$sVPS->sContainerId}_img;exit;";
         $sCommandList = escapeshellarg($sCommandList);
         $sLog[] = array("command" => "VPS Termination via Screen", "result" => $sSSH->exec("screen -dm -S {$sVPS->sContainerId} bash -c {$sCommandList};"));
         $sSave = VPS::save_vps_logs($sLog, $sVPS);
         $sTerminate = $database->CachedQuery("DELETE FROM vps WHERE `id` = :VPSId", array('VPSId' => $sVPS->sId));
         $sCleanIPs = $database->CachedQuery("UPDATE ipaddresses SET `vps_id` = 0 WHERE `vps_id` = :VPSId", array('VPSId' => $sVPS->sId));
         return $sArray = array("json" => 1, "type" => "error", "result" => "This VPS has been terminated.", "reload" => 1);
     } else {
         return $sArray = array("json" => 1, "type" => "error", "result" => "Insufficient permissions for this action.", "reload" => 1);
     }
 }
Пример #2
0
 public function database_openvz_terminate($sUser, $sVPS, $sRequested)
 {
     global $database;
     $sUserPermissions = $sUser->sPermissions;
     if ($sUserPermissions == 7) {
         $sServer = new Server($sVPS->sServerId);
         $sSSH = Server::server_connect($sServer);
         $sLog[] = array("command" => "vzctl stop {$sVPS->sContainerId}", "result" => $sSSH->exec("vzctl stop {$sVPS->sContainerId}"));
         $sLog[] = array("command" => "vzctl destroy {$sVPS->sContainerId}", "result" => $sSSH->exec("vzctl destroy {$sVPS->sContainerId}"));
         $sSave = VPS::save_vps_logs($sLog, $sVPS);
         $sTerminate = $database->CachedQuery("DELETE FROM vps WHERE `id` = :VPSId", array('VPSId' => $sVPS->sId));
         $sCleanIPs = $database->CachedQuery("UPDATE ipaddresses SET `vps_id` = 0 WHERE `vps_id` = :VPSId", array('VPSId' => $sVPS->sId));
         return $sArray = array("json" => 1, "type" => "error", "result" => "This VPS has been terminated.", "reload" => 1);
     } else {
         return $sArray = array("json" => 1, "type" => "error", "result" => "Insufficient permissions for this action.", "reload" => 1);
     }
 }