root-wrap, checkvm, stop, stopall and several fixes
This commit is contained in:
@@ -16,11 +16,12 @@ if(isset($_REQUEST['logout'])){
|
||||
$mode="";
|
||||
|
||||
function checkvm($vmname) {
|
||||
$shellout = shell_exec("/usr/bin/wrap-nlvmi checkvm $vmname bla");//){
|
||||
if (preg_match_all('/running/', $shellout)){
|
||||
return 0;
|
||||
$shellout = shell_exec("/usr/bin/nlvmi checkvm $vmname bla");//){
|
||||
// echo $shellout;
|
||||
if (preg_match_all('/not running/', $shellout)){
|
||||
return 1;
|
||||
}
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
//read config file
|
||||
@@ -165,7 +166,7 @@ if (isset($_SESSION['username'])){
|
||||
}
|
||||
}
|
||||
|
||||
//ajax queries are all don, time for the header
|
||||
//ajax queries are all done, time for the header
|
||||
include('header.php');
|
||||
|
||||
|
||||
@@ -216,7 +217,7 @@ if (isset($_SESSION['username'])){
|
||||
$sql="SELECT * FROM vms WHERE vmname='$vmname' $sqllimit";
|
||||
$res = $db_handle->query($sql);
|
||||
while ($row = $res->fetchArray(SQLITE3_ASSOC)){
|
||||
$shellout = shell_exec("/usr/bin/wrap-nlvmi start $vmname bla");
|
||||
$shellout = shell_exec("/usr/bin/nlvmi start $vmname bla");
|
||||
echo $shellout;
|
||||
}
|
||||
}
|
||||
@@ -229,8 +230,8 @@ if (isset($_SESSION['username'])){
|
||||
$sql="SELECT * FROM vms WHERE vmname='$vmname' $sqllimit";
|
||||
$res = $db_handle->query($sql);
|
||||
while ($row = $res->fetchArray(SQLITE3_ASSOC)){
|
||||
if(checkvm($vmname)){
|
||||
$shellout = shell_exec("/usr/bin/wrap-nlvmi stop $vmname bla");
|
||||
if(!checkvm($vmname)){
|
||||
$shellout = shell_exec("/usr/bin/nlvmi stop $vmname bla");
|
||||
echo $shellout;
|
||||
}
|
||||
}
|
||||
@@ -451,7 +452,7 @@ if (isset($_SESSION['username'])){
|
||||
echo "<button class=\"btn btn-danger\" data-delete-text=\"Delete VM $row[vmname]!\" data-delete-vm=\"$row[id]\" data-delete-name=\"$row[vmname]\" data-toggle=\"modal\" data-target=\"#confirm-delete\">Delete VM</button> ";
|
||||
$server = gethostname();
|
||||
if (preg_match('/stop/', $button)) {
|
||||
echo "<a target=_blank href=novnc/vnc.html?port=$row[websocket]&path=&host=$server class=\"btn btn-success\">VNC</a></div>";
|
||||
echo "<a target=_blank href=novnc/vnc.html?port=$row[websocket]&path=&host=$server class=\"btn btn-success\">VNC</a>";
|
||||
}
|
||||
echo "</div>";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user