Call this v1.1...

master
Pentium44 2020-11-03 20:46:00 -08:00
parent a5440b04e5
commit 5b7c242ade
6 changed files with 101 additions and 27 deletions

View File

@ -17,10 +17,15 @@ Setup
* Modify config.php to your needs
* Visit page to generate svmm_db for flat file user database
* Execute SVMM backend as SU: sudo ./start-svmm start
* Copy a fresh OS install of your choice in a qcow2 (or other format) image to svmm_db/disks/clean.img (THIS MUST BE DONE FOR THE SCRIPT TO COPY AND START A FRESH VM)
* Copy a fresh OS install of your choice in a qcow2 (or other format) image to svmm_db/disks/alpine.img and svmm_db/disks/debian.img (THIS MUST BE DONE FOR THE SCRIPT TO COPY AND START A FRESH VM)
* * For notes on the vm name, they'll be updated in the future.
ChangeLog
----
11/3/2020 - v1.1
* Multi-VM specifications for startup options...
* Support VM deletion in case of VM disk corruption of needing of a fresh VM.
9/24/2020 - v1.0
* Working PHP front end with user registeration and login
* Working bash back end for server management

View File

@ -3,13 +3,13 @@
// SVMM - Simple VM Manager - For Qemu KVM
// (C) Chris Dorman, GPL v3 (2013-2020)
// https://github.com/Pentium44/SVMM
// Version: 1.0
// Version: 1.1
///////
$svmmtitle = "FreeBox"; // SM title
$desc = "Simple, ad-free, yet flexible VPS hosting platform to the user; for the user! " . $svmmtitle . " is powered by SVMM.<br /><br />With a fresh account, you'll be able to create your own free VPS, and 1 is available per user."; // platform description
$domain = "vps.cddo.cf"; // where is SSB operating?
$version = "1.0"; // version
$maxvm = "100"; // max vm count
$svmmtitle = "Simple VM Manager"; // SM title
$desc = "Simple, ad-free, yet flexible VPS hosting platform to the user; for the user! " . $svmmtitle . " is powered by SVMM.<br /><br />With a fresh account, you'll be able to create your own free VPS, and 1 is available per user. Each VM is monitored for inappropriate network traffic. Mining scripts, torrenting, seedboxes, proxy servers, and copywritten content without proper ownership is strictly forbidden on these servers. VM security is left to the user and is to be taken seriously! Root passwords MUST be changed when first generating your VM. Malicious findings will result in the removal of your user account and your VM!"; // Description
$domain = "https://hosting.cddo.cf"; // where is SSB operating?
$version = "1.1"; // version
$maxvm = "50"; // max vm count
?>

BIN
freebox-logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

View File

@ -67,8 +67,8 @@ $username = $_SESSION['svmm-user'];
<?php } ?>
--></div>
</div>
<div class='title'><img src='freebox-logo.png' /></div>
<div class='contain'>
<div class='title'><?php echo $svmmtitle; ?></div>
<?php
@ -125,18 +125,41 @@ else if(isset($_GET['do']))
// grab session values and send friend request functions.
if($do=="create") {
if($do=="create-micro") {
if (!isset($_SESSION['svmm-user']) || !isset($_SESSION['svmm-pass'])) { loginForm(); } else {
include("svmm_db/users/$username.php");
if(!file_exists("svmm_db/disks/$userid.img")) {
if(!copy("svmm_db/disks/clean.img", "svmm_db/disks/$userid.img"))
if(!copy("svmm_db/disks/alpine.img", "svmm_db/disks/$userid.img"))
{
echo "Error copying new disk image to user location... Please contact the system administrator!";
}
else
{
// Trigger event to start VM!
file_put_contents("svmm_db/events/$userid", "./machine start $userid");
file_put_contents("svmm_db/events/$userid", "./machine start-micro $userid");
file_put_contents("ssvm_db/users/$userid.type", "micro");
echo "VM created! Refer to the user management panel for start / up info.";
}
} else {
echo "Error: VM exists, please click &quot;Manage&quot; to start / stop your VM or to download a disk backup.";
}
}
}
// For real VMs
if($do=="create-mini") {
if (!isset($_SESSION['svmm-user']) || !isset($_SESSION['svmm-pass'])) { loginForm(); } else {
include("svmm_db/users/$username.php");
if(!file_exists("svmm_db/disks/$userid.img")) {
if(!copy("svmm_db/disks/debian.img", "svmm_db/disks/$userid.img"))
{
echo "Error copying new disk image to user location... Please contact the system administrator!";
}
else
{
// Trigger event to start VM!
file_put_contents("svmm_db/events/$userid", "./machine start-mini $userid");
file_put_contents("svmm_db/users/$userid.type", "mini");
echo "VM created! Refer to the user management panel for start / up info.";
}
} else {
@ -154,7 +177,12 @@ else if(isset($_GET['do']))
} else {
$vmstatus = file_get_contents("svmm_db/users/$userid.pid.statuscode");
if($vmstatus == "false") {
file_put_contents("svmm_db/events/$userid", "./machine start $userid");
$vmtype = file_get_contents("svmm_db/users/$userid.type");
if(!file_exists("svmm_db/users/$userid.type") || $vmtype == "micro") {
file_put_contents("svmm_db/events/$userid", "./machine start-micro $userid");
} else if($vmtype == "mini") {
file_put_contents("svmm_db/events/$userid", "./machine start-mini $userid");
}
header("Location: index.php?do=manage");
} else {
echo "VM already running...";
@ -187,6 +215,31 @@ else if(isset($_GET['do']))
}
}
if($do=="delete") {
if (!isset($_SESSION['svmm-user']) || !isset($_SESSION['svmm-pass'])) { loginForm(); } else {
include("svmm_db/users/$username.php");
if(file_exists("svmm_db/disks/$userid.img")) {
$vmstatus = file_get_contents("svmm_db/users/$userid.pid.statuscode");
if($vmstatus == "true") {
file_put_contents("svmm_db/events/$userid", "./machine stop $userid");
unlink("svmm_db/users/$userid.pid.status");
unlink("svmm_db/users/$userid.pid.statuscode");
unlink("svmm_db/pids/$userid.pid");
unlink("svmm_db/disks/$userid.img");
header("Location: index.php");
} else {
unlink("svmm_db/users/$userid.pid.status");
unlink("svmm_db/users/$userid.pid.statuscode");
unlink("svmm_db/pids/$userid.pid");
unlink("svmm_db/disks/$userid.img");
header("Location: index.php");
}
} else {
echo "ERROR: VM not found!";
}
}
}
if($do=="manage") {
if (!isset($_SESSION['svmm-user']) || !isset($_SESSION['svmm-pass'])) { loginForm(); } else {
include("svmm_db/users/$username.php");
@ -197,7 +250,7 @@ else if(isset($_GET['do']))
echo $username . "'s VM<br /> VM status: ";
$vmstatus = file_get_contents("svmm_db/users/$userid.pid.status");
echo $vmstatus;
echo "<br /><a href='index.php?do=start' class='button'>Start</a>&nbsp;<a href='index.php?do=stop' class='button'>Stop</a>";
echo "<br /><a href='index.php?do=start' class='button'>Start</a>&nbsp;<a href='index.php?do=stop' class='button'>Stop</a>&nbsp;<a href='index.php?do=delete' class='button'>Delete</a>";
echo "<br /><br />";
echo "<b>Connection information (Via SSH):</b><br />";
echo "<table><tr><td>IP/Port:</td><td> cddo.cf/" . $userid . "22</td></tr>";
@ -291,7 +344,7 @@ else if(isset($_GET['do']))
}
else if (!isset($_SESSION['svmm-user']) || !isset($_SESSION['svmm-pass']))
{
loginForm();
header("Location: index.php?do=about");
}
else
{
@ -299,9 +352,14 @@ else
if(!file_exists("svmm_db/disks/$userid.img"))
{
echo "<h3>Free VPS creation</h3>";
echo "<p>Each user will have the ability to create a VM, and will have a consistent uptime unless FreeBox ends up being disabled due to malicious users improperly using the virtual machines</p>";
echo "<ul><li>CPU: 10% of 1x Xeon E5649 core</li><li>RAM: 128MB dedicated</li><li>Disk: 10GB dedicated space</li><li>OS: Alpine GNU/Linux</li><li>Network: 50mbps down + 2mbps upload</li><li>Select available ports for server operation</li></ul>";
echo "<a href='index.php?do=create' class='button'>Create a VPS</a>";
echo "<p>Each user will have the ability to create a VM, and will have a consistent uptime unless FreeBox ends up being disabled due to malicious users improperly using the virtual machines. The choice is yours, but remember theres a limited amount of mini boxes in comparison to the micro boxes.</p>";
echo "<table><tr><td style='vertical-align: top;'>";
echo "<ul><li>CPU: 25% of 1x Xeon E5649 core</li><li>RAM: 128MB dedicated</li><li>Disk: 10GB dedicated space</li><li>OS: Alpine GNU/Linux</li><li>Network: 50mbps down + 2mbps upload</li><li>Select available ports for server operation</li></ul>";
echo "<div style='display:block;width:100%;text-align:center;'><a href='index.php?do=create-micro' class='button'>Create a MicroVM</a></div>";
echo "</td><td style='vertical-align: top;'>";
echo "<ul><li>CPU: 50% of 2x Xeon E5649 cores</li><li>RAM: 512MB dedicated</li><li>Disk: 25GB dedicated space</li><li>OS: Debian GNU/Linux</li><li>Network: 50mbps down + 2mbps upload</li><li>Select available ports for server operation</li></ul>";
echo "<div style='display:block;width:100%;text-align:center;'><a href='index.php?do=create-mini' class='button'>Create a MiniVM</a></div>";
echo "</td></tr></table>";
}
else
{

21
machine
View File

@ -1,8 +1,10 @@
#!/bin/bash
MAXLOAD=25
MAXLOADMICRO=25
MAXLOADMINI=50
CMD="qemu-system-x86_64"
MEMS=138
MEMSMICRO=138
MEMSMINI=544
case $1 in
status )
@ -26,9 +28,16 @@ case $1 in
;;
esac
;;
start )
$CMD -enable-kvm -daemonize -display none -hda svmm_db/disks/$2.img -m ${MEMS}M -net nic,model=e1000,vlan=0,vlan=1 -net user,vlan=0,vlan=1,hostfwd=tcp::${2}80-:80,hostfwd=tcp::${2}22-:22,hostfwd=tcp::${2}66-:6666,hostfwd=tcp::${2}65-:25665,hostfwd=tcp::${2}21-:21,hostfwd=tcp::${2}67-:6667 -pidfile svmm_db/pids/$2.pid
./setcpulimit $(cat svmm_db/pids/$2.pid) $MAXLOAD > /dev/null &
start-micro )
$CMD -enable-kvm -daemonize -display none -hda svmm_db/disks/$2.img -m ${MEMSMICRO}M -net nic,model=pcnet,vlan=0,vlan=1 -net user,vlan=0,vlan=1,hostfwd=tcp::${2}80-:80,hostfwd=tcp::${2}22-:22,hostfwd=tcp::${2}66-:6666,hostfwd=tcp::${2}65-:25665,hostfwd=tcp::${2}21-:21,hostfwd=tcp::${2}67-:6667 -pidfile svmm_db/pids/$2.pid
./setcpulimit $(cat svmm_db/pids/$2.pid) $MAXLOADMICRO > /dev/null &
#./setkilltimer $(cat svmm_db/pids/$2.pid) $2 > /dev/null &
;;
start-mini )
$CMD -enable-kvm -daemonize -display none -hda svmm_db/disks/$2.img -m ${MEMSMINI}M -smp 2 -net nic,model=pcnet,vlan=0,vlan=1 -net user,vlan=0,vlan=1,hostfwd=tcp::${2}80-:80,hostfwd=tcp::${2}22-:22,hostfwd=tcp::${2}66-:6666,hostfwd=tcp::${2}65-:25665,hostfwd=tcp::${2}21-:21,hostfwd=tcp::${2}67-:6667 -pidfile svmm_db/pids/$2.pid
./setcpulimit $(cat svmm_db/pids/$2.pid) $MAXLOADMINI > /dev/null &
#./setkilltimer $(cat svmm_db/pids/$2.pid) $2 > /dev/null &
;;
@ -43,5 +52,5 @@ case $1 in
echo "Stopped!";;
* )
echo "Usage: machine {start|status|stop|stopall} {_|html|return} [vm id]";;
echo "Usage: machine {start-mini|start-large|status|stop|stopall} {_|html|return} [vm id]";;
esac

View File

@ -12,6 +12,8 @@ html, body {
.title {
font-size: 46px;
text-align: center;
background-position: center;
background-color: #dddddd;
padding: 8px;
}
@ -105,11 +107,11 @@ a:hover {
.contain {
background-color: #121212;
border: solid 1px #565656;
width: 690px;
max-width: 690px;
min-width: 690px;
width: 680px;
max-width: 680px;
min-width: 680px;
margin: 0 auto;
padding: 5px;
padding: 10px;
}
.maincontain {