aboutsummaryrefslogtreecommitdiffstats
path: root/manage.php
diff options
context:
space:
mode:
authorLeonardo Bishop <me@leonardobishop.com>2025-04-25 00:54:15 +0100
committerLeonardo Bishop <me@leonardobishop.com>2025-04-25 00:54:15 +0100
commit45a18c0ecb364c42307641b4057ff5a814e69b2e (patch)
tree3ede8191b4b2ddb55df393d5b70d02977f4d8ea4 /manage.php
Version control
Diffstat (limited to 'manage.php')
-rw-r--r--manage.php68
1 files changed, 68 insertions, 0 deletions
diff --git a/manage.php b/manage.php
new file mode 100644
index 0000000..c4858ca
--- /dev/null
+++ b/manage.php
@@ -0,0 +1,68 @@
+<?php
+require_once('util.php');
+require_once('serviceDefinitions.php');
+
+session_start();
+
+$container = $_GET['container'];
+$action = $_GET['action'];
+
+Util\doSessionCheck('manage.php?container=' . $container);
+?>
+<!DOCTYPE html>
+<html>
+
+<head>
+ <title>Manage container</title>
+ <link rel="stylesheet" type="text/css" href="styles.css">
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
+</head>
+
+<body>
+ <div class="container">
+ <h1>Manage container: <?php echo $container ?></h1>
+ <a href="index.php">Home</a>
+ <a href="status.php">Status</a>
+ <hr>
+ <?php
+ //if (empty($container)) {
+ // Util\createBanner('✗', 'No service specified', 'bad');
+ // return;
+ //}
+ //if (!in_array($service, array_map(function ($s) {
+ // return $s->name;
+ //}, $services))) {
+ // Util\createBanner('✗', "Service '$service' is unknown", 'bad');
+ // return;
+ //}
+
+ $status = Util\getDockerStatus($container);
+
+ if ($status->status === '-') {
+ Util\createBanner('✗', "Container '$container' not found", 'bad');
+ return;
+ }
+
+ if ($action === 'start' || $action === 'stop' || $action === 'restart' || $action === 'logs') {
+ // if ($action === 'start' || $action === 'stop' || $action === 'restart') {
+ $safeService = escapeshellarg($container);
+ Util\doShellExec('sudo docker ' . $action . ' ' . $safeService, '/manage.php?container=' . $container, $action);
+ }
+
+ Util\createStatusBanner($status);
+ ?>
+ <p>
+ <details>
+ <summary>Status as reported by Docker</summary>
+ <?php Util\createStatusTable($status); ?>
+ </details>
+ </p>
+
+ <p class="control-list">
+ <a href="manage.php?container=<?php echo $container ?>&action=logs">[Logs]</a>
+ <a href="manage.php?container=<?php echo $container ?>&action=start">[Start]</a>
+ <a href="manage.php?container=<?php echo $container ?>&action=stop">[Stop]</a>
+ <a href="manage.php?container=<?php echo $container ?>&action=restart">[Restart]</a>
+ </p>
+ </div>
+</body>