Merge pull request #2112 from serghey-rodin/feature/restart-system

Added system reboot endpoint.
This commit is contained in:
Serghey Rodin 2021-11-01 00:24:55 +02:00 committed by GitHub
commit ddee8801a4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -0,0 +1,23 @@
<?php
// Init
error_reporting(NULL);
ob_start();
session_start();
include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
// Check token
if ((!isset($_GET['token'])) || ($_SESSION['token'] != $_GET['token'])) {
exit();
}
if ($_SESSION['user'] == 'admin') {
if (!empty($_GET['hostname'])) {
exec (VESTA_CMD."v-restart-system yes", $output, $return_var);
$_SESSION['error_msg'] = 'The system is going down for reboot NOW!';
}
unset($output);
}
echo json_encode(array('error' => $_SESSION['error_msg']));
unset($_SESSION['error_msg']);