chore: initial commit

This commit is contained in:
2026-06-13 00:11:05 +01:00
commit 2742a3baac
10 changed files with 277 additions and 0 deletions
+7
View File
File diff suppressed because one or more lines are too long
+100
View File
@@ -0,0 +1,100 @@
body {
background-color: #292c31;
height: 100vh;
}
.card {
margin-top: 8rem;
background-color: #454e54;
border: none;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}
.card-body {
padding: 40px;
}
.card-header {
background-color: #007bfe;
color: #fff;
border-bottom: none;
border-radius: 1em 1em 0 0;
}
.btn-start {
background-color: #007bff;
border: none;
}
.btn-start:hover {
background-color: #0056b3;
}
.card-footer {
background-color: #353a3f;
border-top: none;
color: #6c757d;
}
.dot {
height: 10px; /* Smaller inner circle */
width: 10px; /* Smaller inner circle */
border-radius: 50%;
display: inline-block;
position: relative;
background-color: grey; /* Default grey color */
}
.dot::before {
content: "";
position: absolute;
top: 50%;
left: 50%;
width: 100%;
height: 100%;
border-radius: 50%;
transform: translate(-50%, -50%) scale(2); /* Scale to match outer size */
z-index: -1;
}
.green {
background-color: #66ff66; /* Lighter green for online status */
}
.green::before {
background-color: rgba(0, 255, 0, 0.5); /* Lighter outer green */
animation: pulse-green 1.5s infinite;
}
.red {
background-color: red;
}
.red::before {
background-color: rgba(255, 0, 0, 0.5); /* Lighter outer red */
animation: pulse-red 1.5s infinite;
}
@keyframes pulse-green {
0% {
transform: translate(-50%, -50%) scale(1);
opacity: 1;
}
70% {
transform: translate(-50%, -50%) scale(2.5);
opacity: 0;
}
100% {
transform: translate(-50%, -50%) scale(2.5);
opacity: 0;
}
}
@keyframes pulse-red {
0% {
transform: translate(-50%, -50%) scale(1);
opacity: 1;
}
70% {
transform: translate(-50%, -50%) scale(2.5);
opacity: 0;
}
100% {
transform: translate(-50%, -50%) scale(2.5);
opacity: 0;
}
}
+7
View File
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+2
View File
File diff suppressed because one or more lines are too long
+6
View File
File diff suppressed because one or more lines are too long
+21
View File
@@ -0,0 +1,21 @@
<?php
// List of hosts to be able to wake up using Kratos.
// The first item in the array will be the default when hitting the kratos homepage, to
$hosts = array(
array(
"mac_address" => "64:16:7F:B1:D8:31",
"ip_address" => "10.0.0.1",
"name" => "gaia",
"friendly_name" => "Gaia (Home Server)"
),
array(
"mac_address" => "89:96:F3:36:D4:C4",
"ip_address" => "10.0.0.2",
"name" => "fedora",
"friendly_name" => "Fedora (Desktop)"
)
);
print_r(json_encode($hosts));
+94
View File
@@ -0,0 +1,94 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Kratos Power Management</title>
<link href="assets/css/bootstrap.min.css" rel="stylesheet">
<link href="assets/css/main.css" rel="stylesheet">
</head>
<body>
<div class="container">
<div class="row justify-content-center">
<div class="col-md-6">
<div class="card">
<div class="card-header text-center">
<h3 style="padding-bottom: 0; margin-bottom: 0;">Kratos</h3>
<h6>Power Management</h6>
</div>
<div class="card-body">
<form method="post" id="wakeonlan" action="wake.php">
<div class="text-center">
<button type="submit" class="btn btn-primary btn-start">Send Wake Packet</button>
</div>
</div>
</form>
<div class="card-footer text-muted text-center">
<small>
This will send a magic packet to
<select class="form-select bg-dark border-0 shadow-none text-white text-center" form="wakeonlan" id="target" name="target">
</select>
to wake it up.
<br>
Current Status:
<span id="status-dot" class="dot"></span>
</small>
</div>
</div>
</div>
</div>
</div>
<!-- Bootstrap JS (optional) -->
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.5.4/dist/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script>
function checkServerStatus() {
$.ajax({
url: 'ping.php?host=' + $("#target option:selected").val(),
method: 'GET',
dataType: 'json',
success: function(response) {
if(response.status === 'online') {
$('#status-dot').removeClass('red').addClass('green');
} else {
$('#status-dot').removeClass('green').addClass('red');
}
},
error: function() {
$('#status-dot').removeClass('green').addClass('red');
}
});
}
checkServerStatus();
setInterval(checkServerStatus, 5000);
var obj = jQuery.parseJSON('<?php include 'hosts.php'; ?>');
$.each(obj, function(key,value) {
$('#target').append('<option value="'+ value.mac_address+'">'+value.friendly_name+'</option>');
});
$("#wakeonlan").submit(function(e) {
e.preventDefault();
var form = $(this);
var actionUrl = form.attr('action');
$.ajax({
type: "POST",
url: actionUrl,
data: form.serialize(),
success: function(data)
{
alert(data);
}
});
});
</script>
</body>
</html>
+18
View File
@@ -0,0 +1,18 @@
<?php
$host = "10.1.1.2";
echo json_encode(ping($host));
function ping($host) {
$command = "ping -c 4 " . escapeshellarg($host);
$output = [];
exec($command, $output, $status);
// Check if the ping was successful
if ($status == 0) {
return ['status' => 'online', 'output' => $output];
} else {
return ['status' => 'offline', 'output' => $output];
}
}
?>
+20
View File
@@ -0,0 +1,20 @@
<?php
function wakeOnLan($macAddress) {
$output = shell_exec("wakeonlan " . escapeshellarg($macAddress));
if ($output === null) {
return "Failed to send Magic Packet.";
}
return true;
return true;
}
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$macAddress = $_POST['target'];
$result = wakeOnLan($macAddress);
if ($result === true) {
$message = "Magic Packet sent successfully!";
} else {
$message = $result;
}
}