mirror of
https://github.com/unraid/webgui.git
synced 2026-02-07 01:19:08 -06:00
Merge remote-tracking branch 'upstream/master'
This commit is contained in:
@@ -2482,6 +2482,20 @@ If set to 'Yes' the bash history will persist reboots, set to 'No' to disable.
|
||||
**Note:** Disabling and Enabling will remove the entire bash history.
|
||||
:end
|
||||
|
||||
:WOL_intro_help:
|
||||
This page allows the setup to start/resume and stop VMs, Containters(Docker and LXC) using WOL magic packets
|
||||
|
||||
It does setup wake up of the Unraid server.
|
||||
|
||||
The process will look for the defined mac address defined within the service(VM or container) with the exception of dockers. Dockers do not have a mac address until they are running so you will need to define a user mac address to allow you to start them
|
||||
|
||||
If the service is paused a WOL Packet will resume.
|
||||
|
||||
For each service you can set: enable, disable or enable and shutdown
|
||||
|
||||
When the enable and shutdown is set if the service is running when the next WOL packet is recieved a shutdown will be performed.
|
||||
|
||||
:end:
|
||||
|
||||
:WOL_enable_help:
|
||||
If set to yes Unraidwold daemon is set to run.
|
||||
@@ -2499,6 +2513,10 @@ If set to yes when wake on lan packets are received checks are carrried out for
|
||||
If set to yes when wake on lan packets are received checks are carrried out for LXC otherwise LXC will be ignored. The LXC plugin needs to be installed for LXC to be processed.
|
||||
:end
|
||||
|
||||
:WOL_run_shutdown_help:
|
||||
If set to yes when wake on lan packets are received checks are carrried out and if enabled for service and that service is running the entity will be shutdown. System has to be set to Enabled and Shutdwon for it to be action.
|
||||
:end
|
||||
|
||||
:WOL_interface_help:
|
||||
Specify the interface to the daemon to bind to. Some interfaces may not be able to recieve etherframe packets. Recommend to bind to a physical interface.
|
||||
:end
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
|
||||
require_once "$docroot/webGui/include/Helpers.php";
|
||||
require_once "$docroot/webGui/include/Wrappers.php";
|
||||
|
||||
// add translations
|
||||
extract(parse_plugin_cfg('dynamix',true));
|
||||
@@ -27,6 +28,9 @@ if ($_SERVER['REQUEST_URI'] == '/logout') {
|
||||
$error = _('Successfully logged out');
|
||||
}
|
||||
|
||||
// If issue with license key redirect to Tools/Registration, otherwise go to start page
|
||||
$start_page = (!empty(_var($var,'regCheck'))) ? 'Tools/Registration' : _var($var,'START_PAGE','Main');
|
||||
|
||||
$result = exec( "/usr/bin/passwd --status root");
|
||||
if (($result === false) || (substr($result, 0, 6) !== "root P"))
|
||||
include "$docroot/webGui/include/.set-password.php";
|
||||
|
||||
@@ -367,7 +367,7 @@ class DockerTemplates {
|
||||
@copy($iconRAM,$icon);
|
||||
}
|
||||
if (!is_file($iconRAM)) {
|
||||
exec("logger -t webGUI -- \"$contName: Could not download icon $imgUrl\"");
|
||||
my_logger("$contName: Could not download icon $imgUrl");
|
||||
}
|
||||
|
||||
return (is_file($iconRAM)) ? str_replace($docroot, '', $iconRAM) : '';
|
||||
|
||||
@@ -15,6 +15,7 @@ $webguiGlobals = $GLOBALS;
|
||||
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
|
||||
|
||||
require_once "$docroot/plugins/dynamix.my.servers/include/reboot-details.php";
|
||||
require_once "$docroot/plugins/dynamix.plugin.manager/include/UnraidCheck.php";
|
||||
/**
|
||||
* ServerState class encapsulates server-related information and settings.
|
||||
*
|
||||
@@ -47,7 +48,10 @@ class ServerState
|
||||
private $rebootDetails;
|
||||
private $caseModel = '';
|
||||
private $keyfileBase64UrlSafe = '';
|
||||
private $updateOsCheck;
|
||||
private $updateOsNotificationsEnabled = false;
|
||||
private $updateOsResponse;
|
||||
private $updateOsIgnoredReleases = [];
|
||||
|
||||
public $myServersFlashCfg = [];
|
||||
public $myServersMemoryCfg = [];
|
||||
@@ -164,10 +168,10 @@ class ServerState
|
||||
$this->keyfileBase64UrlSafe = str_replace(['+', '/', '='], ['-', '_', ''], trim($this->keyfileBase64));
|
||||
}
|
||||
|
||||
/**
|
||||
* updateOsResponse is provided by the dynamix.plugin.manager/scripts/unraidcheck script saving to /tmp/unraidcheck/result.json
|
||||
*/
|
||||
$this->updateOsResponse = @json_decode(@file_get_contents('/tmp/unraidcheck/result.json'), true);
|
||||
$this->updateOsCheck = new UnraidOsCheck();
|
||||
$this->updateOsIgnoredReleases = $this->updateOsCheck->getIgnoredReleases();
|
||||
$this->updateOsNotificationsEnabled = !empty(@$this->getWebguiGlobal('notify')['unraidos']);
|
||||
$this->updateOsResponse = $this->updateOsCheck->getUnraidOSCheckResult();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -249,6 +253,14 @@ class ServerState
|
||||
$serverState['combinedKnownOrigins'] = $this->combinedKnownOrigins;
|
||||
}
|
||||
|
||||
if ($this->updateOsIgnoredReleases) {
|
||||
$serverState['updateOsIgnoredReleases'] = $this->updateOsIgnoredReleases;
|
||||
}
|
||||
|
||||
if ($this->updateOsNotificationsEnabled) {
|
||||
$serverState['updateOsNotificationsEnabled'] = $this->updateOsNotificationsEnabled;
|
||||
}
|
||||
|
||||
if ($this->updateOsResponse) {
|
||||
$serverState['updateOsResponse'] = $this->updateOsResponse;
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -1,13 +1,13 @@
|
||||
{
|
||||
".nuxt/nuxt-custom-elements/entries/unraid-components.client.css": {
|
||||
"file": "_nuxt/unraid-components.client-b74ef392.css",
|
||||
"file": "_nuxt/unraid-components.client-fad7c220.css",
|
||||
"src": ".nuxt/nuxt-custom-elements/entries/unraid-components.client.css"
|
||||
},
|
||||
".nuxt/nuxt-custom-elements/entries/unraid-components.client.mjs": {
|
||||
"css": [
|
||||
"_nuxt/unraid-components.client-b74ef392.css"
|
||||
"_nuxt/unraid-components.client-fad7c220.css"
|
||||
],
|
||||
"file": "_nuxt/unraid-components.client-b620404a.js",
|
||||
"file": "_nuxt/unraid-components.client-e6cfc5d4.js",
|
||||
"isEntry": true,
|
||||
"src": ".nuxt/nuxt-custom-elements/entries/unraid-components.client.mjs"
|
||||
}
|
||||
|
||||
266
emhttp/plugins/dynamix.plugin.manager/include/UnraidCheck.php
Normal file
266
emhttp/plugins/dynamix.plugin.manager/include/UnraidCheck.php
Normal file
@@ -0,0 +1,266 @@
|
||||
<?php
|
||||
/* Copyright 2005-2023, Lime Technology
|
||||
* Copyright 2012-2023, Bergware International.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License version 2,
|
||||
* as published by the Free Software Foundation.
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*/
|
||||
/**
|
||||
* Abstracting this code into a separate file allows us to use it in multiple places without duplicating code.
|
||||
* 1. unraidcheck script can call this
|
||||
* require_once "$docroot/plugins/dynamix.plugin.manager/include/UnraidCheck.php";
|
||||
* $unraidOsCheck = new UnraidOsCheck();
|
||||
* $unraidOsCheck->checkForUpdate();
|
||||
*
|
||||
* 2. Unraid webgui web components can GET this file with action params to get updates, ignore updates, etc.
|
||||
* - EX: Unraid webgui web components can check for updates via a GET request and receive a response with the json file directly
|
||||
* - this is useful for the UPC to check for updates and display a model based on the value
|
||||
* - `/plugins/dynamix.plugin.manager/scripts/unraidcheck.php?json=true`
|
||||
* - note the json=true query param to receive a json response
|
||||
*
|
||||
* @param action {'check'|'removeAllIgnored'|'removeIgnoredVersion'|'ignoreVersion'} - the action to perform
|
||||
* @param version {string} - the version to ignore or remove
|
||||
* @param json {string} - if set to true, will return the json response from the external request
|
||||
* @param altUrl {URL} - if set, will use this url instead of the default
|
||||
*/
|
||||
$docroot ??= ($_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp');
|
||||
require_once "$docroot/webGui/include/Wrappers.php";
|
||||
require_once "$docroot/plugins/dynamix.plugin.manager/include/PluginHelpers.php";
|
||||
|
||||
class UnraidOsCheck
|
||||
{
|
||||
private const BASE_RELEASES_URL = 'https://releases.unraid.net/os';
|
||||
private const JSON_FILE_IGNORED = '/tmp/unraidcheck/ignored.json';
|
||||
private const JSON_FILE_IGNORED_KEY = 'updateOsIgnoredReleases';
|
||||
private const JSON_FILE_RESULT = '/tmp/unraidcheck/result.json';
|
||||
private const PLG_PATH = '/var/log/plugins/unRAIDServer.plg';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$isGetRequest = !empty($_SERVER) && isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] === 'GET';
|
||||
$getHasAction = $_GET !== null && !empty($_GET) && isset($_GET['action']);
|
||||
|
||||
if ($isGetRequest && $getHasAction) {
|
||||
$this->handleGetRequestWithActions();
|
||||
}
|
||||
}
|
||||
|
||||
private function handleGetRequestWithActions()
|
||||
{
|
||||
switch ($_GET['action']) {
|
||||
case 'check':
|
||||
$this->checkForUpdate();
|
||||
break;
|
||||
|
||||
case 'removeAllIgnored':
|
||||
$this->removeAllIgnored();
|
||||
break;
|
||||
|
||||
case 'removeIgnoredVersion':
|
||||
if (isset($_GET['version'])) {
|
||||
$this->removeIgnoredVersion($_GET['version']);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'ignoreVersion':
|
||||
if (isset($_GET['version'])) {
|
||||
$this->ignoreVersion($_GET['version']);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
$this->respondWithError(400, "Unhandled action");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public function getUnraidOSCheckResult()
|
||||
{
|
||||
if (file_exists(self::JSON_FILE_RESULT)) {
|
||||
return $this->readJsonFile(self::JSON_FILE_RESULT);
|
||||
}
|
||||
}
|
||||
|
||||
public function getIgnoredReleases()
|
||||
{
|
||||
if (!file_exists(self::JSON_FILE_IGNORED)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$ignoredData = $this->readJsonFile(self::JSON_FILE_IGNORED);
|
||||
|
||||
if (is_array($ignoredData) && array_key_exists(self::JSON_FILE_IGNORED_KEY, $ignoredData)) {
|
||||
return $ignoredData[self::JSON_FILE_IGNORED_KEY];
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
/** @todo clean up this method to be more extensible */
|
||||
public function checkForUpdate()
|
||||
{
|
||||
// Multi-language support
|
||||
if (!function_exists('_')) {
|
||||
function _($text) {return $text;}
|
||||
}
|
||||
|
||||
extract(parse_plugin_cfg('dynamix', true));
|
||||
|
||||
$var = (array)@parse_ini_file('/var/local/emhttp/var.ini');
|
||||
|
||||
$params = [];
|
||||
$params['branch'] = plugin('category', self::PLG_PATH, 'stable');
|
||||
$params['current_version'] = plugin('version', self::PLG_PATH) ?: _var($var,'version');
|
||||
if (_var($var,'regExp')) $params['update_exp'] = date('m-d-Y', _var($var,'regExp')*1);
|
||||
$defaultUrl = self::BASE_RELEASES_URL;
|
||||
// pass a param of altUrl to use the provided url instead of the default
|
||||
$parsedAltUrl = (array_key_exists('altUrl',$_GET) && $_GET['altUrl']) ? $_GET['altUrl'] : null;
|
||||
// if $parsedAltUrl pass to params
|
||||
if ($parsedAltUrl) $params['altUrl'] = $parsedAltUrl;
|
||||
|
||||
$urlbase = $parsedAltUrl ?? $defaultUrl;
|
||||
$url = $urlbase.'?'.http_build_query($params);
|
||||
|
||||
$response = "";
|
||||
// use error handler to convert warnings from file_get_contents to errors so they can be captured
|
||||
function warning_as_error($severity, $message, $filename, $lineno) {
|
||||
throw new ErrorException($message, 0, $severity, $filename, $lineno);
|
||||
}
|
||||
set_error_handler("warning_as_error");
|
||||
try {
|
||||
$response = file_get_contents($url);
|
||||
} catch (Exception $e) {
|
||||
$response = json_encode(array('error' => $e->getMessage()), JSON_PRETTY_PRINT);
|
||||
}
|
||||
restore_error_handler();
|
||||
|
||||
$responseMutated = json_decode($response, true);
|
||||
if (!$responseMutated) {
|
||||
$response = json_encode(array('error' => 'Invalid response from '.$urlbase), JSON_PRETTY_PRINT);
|
||||
$responseMutated = json_decode($response, true);
|
||||
}
|
||||
|
||||
// add params that were used for debugging
|
||||
$responseMutated['params'] = $params;
|
||||
|
||||
// store locally for UPC to access
|
||||
$this->writeJsonFile(self::JSON_FILE_RESULT, $responseMutated);
|
||||
|
||||
// if we have a query param of json=true then just output the json
|
||||
if (array_key_exists('json',$_GET) && $_GET['json']) {
|
||||
header('Content-Type: application/json');
|
||||
echo $response;
|
||||
exit(0);
|
||||
}
|
||||
|
||||
// send notification if a newer version is available and not ignored
|
||||
$isNewerVersion = array_key_exists('isNewer',$responseMutated) ? $responseMutated['isNewer'] : false;
|
||||
$isReleaseIgnored = in_array($responseMutated['version'], $this->getIgnoredReleases());
|
||||
|
||||
if ($responseMutated && $isNewerVersion && !$isReleaseIgnored) {
|
||||
$output = _var($notify,'plugin');
|
||||
$server = strtoupper(_var($var,'NAME','server'));
|
||||
$newver = (array_key_exists('version',$responseMutated) && $responseMutated['version']) ? $responseMutated['version'] : 'unknown';
|
||||
$script = '/usr/local/emhttp/webGui/scripts/notify';
|
||||
exec("$script -e ".escapeshellarg("System - Unraid [$newver]")." -s ".escapeshellarg("Notice [$server] - Version update $newver")." -d ".escapeshellarg("A new version of Unraid is available")." -i ".escapeshellarg("normal $output")." -l '/Tools/Update' -x");
|
||||
}
|
||||
|
||||
exit(0);
|
||||
}
|
||||
|
||||
private function removeAllIgnored()
|
||||
{
|
||||
if (file_exists(self::JSON_FILE_IGNORED)) {
|
||||
$this->deleteJsonFile(self::JSON_FILE_IGNORED);
|
||||
$this->respondWithSuccess([]);
|
||||
}
|
||||
// fail silently if file doesn't exist
|
||||
}
|
||||
|
||||
private function removeIgnoredVersion($removeVersion)
|
||||
{
|
||||
if ($this->isValidSemVerFormat($removeVersion)) {
|
||||
if (file_exists(self::JSON_FILE_IGNORED)) {
|
||||
$existingData = $this->readJsonFile(self::JSON_FILE_IGNORED);
|
||||
|
||||
if (isset($existingData[self::JSON_FILE_IGNORED_KEY])) {
|
||||
$existingData[self::JSON_FILE_IGNORED_KEY] = array_diff($existingData[self::JSON_FILE_IGNORED_KEY], [$removeVersion]);
|
||||
$this->writeJsonFile(self::JSON_FILE_IGNORED, $existingData);
|
||||
$this->respondWithSuccess($existingData);
|
||||
} else {
|
||||
$this->respondWithError(400, "No versions to remove in the JSON file");
|
||||
}
|
||||
} else {
|
||||
$this->respondWithError(400, "No JSON file found");
|
||||
}
|
||||
} else {
|
||||
$this->respondWithError(400, "Invalid removeVersion format");
|
||||
}
|
||||
}
|
||||
|
||||
private function ignoreVersion($version)
|
||||
{
|
||||
if ($this->isValidSemVerFormat($version)) {
|
||||
$newData = [$this::JSON_FILE_IGNORED_KEY => [$version]];
|
||||
$existingData = file_exists(self::JSON_FILE_IGNORED) ? $this->readJsonFile(self::JSON_FILE_IGNORED) : [];
|
||||
|
||||
if (isset($existingData[self::JSON_FILE_IGNORED_KEY])) {
|
||||
$existingData[self::JSON_FILE_IGNORED_KEY][] = $version;
|
||||
} else {
|
||||
$existingData[self::JSON_FILE_IGNORED_KEY] = [$version];
|
||||
}
|
||||
|
||||
$this->writeJsonFile(self::JSON_FILE_IGNORED, $existingData);
|
||||
$this->respondWithSuccess($existingData);
|
||||
} else {
|
||||
$this->respondWithError(400, "Invalid version format");
|
||||
}
|
||||
}
|
||||
|
||||
private function isValidSemVerFormat($version)
|
||||
{
|
||||
return preg_match('/^\d+\.\d+(\.\d+)?(-.+)?$/', $version);
|
||||
}
|
||||
|
||||
private function readJsonFile($file)
|
||||
{
|
||||
return @json_decode(@file_get_contents($file), true) ?? [];
|
||||
}
|
||||
|
||||
private function writeJsonFile($file, $data)
|
||||
{
|
||||
if (!is_dir(dirname($file))) { // prevents errors when directory doesn't exist
|
||||
mkdir(dirname($file));
|
||||
}
|
||||
file_put_contents($file, json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
|
||||
}
|
||||
|
||||
private function deleteJsonFile($file)
|
||||
{
|
||||
unlink($file);
|
||||
}
|
||||
|
||||
private function respondWithError($statusCode, $message)
|
||||
{
|
||||
http_response_code($statusCode);
|
||||
echo $message;
|
||||
}
|
||||
|
||||
private function respondWithSuccess($data)
|
||||
{
|
||||
http_response_code(200);
|
||||
header('Content-Type: application/json');
|
||||
echo json_encode($data, JSON_PRETTY_PRINT);
|
||||
}
|
||||
}
|
||||
|
||||
// Instantiate and handle the request for GET requests with actions – vars are duplicated here for multi-use of this file
|
||||
$isGetRequest = !empty($_SERVER) && isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] === 'GET';
|
||||
$getHasAction = $_GET !== null && !empty($_GET) && isset($_GET['action']);
|
||||
if ($isGetRequest && $getHasAction) {
|
||||
new UnraidOsCheck();
|
||||
}
|
||||
@@ -6,6 +6,9 @@
|
||||
// Program updates made by Bergware International (April 2020)
|
||||
// Program updates made by Bergware International (June 2022)
|
||||
|
||||
$docroot ??= ($_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp');
|
||||
require_once "$docroot/webGui/include/Wrappers.php";
|
||||
|
||||
$usage = <<<EOF
|
||||
Process language files.
|
||||
|
||||
@@ -148,12 +151,6 @@ function download($url, $name, &$error) {
|
||||
}
|
||||
}
|
||||
|
||||
// Deal with logging message.
|
||||
//
|
||||
function logger($message) {
|
||||
exec("logger -t 'language-manager' -- \"$message\"");
|
||||
}
|
||||
|
||||
// Interpret a language file
|
||||
// Returns TRUE if success, else FALSE and fills in error string.
|
||||
//
|
||||
@@ -314,7 +311,7 @@ if ($method == 'install') {
|
||||
copy($xml_file, $lang_file);
|
||||
symlink($lang_file, $link_file);
|
||||
write("language: $lang language pack installed\n");
|
||||
logger("$lang language pack installed");
|
||||
my_logger('language-manager',"$lang language pack installed");
|
||||
// run hook scripts for post processing
|
||||
post_hooks();
|
||||
done(0);
|
||||
@@ -396,7 +393,7 @@ if ($method == 'update') {
|
||||
copy($xml_file, $lang_file);
|
||||
symlink($lang_file, $link_file);
|
||||
write("language: $lang language pack updated\n");
|
||||
logger("$lang language pack updated");
|
||||
my_logger('language-manager',"$lang language pack updated");
|
||||
// run hook scripts for post processing
|
||||
post_hooks();
|
||||
done(0);
|
||||
@@ -423,7 +420,7 @@ if ($method == 'remove') {
|
||||
done(1);
|
||||
}
|
||||
write("language: $lang language pack removed\n");
|
||||
logger("$lang language pack removed");
|
||||
my_logger('language-manager',"$lang language pack removed");
|
||||
// run hook scripts for post processing
|
||||
post_hooks();
|
||||
done(0);
|
||||
|
||||
@@ -284,7 +284,7 @@ function filter_url($url) {
|
||||
// Deal with logging message.
|
||||
//
|
||||
function logger($message) {
|
||||
exec("logger -t 'plugin-manager' -- \"$message\"");
|
||||
exec("logger -t 'plugin-manager' -- ".escapeshellarg($message));
|
||||
}
|
||||
|
||||
// Interpret a plugin file
|
||||
@@ -691,7 +691,7 @@ if ($method == 'install') {
|
||||
$event = "Install error";
|
||||
$subject = "plugin: ".basename($plugin_file);
|
||||
$description = "Plugin failed to install";
|
||||
exec("$notify -e $event -s $subject -d $description) -i 2");
|
||||
exec("$notify -e ".escapeshellarg($event)." -s ".escapeshellarg($subject)." -d ".escapeshellarg($description)." -i 'warning'");
|
||||
// run hook scripts for post processing
|
||||
post_hooks($error);
|
||||
done(1);
|
||||
|
||||
@@ -13,60 +13,7 @@
|
||||
?>
|
||||
<?
|
||||
$docroot ??= ($_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp');
|
||||
require_once "$docroot/webGui/include/Wrappers.php";
|
||||
require_once "$docroot/plugins/dynamix.plugin.manager/include/PluginHelpers.php";
|
||||
require_once "$docroot/plugins/dynamix.plugin.manager/include/UnraidCheck.php";
|
||||
|
||||
// Multi-language support
|
||||
if (!function_exists('_')) {
|
||||
function _($text) {return $text;}
|
||||
}
|
||||
|
||||
extract(parse_plugin_cfg('dynamix', true));
|
||||
|
||||
$var = (array)@parse_ini_file('/var/local/emhttp/var.ini');
|
||||
$script = "$docroot/webGui/scripts/notify";
|
||||
$server = strtoupper(_var($var,'NAME','server'));
|
||||
$output = _var($notify,'plugin');
|
||||
$plg = '/var/log/plugins/unRAIDServer.plg';
|
||||
|
||||
$params = [];
|
||||
$params['branch'] = plugin('category', $plg, 'stable');
|
||||
$params['current_version'] = plugin('version', $plg) ?: _var($var,'version');
|
||||
if (_var($var,'regExp')) $params['update_exp'] = date('m-d-Y', _var($var,'regExp')*1);
|
||||
$urlbase = 'https://releases.unraid.net/os';
|
||||
$url = $urlbase.'?'.http_build_query($params);
|
||||
|
||||
$response = "";
|
||||
// use error handler to convert warnings from file_get_contents to errors so they can be captured
|
||||
function warning_as_error($severity, $message, $filename, $lineno) {
|
||||
throw new ErrorException($message, 0, $severity, $filename, $lineno);
|
||||
}
|
||||
set_error_handler("warning_as_error");
|
||||
try {
|
||||
$response = file_get_contents($url);
|
||||
} catch (Exception $e) {
|
||||
$response = json_encode(array('error' => $e->getMessage()), JSON_PRETTY_PRINT);
|
||||
}
|
||||
restore_error_handler();
|
||||
|
||||
$json = json_decode($response, true);
|
||||
if (!$json) {
|
||||
$response = json_encode(array('error' => 'Invalid response from '.$urlbase), JSON_PRETTY_PRINT);
|
||||
$json = json_decode($response, true);
|
||||
}
|
||||
|
||||
// add params that were sent to $urlbase
|
||||
$json['params'] = $params;
|
||||
|
||||
// store locally for UPC to access
|
||||
$file = '/tmp/unraidcheck/result.json';
|
||||
if (!is_dir(dirname($file))) mkdir(dirname($file));
|
||||
file_put_contents($file, json_encode($json, JSON_PRETTY_PRINT));
|
||||
|
||||
// send notification if a newer version is available
|
||||
if ($json && array_key_exists('isNewer',$json) && $json['isNewer']) {
|
||||
$newver = (array_key_exists('version',$json) && $json['version']) ? $json['version'] : 'unknown';
|
||||
exec("$script -e ".escapeshellarg("System - Unraid [$newver]")." -s ".escapeshellarg("Notice [$server] - Version update $newver")." -d ".escapeshellarg("A new version of Unraid is available")." -i ".escapeshellarg("normal $output")." -l '/Tools/Update' -x");
|
||||
}
|
||||
exit(0);
|
||||
?>
|
||||
$unraidOsCheck = new UnraidOsCheck();
|
||||
$unraidOsCheck->checkForUpdate();
|
||||
|
||||
@@ -261,6 +261,9 @@
|
||||
if (!empty($disk['boot'])) {
|
||||
$arrReturn['boot'] = $disk['boot'];
|
||||
}
|
||||
if (!empty($disk['rotation'])) {
|
||||
$arrReturn['rotation'] = $disk['rotation'];
|
||||
}
|
||||
if (!empty($disk['serial'])) {
|
||||
$arrReturn['serial'] = $disk['serial'];
|
||||
}
|
||||
@@ -687,13 +690,18 @@
|
||||
|
||||
if ($disk["serial"] != "") $serial = "<serial>".$disk["serial"]."</serial>" ; else $serial = "" ;
|
||||
|
||||
$rotation_rate = "";
|
||||
if ($disk['bus'] == "scsi" || $disk['bus'] == "sata" || $disk['bus'] == "ide" ) {
|
||||
if ($disk['rotation']) $rotation_rate = " rotation_rate='1' ";
|
||||
}
|
||||
|
||||
if ($strDevType == 'file' || $strDevType == 'block') {
|
||||
$strSourceType = ($strDevType == 'file' ? 'file' : 'dev');
|
||||
|
||||
$diskstr .= "<disk type='" . $strDevType . "' device='disk'>
|
||||
<driver name='qemu' type='" . $disk['driver'] . "' cache='writeback'/>
|
||||
<source " . $strSourceType . "='" . htmlspecialchars($disk['image'], ENT_QUOTES | ENT_XML1) . "'/>
|
||||
<target bus='" . $disk['bus'] . "' dev='" . $disk['dev'] . "'/>
|
||||
<target bus='" . $disk['bus'] . "' dev='" . $disk['dev'] . "' $rotation_rate />
|
||||
$bootorder
|
||||
$readonly
|
||||
$serial
|
||||
@@ -1307,6 +1315,7 @@
|
||||
if ($tmp) {
|
||||
$tmp['bus'] = $disk->target->attributes()->bus->__toString();
|
||||
$tmp["boot order"] = $disk->boot->attributes()->order ?? "";
|
||||
$tmp["rotation"] = $disk->target->attributes()->rotation_rate ?? "0";
|
||||
$tmp['serial'] = $disk->serial ;
|
||||
|
||||
// Libvirt reports 0 bytes for raw disk images that haven't been
|
||||
@@ -1335,6 +1344,7 @@
|
||||
'physical' => '-',
|
||||
'bus' => $disk->target->attributes()->bus->__toString(),
|
||||
'boot order' => $disk->boot->attributes()->order ,
|
||||
'rotation' => $disk->target->attributes()->rotation_rate ?? "0",
|
||||
'serial' => $disk->serial
|
||||
];
|
||||
}
|
||||
@@ -2365,6 +2375,7 @@
|
||||
foreach ($objNodes as $objNode) {
|
||||
$dom = $xpath->query('source/address/@domain', $objNode)->Item(0)->nodeValue;
|
||||
$bus = $xpath->query('source/address/@bus', $objNode)->Item(0)->nodeValue;
|
||||
$rotation = $xpath->query('target/address/@rotation_rate', $objNode)->Item(0)->nodeValue;
|
||||
$slot = $xpath->query('source/address/@slot', $objNode)->Item(0)->nodeValue;
|
||||
$func = $xpath->query('source/address/@function', $objNode)->Item(0)->nodeValue;
|
||||
$rom = $xpath->query('rom/@file', $objNode);
|
||||
@@ -2388,6 +2399,7 @@
|
||||
'product' => $tmp2['product_name'],
|
||||
'product_id' => $tmp2['product_id'],
|
||||
'boot' => $boot,
|
||||
'rotation' => $rotation,
|
||||
'rom' => $rom,
|
||||
'guest' => $guest
|
||||
];
|
||||
|
||||
@@ -1289,6 +1289,7 @@ private static $encoding = 'UTF-8';
|
||||
'dev' => $disk['device'],
|
||||
'bus' => $disk['bus'],
|
||||
'boot' => $disk['boot order'],
|
||||
'rotation' => $disk['rotation'],
|
||||
'serial' => $disk['serial'],
|
||||
'select' => $default_option
|
||||
];
|
||||
@@ -1300,7 +1301,8 @@ private static $encoding = 'UTF-8';
|
||||
'driver' => 'raw',
|
||||
'dev' => 'hda',
|
||||
'select' => '',
|
||||
'bus' => 'virtio'
|
||||
'bus' => 'virtio',
|
||||
'rotation' => "0"
|
||||
];
|
||||
}
|
||||
|
||||
@@ -2521,11 +2523,7 @@ function addtemplatexml($post) {
|
||||
'overrides' => $usertemplate
|
||||
];
|
||||
file_put_contents($templateslocation,json_encode($savedtemplates,JSON_PRETTY_PRINT));
|
||||
// Fire off the vnc/spice popup if available
|
||||
$reply = ['success' => true];
|
||||
|
||||
#} else {
|
||||
# $reply = ['error' => $lv->get_last_error()];
|
||||
$reply = ['success' => true];
|
||||
|
||||
return $reply;
|
||||
}
|
||||
|
||||
@@ -303,7 +303,6 @@
|
||||
}
|
||||
|
||||
if (strpos($arrConfig['template']['name'],"User-") !== false) $arrConfig['template']['name'] = str_replace("User-","",$arrConfig['template']['name']);
|
||||
#var_dump($arrConfig);
|
||||
?>
|
||||
|
||||
<link rel="stylesheet" href="<?autov('/plugins/dynamix.vm.manager/scripts/codemirror/lib/codemirror.css')?>">
|
||||
@@ -805,11 +804,14 @@
|
||||
<tr class="advanced disk_bus_options">
|
||||
<td>_(vDisk Bus)_:</td>
|
||||
<td>
|
||||
<select name="disk[<?=$i?>][bus]" class="disk_bus narrow">
|
||||
<select name="disk[<?=$i?>][bus]" class="disk_bus narrow" onchange="BusChange(this)">
|
||||
<?mk_dropdown_options($arrValidDiskBuses, $arrDisk['bus']);?>
|
||||
</select>
|
||||
_(Boot Order)_:
|
||||
<input type="number" size="5" maxlength="5" id="disk[<?=$i?>][boot]" class="narrow bootorder" style="width: 50px;" name="disk[<?=$i?>][boot]" title="_(Boot order)_" value="<?=$arrDisk['boot']?>" >
|
||||
<? if ($arrDisk['bus'] == "virtio" || $arrDisk['bus'] == "usb") $ssddisabled = "hidden "; else $ssddisabled = " ";?>
|
||||
<span id="disk[<?=$i?>][rotatetext]" <?=$ssddisabled?>>_(SSD)_:</span>
|
||||
<input type="checkbox" id="disk[<?=$i?>][rotation]" class="narrow rotation" onchange="updateSSDCheck(this)"style="width: 50px;" name="disk[<?=$i?>][rotation]" <?=$ssddisabled ?> <?=$arrDisk['rotation'] ? "checked ":"";?> title="_(Set SDD flag)_" value="<?=$arrDisk['rotation']?>" >
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="advanced disk_bus_options">
|
||||
@@ -857,6 +859,11 @@
|
||||
Specify the order the devices are used for booting.
|
||||
</p>
|
||||
|
||||
<p class="advanced">
|
||||
<b>vDisk SSD Flag</b><br>
|
||||
Specify the vdisk shows as SSD within the guest, only supported on SCSI, SATA and IDE bus types.
|
||||
</p>
|
||||
|
||||
<p class="advanced">
|
||||
<b>vDisk Serial</b><br>
|
||||
Set the device serial number presented to the VM.
|
||||
@@ -949,12 +956,14 @@
|
||||
<tr class="advanced disk_bus_options">
|
||||
<td>_(vDisk Bus)_:</td>
|
||||
<td>
|
||||
<select name="disk[{{INDEX}}][bus]" class="disk_bus narrow">
|
||||
<select name="disk[{{INDEX}}][bus]" class="disk_bus narrow" onchange="BusChange(this)">
|
||||
<?mk_dropdown_options($arrValidDiskBuses, '');?>
|
||||
</select>
|
||||
|
||||
_(Boot Order)_:
|
||||
<input type="number" size="5" maxlength="5" id="disk[{{INDEX}}][boot]" class="narrow bootorder" style="width: 50px;" name="disk[{{INDEX}}][boot]" title="_(Boot order)_" value="" >
|
||||
<span id="disk[{{INDEX}}][rotatetext]" hidden>_(SSD)_:</span>
|
||||
<input type="checkbox" id="disk[{{INDEX}}][rotation]" class="narrow rotation" onchange="updateSSDCheck(this)"style="width: 50px;" name="disk[{{INDEX}}[rotation]" hidden title="_(Set SSD flag)_" value='0' >
|
||||
</td>
|
||||
<tr class="advanced disk_bus_options">
|
||||
<td>_(Serial)_:</td>
|
||||
@@ -1700,6 +1709,28 @@ function ShareChange(share) {
|
||||
}
|
||||
}
|
||||
|
||||
function BusChange(bus) {
|
||||
var value = bus.value;
|
||||
var index = bus.name.indexOf("]") + 1;
|
||||
var name = bus.name.substr(0,index) ;
|
||||
if (value == "virtio" || value == "usb" ) {
|
||||
document.getElementById(name+"[rotatetext]").style.visibility="hidden";
|
||||
document.getElementById(name+"[rotation]").style.visibility="hidden";
|
||||
} else {
|
||||
document.getElementById(name+"[rotation]").style.display="inline";
|
||||
document.getElementById(name+"[rotation]").style.visibility="visible";
|
||||
document.getElementById(name+"[rotatetext]").style.display="inline";
|
||||
document.getElementById(name+"[rotatetext]").style.visibility="visible";
|
||||
}
|
||||
}
|
||||
|
||||
function updateSSDCheck(ssd) {
|
||||
var value = ssd.value;
|
||||
var index = ssd.name.indexOf("]") + 1;
|
||||
var name = ssd.name.substr(0,index) ;
|
||||
if (document.getElementById(name+"[rotation]").checked) ssd.value = "1"; else ssd.value = "0";
|
||||
}
|
||||
|
||||
function BIOSChange(bios) {
|
||||
var value = bios.value;
|
||||
if (value == "0") {
|
||||
|
||||
@@ -225,7 +225,6 @@ function readSMB() {
|
||||
$.get('/webGui/include/ProtocolData.php',{protocol:'smb',name:name},function(json) {
|
||||
var data = $.parseJSON(json);
|
||||
form.shareExport.value = data.export;
|
||||
form.shareFruit.value = data.fruit;
|
||||
form.shareSecurity.value = data.security;
|
||||
});
|
||||
$(form).find('select').trigger('change');
|
||||
@@ -245,7 +244,6 @@ function writeSMB(data,n,i) {
|
||||
data[i] = {};
|
||||
data[i]['shareName'] = $(this).val();
|
||||
data[i]['shareExport'] = '<?=addslashes(htmlspecialchars($sec[$name]['export']))?>';
|
||||
data[i]['shareFruit'] = '<?=addslashes(htmlspecialchars($sec[$name]['fruit']))?>';
|
||||
data[i]['shareSecurity'] = '<?=addslashes(htmlspecialchars($sec[$name]['security']))?>';
|
||||
data[i]['changeShareSecurity'] = 'Apply';
|
||||
i++;
|
||||
|
||||
@@ -27,7 +27,7 @@ if (count($_POST)) {
|
||||
foreach($update_file as $type => $types) {
|
||||
foreach($types as $name => $details) {
|
||||
if ($details['user_mac'] == "") $details['user_mac'] = "None Defined";
|
||||
if ($details['user_mac'] == "None Defined" && $details['enable'] == "enable") unset($update_file[$type][$name]) ;
|
||||
if ($details['user_mac'] == "None Defined" && ($details['enable'] == "enable" || $details['enable'] == "shutdown")) unset($update_file[$type][$name]) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -99,11 +99,11 @@ function showWOLupdate() {
|
||||
|
||||
function maccreate(name) {
|
||||
|
||||
$.getJSON("/plugins/dynamix.vm.manager/include/VMajax.php?action=generate-mac", function( data ) {
|
||||
$.post('/webGui/include/WOL.php',{table:'macaddress'}, function( data ) {
|
||||
if (data.mac) {
|
||||
$('#'+name).val(data.mac);
|
||||
}
|
||||
});
|
||||
},'json');
|
||||
}
|
||||
|
||||
showWOL("all",true);
|
||||
|
||||
@@ -65,6 +65,14 @@ _(Enable VM actions)_:
|
||||
|
||||
:WOL_run_VM_help:
|
||||
|
||||
_(Enable Shutdown actions)_:
|
||||
: <select name="RUNSHUT" >
|
||||
<?=mk_option($current['RUNSHUT'], "n", _('No'))?>
|
||||
<?=mk_option($current['RUNSHUT'], "y", _('Yes'))?>
|
||||
</select>
|
||||
|
||||
:WOL_run_shutdown_help:
|
||||
|
||||
_(Interface to listern on)_:
|
||||
: <select id="INTERFACE" name="INTERFACE" >
|
||||
<?=mk_option(_var($eth0,'INTERFACE'),'eth0','eth0','selected')?>
|
||||
|
||||
@@ -9,8 +9,8 @@ if (!empty($_COOKIE['unraid_'.md5($server_name)])) {
|
||||
|
||||
// Check if the user is already logged in
|
||||
if ($_SESSION && !empty($_SESSION['unraid_user'])) {
|
||||
// If so redirect them to the start page
|
||||
header("Location: /".$var['START_PAGE']);
|
||||
// Redirect the user to the start page
|
||||
header("Location: /".$start_page);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
@@ -119,12 +119,12 @@ function verifyTwoFactorToken(string $username, string $token): bool {
|
||||
// This should accept 200 or 204 status codes
|
||||
if ($httpCode !== 200 && $httpCode !== 204) {
|
||||
// Log error to syslog
|
||||
exec("logger -t webGUI -- \"2FA code for {$username} is invalid, blocking access!\"");
|
||||
my_logger("2FA code for {$username} is invalid, blocking access!");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Log success to syslog
|
||||
exec("logger -t webGUI -- \"2FA code for {$username} is valid, allowing login!\"");
|
||||
my_logger("2FA code for {$username} is valid, allowing login!");
|
||||
|
||||
// Success
|
||||
return true;
|
||||
@@ -199,7 +199,7 @@ if (!empty($username) && !empty($password)) {
|
||||
|
||||
// Check if we're limited
|
||||
if ($failCount >= $maxFails) {
|
||||
if ($failCount == $maxFails) exec("logger -t webGUI -- \"Ignoring login attempts for {$username} from {$remote_addr}\"");
|
||||
if ($failCount == $maxFails) my_logger("Ignoring login attempts for {$username} from {$remote_addr}");
|
||||
throw new Exception(_('Too many invalid login attempts'));
|
||||
}
|
||||
|
||||
@@ -216,17 +216,17 @@ if (!empty($username) && !empty($password)) {
|
||||
$_SESSION['unraid_user'] = $username;
|
||||
session_regenerate_id(true);
|
||||
session_write_close();
|
||||
exec("logger -t webGUI -- \"Successful login user {$username} from {$remote_addr}\"");
|
||||
my_logger("Successful login user {$username} from {$remote_addr}");
|
||||
|
||||
// Redirect the user to the start page
|
||||
header("Location: /".$var['START_PAGE']);
|
||||
header("Location: /".$start_page);
|
||||
exit;
|
||||
} catch (Exception $exception) {
|
||||
// Set error message
|
||||
$error = $exception->getMessage();
|
||||
|
||||
// Log error to syslog
|
||||
exec("logger -t webGUI -- \"Unsuccessful login user {$username} from {$remote_addr}\"");
|
||||
my_logger("Unsuccessful login user {$username} from {$remote_addr}");
|
||||
appendToFile($failFile, $time."\n");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,12 +30,13 @@ if (!empty($_POST['password']) && !empty($_POST['confirmPassword'])) {
|
||||
session_regenerate_id(true);
|
||||
session_write_close();
|
||||
|
||||
header("Location: /".$var['START_PAGE']);
|
||||
// Redirect the user to the start page
|
||||
header("Location: /".$start_page);
|
||||
exit;
|
||||
}
|
||||
|
||||
// Error when attempting to set password
|
||||
exec("logger -t webGUI -- \"{$VALIDATION_MESSAGES['saveError']} [REMOTE_ADDR]: {$REMOTE_ADDR}\"");
|
||||
my_logger("{$VALIDATION_MESSAGES['saveError']} [REMOTE_ADDR]: {$REMOTE_ADDR}");
|
||||
return $POST_ERROR = $VALIDATION_MESSAGES['saveError'];
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
?>
|
||||
<?
|
||||
require_once "$docroot/webGui/include/MarkdownExtra.inc.php";
|
||||
require_once "$docroot/webGui/include/Wrappers.php";
|
||||
|
||||
function get_ini_key($key,$default) {
|
||||
$x = strpos($key, '[');
|
||||
@@ -32,7 +33,7 @@ function build_pages($pattern) {
|
||||
foreach (glob($pattern,GLOB_NOSORT) as $entry) {
|
||||
[$header, $content] = my_explode("\n---\n",file_get_contents($entry));
|
||||
$page = @parse_ini_string($header);
|
||||
if (!$page) {exec("logger -t webGUI -- \"Invalid .page format: $entry\""); continue;}
|
||||
if (!$page) {my_logger("Invalid .page format: $entry"); continue;}
|
||||
$page['file'] = $entry;
|
||||
$page['root'] = dirname($entry);
|
||||
$page['name'] = basename($entry, '.page');
|
||||
|
||||
@@ -3,10 +3,11 @@
|
||||
function SysDriverslog($m, $type='NOTICE') {
|
||||
if ($type == 'DEBUG') return;
|
||||
$m = str_replace(["\n",'"'],[" ","'"],print_r($m,true));
|
||||
exec("logger -t sysDrivers -- \"$m\"");
|
||||
my_logger('sysDrivers', "$m");
|
||||
}
|
||||
|
||||
$docroot ??= ($_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp');
|
||||
require_once "$docroot/webGui/include/Wrappers.php";
|
||||
require_once "$docroot/webGui/include/Helpers.php";
|
||||
require_once "$docroot/webGui/include/SysDriversHelpers.php";
|
||||
require_once "$docroot/plugins/dynamix.plugin.manager/include/PluginHelpers.php";
|
||||
|
||||
@@ -22,6 +22,14 @@ $_SERVER['REQUEST_URI'] = 'tools';
|
||||
require_once "$docroot/webGui/include/Translations.php";
|
||||
require_once "$docroot/plugins/dynamix.docker.manager/include/DockerClient.php";
|
||||
require_once "$docroot/plugins/dynamix.vm.manager/include/libvirt.php";
|
||||
|
||||
function macbyte($val) {
|
||||
if ($val < 16)
|
||||
return '0'.dechex($val);
|
||||
|
||||
return dechex($val);
|
||||
}
|
||||
|
||||
$arrEntries = [];
|
||||
$vms = $lv->get_domains() ?:[];
|
||||
sort($vms,SORT_NATURAL);
|
||||
@@ -54,8 +62,7 @@ foreach($arrEntries as $key => $data) {
|
||||
foreach($data as $data2){
|
||||
$name=$data2['name'];
|
||||
if (isset($user_mac[$type][$name])) {
|
||||
$name=$name;
|
||||
#var_dump($name);
|
||||
$name=$name;
|
||||
$arrEntries[$type][$name]['enable'] = $user_mac[$type][$name]['enable'];
|
||||
$arrEntries[$type][$name]['user_mac'] = strtolower($user_mac[$type][$name]['user_mac']);
|
||||
} else {
|
||||
@@ -91,6 +98,7 @@ case 't1load':
|
||||
$html .="<select name='$selecttypename' class='audio narrow'>";
|
||||
$html .= mk_option($macaddr["enable"] , "disable", _("Disabled"));
|
||||
$html .= mk_option($macaddr["enable"] , "enable", _("Enabled"));
|
||||
$html .= mk_option($macaddr["enable"] , "shutdown", _("Enabled and Shutdown"));
|
||||
$html .= "</select></td><td>".$user_mac_str."</td></tr>";
|
||||
$text = "";
|
||||
}
|
||||
@@ -108,8 +116,8 @@ case 't1load':
|
||||
|
||||
case "macaddress":
|
||||
$seed = 1;
|
||||
$prefix = '52:54:AA';
|
||||
$prefix.':'.$lv->macbyte(($seed * rand()) % 256).':'.$lv->macbyte(($seed * rand()) % 256).':'.$lv->macbyte(($seed * rand()) % 256);
|
||||
$prefix = '62:00:00';
|
||||
$prefix .=':'.macbyte(($seed * rand()) % 256).':'.macbyte(($seed * rand()) % 256).':'.macbyte(($seed * rand()) % 256);
|
||||
echo json_encode(['mac' => $prefix]);
|
||||
break;
|
||||
|
||||
|
||||
9
emhttp/plugins/dynamix/include/WOLrun.php
Executable file → Normal file
9
emhttp/plugins/dynamix/include/WOLrun.php
Executable file → Normal file
@@ -28,6 +28,7 @@ extract(parse_ini_file("/boot/config/wol.cfg")) ;
|
||||
if (!isset($RUNLXC)) $RUNLXC = "y";
|
||||
if (!isset($RUNVM)) $RUNVM = "y";
|
||||
if (!isset($RUNDocker)) $RUNDocker = "y";
|
||||
if (!isset($RUNSHUT)) $RUNSHUT = "n";
|
||||
|
||||
$arrEntries = [] ;
|
||||
if ($libvirtd_running && $RUNVM == "y") {
|
||||
@@ -117,7 +118,7 @@ foreach($arrEntries as $type => $detail)
|
||||
$found = array_key_exists($mac,$mac_list);
|
||||
|
||||
|
||||
if ($found && $mac_list[$mac]['enable'] == "enable") {
|
||||
if ($found && $mac_list[$mac]['enable'] != "disable") {
|
||||
echo _("Found"). " " . $mac . " " .$mac_list[$mac]['type'] . " " . $mac_list[$mac]['name'];
|
||||
switch ($mac_list[$mac]['type']) {
|
||||
|
||||
@@ -128,6 +129,7 @@ if ($found && $mac_list[$mac]['enable'] == "enable") {
|
||||
$state = $lv->domain_state_translate($dom['state']);
|
||||
switch ($state) {
|
||||
case 'running':
|
||||
if ($RUNSHUT == "y" && $mac_list[$mac]['enable'] == "shutdown") $lv->domain_shutdown("{$mac_list[$mac]['name']}");
|
||||
break;
|
||||
case 'paused':
|
||||
case 'pmsuspended':
|
||||
@@ -143,6 +145,7 @@ if ($found && $mac_list[$mac]['enable'] == "enable") {
|
||||
$state = getContainerStats($mac_list[$mac]['name'], "State");
|
||||
switch ($state) {
|
||||
case 'RUNNING':
|
||||
if ($RUNSHUT == "y" && $mac_list[$mac]['enable'] == "shutdown") shell_exec("lxc-stop {$mac_list[$mac]['name']}");
|
||||
break;
|
||||
case 'FROZEN':
|
||||
shell_exec("lxc-unfreeze {$mac_list[$mac]['name']}");
|
||||
@@ -156,7 +159,9 @@ if ($found && $mac_list[$mac]['enable'] == "enable") {
|
||||
if ($dockerd_running && $RUNDOCKER == "y") {
|
||||
|
||||
switch ($mac_list[$mac]['state']) {
|
||||
|
||||
case "running":
|
||||
if ($RUNSHUT == "y" && $mac_list[$mac]['enable'] == "shutdown") shell_exec("docker stop {$mac_list[$mac]['name']}");
|
||||
break;
|
||||
case "exited":
|
||||
case "created":
|
||||
shell_exec("docker start {$mac_list[$mac]['name']}");
|
||||
|
||||
@@ -145,4 +145,8 @@ function my_date($fmt, $time) {
|
||||
$legacy = ['%c' => 'D j M Y h:i A','%A' => 'l','%Y' => 'Y','%B' => 'F','%e' => 'j','%d' => 'd','%m' => 'm','%I' => 'h','%H' => 'H','%M' => 'i','%S' => 's','%p' => 'a','%R' => 'H:i', '%F' => 'Y-m-d', '%T' => 'H:i:s'];
|
||||
return date(strtr($fmt,$legacy), $time);
|
||||
}
|
||||
// ensure params passed to logger are properly escaped
|
||||
function my_logger($message, $tag="webgui") {
|
||||
exec('logger -t '.escapeshellarg($tag).' -- '.escapeshellarg($message));
|
||||
}
|
||||
?>
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
// auto_prepend_file="/usr/local/emhttp/webGui/include/local_prepend.php"
|
||||
|
||||
function csrf_terminate($reason) {
|
||||
exec("logger -t webGUI -- \"error: {$_SERVER['REQUEST_URI']} - {$reason} csrf_token\"");
|
||||
exec('logger -t webGUI -- '.escapeshellarg("error: {$_SERVER['REQUEST_URI']} - {$reason} csrf_token"));
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
@@ -11,13 +11,16 @@
|
||||
*/
|
||||
?>
|
||||
<?
|
||||
$docroot ??= ($_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp');
|
||||
require_once "$docroot/webGui/include/Wrappers.php";
|
||||
|
||||
function curl_socket($socket, $url, $message='') {
|
||||
$com = curl_init($url);
|
||||
curl_setopt_array($com, [CURLOPT_UNIX_SOCKET_PATH => $socket, CURLOPT_RETURNTRANSFER => 1]);
|
||||
if ($message) curl_setopt_array($com, [CURLOPT_POSTFIELDS => $message, CURLOPT_POST => 1]);
|
||||
$reply = curl_exec($com);
|
||||
curl_close($com);
|
||||
if ($reply===false) exec("logger -t curl_socket -- 'curl to $url failed'");
|
||||
if ($reply===false) my_logger("curl to $url failed", 'curl_socket');
|
||||
return $reply;
|
||||
}
|
||||
|
||||
@@ -32,7 +35,7 @@ function publish($endpoint, $message, $len=1) {
|
||||
]);
|
||||
$reply = curl_exec($com);
|
||||
curl_close($com);
|
||||
if ($reply===false) exec("logger -t publish -- 'curl to $endpoint failed'");
|
||||
if ($reply===false) my_logger("curl to $endpoint failed", 'publish');
|
||||
return $reply;
|
||||
}
|
||||
?>
|
||||
|
||||
@@ -12,6 +12,9 @@
|
||||
*/
|
||||
?>
|
||||
<?
|
||||
$docroot ??= ($_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp');
|
||||
require_once "$docroot/webGui/include/Wrappers.php";
|
||||
|
||||
$set = $ifname = $argv[1];
|
||||
$run = $set != 'none';
|
||||
$ini = parse_ini_file('/var/local/emhttp/network.ini',true); ksort($ini,SORT_NATURAL);
|
||||
@@ -25,7 +28,7 @@ function update_wireguard($ifname) {
|
||||
$vtun = basename($wg,'.conf');
|
||||
// interface has changed?
|
||||
if (exec("grep -Pom1 ' dev $nic ' $wg")=='') {
|
||||
exec("logger -t netconfig -- \"updated wireguard $vtun configuration\"");
|
||||
my_logger("updated wireguard $vtun configuration", 'netconfig');
|
||||
exec("sed -ri 's/ dev (br0|bond0|eth0) / dev $nic /' $wg");
|
||||
}
|
||||
// restart active wireguard tunnels
|
||||
|
||||
Reference in New Issue
Block a user