autostart delete tmp files
This commit is contained in:
parent
daabc3d8a0
commit
102e47026d
7
nlvmi
7
nlvmi
|
@ -300,6 +300,13 @@ if [ $# -gt 0 ]; then
|
|||
elif [ $1 == "checkvm" ]; then
|
||||
if [ -z $2 ]; then echo "checkvm needs two arguments"; fi
|
||||
checkvm $2
|
||||
elif [ $1 == "delautostart" ]; then
|
||||
if [ $2 == "local" ]; then
|
||||
rm /home/nlvmi/start*-$3.tmp
|
||||
rm /home/nlvmi/start*-$3.tmp.sha512
|
||||
else
|
||||
su nlvmi -c "ssh $2 \"rm /home/nlvmi/start*-$3.tmp; rm /home/nlvmi/start*-$3.tmp.sha512\""
|
||||
fi
|
||||
elif [ $1 == "start" ]; then
|
||||
if [ -z $2 ]; then echo "start needs a vmname!"; exit 1; fi
|
||||
VMFOUND="no"
|
||||
|
|
|
@ -141,7 +141,7 @@ if (isset($_SESSION['username'])){
|
|||
} else {
|
||||
$vmname = clean($_POST['deletename']);
|
||||
$vmid = clean($_POST['deleteid']);
|
||||
$sql="SELECT id,prio FROM vms WHERE vmname='$vmname' AND id='$vmid'";
|
||||
$sql="SELECT vms.id AS vid,prio,hostname,connectstring,autostart FROM vms LEFT JOIN servers ON vms.server = servers.hostname WHERE vmname='$vmname' AND vid='$vmid'";
|
||||
$res = $db_handle->query($sql);
|
||||
while ($row = $res->fetchArray(SQLITE3_ASSOC)){
|
||||
$prio = $row['prio'];
|
||||
|
@ -163,6 +163,13 @@ if (isset($_SESSION['username'])){
|
|||
}
|
||||
}
|
||||
}
|
||||
if ($row['autostart'] == "1"){
|
||||
if ($row['connectstring'] == ""){
|
||||
$shellout = shell_exec("/usr/bin/nlvmi delautostart local $vmname");
|
||||
} else {
|
||||
$shellout = shell_exec("/usr/bin/nlvmi delautostart $row[connectstring] $vmname");
|
||||
}
|
||||
}
|
||||
$sqld="DELETE FROM vms WHERE id='$vmid'";
|
||||
if ($db_handle->query($sqld)){
|
||||
echo "VM $vmname deleted!";
|
||||
|
@ -301,13 +308,13 @@ if (isset($_SESSION['username'])){
|
|||
$pres = $db_handle->query($psql);
|
||||
$prioa = $pres->fetchArray(SQLITE3_ASSOC);
|
||||
$prio = $prioa['prio'] + 1;
|
||||
|
||||
$mode="newvm";
|
||||
$sqls="INSERT INTO vms ";
|
||||
$sqlc="(";
|
||||
$sqlv=" VALUES (";
|
||||
foreach(array_keys($_REQUEST) as $rkey){
|
||||
if (($rkey!="mode")&&($rkey!="rand")){
|
||||
$rvalue = clean($_REQUEST[$rkey]);
|
||||
if ((preg_match('/macaddr/', $rkey))&&($rvalue!="")){
|
||||
$cm = checkmacfree(clean($_REQUEST['vmname']), $rvalue, $db_handle);
|
||||
if ($cm != "0") {
|
||||
|
@ -322,7 +329,6 @@ if (isset($_SESSION['username'])){
|
|||
$rvalue = "0";
|
||||
}
|
||||
}
|
||||
$rvalue = clean($_REQUEST[$rkey]);
|
||||
if ($rvalue == "x86_64"){
|
||||
$rvalue = "qemu-system-x86_64";
|
||||
} elseif ((preg_match('/no drive/', $rvalue))||($rvalue == "no cdrom")){
|
||||
|
@ -336,8 +342,8 @@ if (isset($_SESSION['username'])){
|
|||
$sqlv.=" '$prio')";
|
||||
$sql = "$sqls$sqlc$sqlv";
|
||||
$res = $db_handle->exec($sql);
|
||||
echo "success";
|
||||
exit;
|
||||
echo "success";
|
||||
exit;
|
||||
} elseif ($_REQUEST['mode']=="editvm"){
|
||||
$sql="UPDATE vms SET ";
|
||||
$autostartfound = "0";
|
||||
|
|
Loading…
Reference in New Issue