mirror of
https://github.com/serghey-rodin/vesta.git
synced 2026-05-07 23:07:20 +02:00
Merge pull request #2112 from serghey-rodin/feature/restart-system
Added system reboot endpoint.
This commit is contained in:
23
web/api/v1/restart/system/index.php
Normal file
23
web/api/v1/restart/system/index.php
Normal 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']);
|
||||
Reference in New Issue
Block a user