From db497de7d0965cbd11ea3f02031e74e8a4b5af79 Mon Sep 17 00:00:00 2001 From: billz Date: Mon, 20 Apr 2020 12:53:46 +0100 Subject: [PATCH] Initial commit: wg templates --- includes/wireguard.php | 48 +++++++++++++++++++++++++++++++++++++ templates/wg/general.php | 0 templates/wg/logging.php | 0 templates/wireguard.php | 51 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 99 insertions(+) create mode 100644 includes/wireguard.php create mode 100644 templates/wg/general.php create mode 100644 templates/wg/logging.php create mode 100644 templates/wireguard.php diff --git a/includes/wireguard.php b/includes/wireguard.php new file mode 100644 index 00000000..a0c2ed94 --- /dev/null +++ b/includes/wireguard.php @@ -0,0 +1,48 @@ +addMessage('Attempting to start WireGuard', 'info'); + exec('sudo /bin/systemctl start wg-quick@wg0', $return); + exec('sudo /bin/systemctl enable wg-quick@wg0', $return); + foreach ($return as $line) { + $status->addMessage($line, 'info'); + } + } elseif (isset($_POST['stopwg'])) { + $status->addMessage('Attempting to stop WireGuard', 'info'); + exec('sudo /bin/systemctl stop wg-quick@wg0', $return); + exec('sudo /bin/systemctl disable wg-quick@wg0', $return); + foreach ($return as $line) { + $status->addMessage($line, 'info'); + } + } + } + + exec('pidof wg | wc -l', $wgstatus); + + $serviceStatus = $wgstatus[0] == 0 ? "down" : "up"; + + echo renderTemplate( + "wireguard", compact( + "status", + "serviceStatus" + ) + ); +} + diff --git a/templates/wg/general.php b/templates/wg/general.php new file mode 100644 index 00000000..e69de29b diff --git a/templates/wg/logging.php b/templates/wg/logging.php new file mode 100644 index 00000000..e69de29b diff --git a/templates/wireguard.php b/templates/wireguard.php new file mode 100644 index 00000000..b3f33796 --- /dev/null +++ b/templates/wireguard.php @@ -0,0 +1,51 @@ + + + "> + + "> + + "> + + + + +
+
+
+
+
+
+ +
+
+ +
+
+
+
+ showMessages(); ?> +
+ + + + + +
+ + +
+ + +
+
+ +
+
+
+