Call this v1.3

master
Pentium44 2020-12-26 20:30:23 -08:00
parent 5b7c242ade
commit bf3ef69aa7
6 changed files with 109 additions and 70 deletions

View File

@ -17,14 +17,17 @@ 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/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.
* Copy a fresh OS install of your choice in a qcow2 (or other format) image to svmm_db/disks/slitaz.img and alpine.img (THIS MUST BE DONE FOR THE SCRIPT TO COPY AND START A FRESH VM)
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.
12/26/2020 - v1.3
* [bugfix] Fix start/stop functions in some scenarios
* Added registration codes for user registration management
* Deletion feature.
* CSS cleanup
* Feature manipulation
* [to-do] Clean up code, and create two main configuration scripts for server / client VM managers for easy setup.
9/24/2020 - v1.0
* Working PHP front end with user registeration and login

View File

@ -3,13 +3,14 @@
// SVMM - Simple VM Manager - For Qemu KVM
// (C) Chris Dorman, GPL v3 (2013-2020)
// https://github.com/Pentium44/SVMM
// Version: 1.1
// Version: 1.3
///////
$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
$svmmtitle = "SVMM"; // SM title
$desc = "Nimble, open-source, and flexible Qemu-KVM VM management panel <br />With a fresh account, you'll be able to create your own free VPS, and 1 is available per user."; // Description
$domain = "https://example.com/svmm/"; // where is SSB operating?
$version = "1.3"; // version
$panelpass = "svmmregisterpass"; // Password to register a new user
$maxvm = "100"; // max vm count
?>

View File

@ -8,7 +8,7 @@ function loginForm() {
?>
<br />
<div class="login">
<a class="button" href="<?php echo $_SERVER['PHP_SELF']; ?>?forms=register">Register</a>
Don't have an account? No problem, <a href="<?php echo $_SERVER['PHP_SELF']; ?>?forms=register">register here</a>!<br /><br />
<form action="<?php echo $_SERVER['PHP_SELF']; ?>?do=login" method="post">
<table><tr><td>
Username:</td><td> <input class="text" type="text" name="username"></td></tr><tr><td>
@ -61,14 +61,15 @@ function registerForm() {
?>
<br />
<div class="login">
Don't have a registration code? Reach out! cddo [at] riseup [dot] net<br />
<form action="<?php echo $_SERVER['PHP_SELF']; ?>?do=register" method="post">
<table><tr><td>
Username:</td><td> <input class="text" type="text" name="username"></td></tr><tr><td>
Full name:</td><td> <input class="text" type="text" name="fullname"></td></tr><tr><td>
Email:</td><td><input class="text" type="text" name="email"></td></tr><tr><td>
Password:</td><td> <input class="text" type="password" name="password"></td></tr><tr><td>
Password Again:</td><td> <input class="text" type="password" name="password-again"></td></tr><tr><td>
<table><tr><td>
Username:</td><td> <input class="text" type="text" name="username"></td></tr><tr><td>
Full name:</td><td> <input class="text" type="text" name="fullname"></td></tr><tr><td>
Email:</td><td><input class="text" type="text" name="email"></td></tr><tr><td>
Password:</td><td> <input class="text" type="password" name="password"></td></tr><tr><td>
Password again:</td><td> <input class="text" type="password" name="password-again"></td></tr><tr><td>
Registration code (required):</td><td> <input class="text" type="text" name="codeword"></td></tr><tr><td>
<input class="text" type="submit" name="submitBtn" value="Register">
</td></tr></table>
</form>

View File

@ -63,6 +63,7 @@ $username = $_SESSION['svmm-user'];
--><a href="?do=logout">Logout</a><!--
<?php } else {?>
--><a href="?forms=login">Login</a><!--
--><a href="?forms=register">Register</a><!--
--><a href="?do=about">About</a><!--
<?php } ?>
--></div>
@ -82,12 +83,6 @@ if(isset($_GET['forms']))
else if($forms=="login") {
loginForm();
}
else if($forms=="friendreq") {
friendReqForm();
}
else if($forms=="changepass") {
changePassForm();
}
else { echo "ERROR: Unknown form-name<br>"; }
}
else if(isset($_GET['notify']))
@ -125,7 +120,9 @@ else if(isset($_GET['do']))
// grab session values and send friend request functions.
if($do=="create-micro") {
if($do=="create-medium") {
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")) {
@ -136,8 +133,8 @@ else if(isset($_GET['do']))
else
{
// Trigger event to start VM!
file_put_contents("svmm_db/events/$userid", "./machine start-micro $userid");
file_put_contents("ssvm_db/users/$userid.type", "micro");
file_put_contents("svmm_db/events/$userid", "./machine start-medium $userid");
file_put_contents("ssvm_db/users/$userid.type", "medium");
echo "VM created! Refer to the user management panel for start / up info.";
}
} else {
@ -146,12 +143,13 @@ else if(isset($_GET['do']))
}
}
// 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"))
if(!copy("svmm_db/disks/slitaz.img", "svmm_db/disks/$userid.img"))
{
echo "Error copying new disk image to user location... Please contact the system administrator!";
}
@ -178,8 +176,8 @@ else if(isset($_GET['do']))
$vmstatus = file_get_contents("svmm_db/users/$userid.pid.statuscode");
if($vmstatus == "false") {
$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");
if(!file_exists("svmm_db/users/$userid.type") || $vmtype == "medium") {
file_put_contents("svmm_db/events/$userid", "./machine start-medium $userid");
} else if($vmtype == "mini") {
file_put_contents("svmm_db/events/$userid", "./machine start-mini $userid");
}
@ -221,11 +219,10 @@ else if(isset($_GET['do']))
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");
file_put_contents("svmm_db/events/$userid", "./machine del $userid");
sleep(2);
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");
@ -245,25 +242,33 @@ else if(isset($_GET['do']))
include("svmm_db/users/$username.php");
if(file_exists("svmm_db/disks/$userid.img")) {
if(!file_exists("svmm_db/users/$userid.pid.status")) {
echo "Pending: VM is pending creation, this process shouldn't take longer than 30 seconds...";
echo "Please wait: VM is being created, this process shouldn't take longer than 30 seconds...";
// Refresh the page every 5 seconds for updates on the VM status.
echo "<meta http-equiv='refresh' content='5' />";
} else {
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>&nbsp;<a href='index.php?do=delete' class='button'>Delete</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><br />";
echo "The VM manipulation functions above take time to process, the page will update within 1 minute";
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>";
echo "<tr><td>Default username:</td><td> user</td></tr>";
echo "<tr><td>Default user password:</td><td> user</td></tr>";
echo "<tr><td style='padding-right: 30px;'>Default root password: </td><td>root</td></tr></table><br />";
echo "<b>Available ports for use:</b>";
echo "<table><tr><td style='padding-right:30px;'>Server side port</td><td>External port (viewable)</td></tr>";
echo "<tr><td>21</td><td>" . $userid . "21</td></tr>";
echo "<tr><td>22</td><td>" . $userid . "22</td></tr>";
echo "<tr><td>25565</td><td>" . $userid . "65</td></tr>";
echo "<tr><td>80</td><td>" . $userid . "80</td></tr>";
//echo "<tr><td>25565</td><td>" . $userid . "65</td></tr>";
echo "<tr><td>6666</td><td>" . $userid . "66</td></tr>";
echo "<tr><td>6667</td><td>" . $userid . "67</td></tr>";
echo "<tr><td>80</td><td>" . $userid . "80</td></tr>";
echo "</table>";
// Refresh the page every 5 seconds for updates on the VM status.
echo "<meta http-equiv='refresh' content='5' />";
}
} else {
echo "ERROR: VM not found!";
@ -274,7 +279,16 @@ else if(isset($_GET['do']))
if($do=="about")
{
echo "<h2>About</h2>";
echo $desc;
echo "<p>" . $desc;
echo "<br />If anyone runs into any issues with the FreeBox services, or wants to request a registration code; please reach out at cddo [at] riseup [dot] net.<br />";
echo "<br />If you enjoy the FreeBox services, please consider donating!";
echo '<form action="https://www.paypal.com/donate" method="post" target="_top">
<input type="hidden" name="cmd" value="_donations" />
<input type="hidden" name="business" value="cdorm245@gmail.com" />
<input type="hidden" name="currency_code" value="USD" />
<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_donate_LG.gif" border="0" name="submit" title="PayPal - The safer, easier way to pay online!" alt="Donate with PayPal button" />
<img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1" />
</form></p>';
}
if($do=="login")
@ -314,10 +328,16 @@ else if(isset($_GET['do']))
if($vpscount < $maxvm)
{
if(filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) {
$vpscount = $vpscount + 1;
file_put_contents("svmm_db/users/usercount", $vpscount);
file_put_contents("svmm_db/users/" . stripslashes(htmlentities($_POST['username'])) . ".php", "<?php\n\$user_handle = \"" . stripslashes(htmlentities($_POST['username'])) . "\";\n\$user_password = \"" . sha1(md5($_POST['password'])) . "\";\n \$user_email = \"" . stripslashes(htmlentities($_POST['email'])) . "\"; \$user_fullname = \"" . stripslashes(htmlentities($_POST['fullname'])) . "\"; \$userid = \"" . $vpscount . "\";\n?>");
header("Location: index.php");
if(stripslashes(htmlentities($_POST['codeword'])) == $panelpass) {
$vpscount = $vpscount + 1;
file_put_contents("svmm_db/users/usercount", $vpscount);
file_put_contents("svmm_db/users/" . stripslashes(htmlentities($_POST['username'])) . ".php", "<?php\n\$user_handle = \"" . stripslashes(htmlentities($_POST['username'])) . "\";\n\$user_password = \"" . sha1(md5($_POST['password'])) . "\";\n \$user_email = \"" . stripslashes(htmlentities($_POST['email'])) . "\"; \$user_fullname = \"" . stripslashes(htmlentities($_POST['fullname'])) . "\"; \$userid = \"" . $vpscount . "\";\n?>");
header("Location: index.php");
}
else
{
echo "ERROR: Registration code incorrect, please try again!";
}
}
else
{
@ -352,25 +372,25 @@ 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. 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 "<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 "<table><tr><td style='vertical-align: top; width: 50%; '>Best VM for IRC bouncers / session idling CLI IRC clients. Great for small websites and some development.<br /><br />";
echo "<ul><li>CPU: 10% of 1x Xeon E5649 core</li><li>RAM: 48MB dedicated</li><li>Disk: 500MB dedicated space</li><li>OS: SliTaz GNU/Linux</li><li>Network: 10mbps down + 5mbps 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 Micro Box</a></div>";
echo "</td><td style='vertical-align: top; width: 50%;'>Best VM for development / IRC server hosting / FTP server hosting. Awesome for hosting source tarballs, websites, forums, git repo, and more!";
echo "<ul><li>CPU: 25% of 1x Xeon E5649 core</li><li>RAM: 192MB dedicated</li><li>Disk: 10GB dedicated space</li><li>OS: Alpine GNU/Linux</li><li>Network: 10mbps down + 5mbps 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-medium' class='button'>Create a Mini Box</a></div>";
echo "</td></tr></table>";
}
else
{
echo "You've been assigned a VPS, click &quot;Manage&quot; for more information on your server.";
echo "<p>You've been assigned a VPS, click &quot;Manage&quot; for more information on your server.</p>";
}
}
?>
<br /><br />
<center style="background-color: #555555; padding 3px;">Powered By SVMM <?php echo $version; ?></center>
<div style="margin: auto; width: 100%; text-align: center; background-color: #555555; padding: 3px;">Powered By <a href="https://notabug.org/Pentium44/SVMM">SVMM</a> <?php echo $version; ?></div>
</div>
</div> <!-- main contain -->
</body>

45
machine
View File

@ -1,10 +1,10 @@
#!/bin/bash
MAXLOADMICRO=25
MAXLOADMINI=50
MAXLOADMINI=10
MAXLOADMEDIUM=25
CMD="qemu-system-x86_64"
MEMSMICRO=138
MEMSMINI=544
MEMSMINI=54
MEMSMEDIUM=212
case $1 in
status )
@ -28,29 +28,38 @@ case $1 in
;;
esac
;;
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
$CMD -enable-kvm -daemonize -display none -smp 1 -hda svmm_db/disks/$2.img -m ${MEMSMINI}M -net nic,model=pcnet -net user,hostfwd=tcp::${2}80-:80,hostfwd=tcp::${2}22-:22,hostfwd=tcp::${2}66-:6666,hostfwd=tcp::${2}21-:21,hostfwd=tcp::${2}67-:6667 -pidfile svmm_db/pids/$2.pid
sleep 10
./setcpulimit $(cat svmm_db/pids/$2.pid) $MAXLOADMINI > /dev/null &
#./setkilltimer $(cat svmm_db/pids/$2.pid) $2 > /dev/null &
;;
start-medium )
$CMD -enable-kvm -daemonize -display none -smp 1 -hda svmm_db/disks/$2.img -m ${MEMSMEDIUM}M -net nic,model=pcnet -net user,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
sleep 20
./setcpulimit $(cat svmm_db/pids/$2.pid) $MAXLOADMEDIUM > /dev/null &
#./setkilltimer $(cat svmm_db/pids/$2.pid) $2 > /dev/null &
;;
stopall )
killall $CMD
;;
killall $CMD
;;
stop )
echo "Stopping VM $2"
kill -TERM $(cat svmm_db/pids/$2.pid)
echo "Stopped!";;
kill -TERM $(cat svmm_db/pids/$2.pid)
;;
del )
kill -TERM $(cat svmm_db/pids/$2.pid)
rm svmm_db/disks/$2.img
rm svmm_db/pids/$2.pid
;;
* )
echo "Usage: machine {start-mini|start-large|status|stop|stopall} {_|html|return} [vm id]";;
esac

View File

@ -114,6 +114,11 @@ a:hover {
padding: 10px;
}
.contain p {
text-align: justify;
padding: 5px;
}
.maincontain {
margin: 0 auto;
width: 702px;