Disabled //restart , restored backwards compatibility for the backend on restart

This commit is contained in:
Alexander Nell 2020-04-26 09:47:33 +02:00
parent c04f39a056
commit 9dc455774f
4 changed files with 39 additions and 12 deletions

View File

@ -15,6 +15,8 @@ interface CommunicationMethods {
* - message
*/
const REBOOT_MANIA_CONTROL = "ManiaControl.Reboot";
/** @deprecated */
const RESTART_MANIA_CONTROL = "ManiaControl.Restart";
/** Update the ManiaControl Core */
const UPDATE_MANIA_CONTROL_CORE = "UpdateManager.CoreUpdate";

View File

@ -228,6 +228,7 @@ class ManiaControl implements CallbackListener, CommandListener, TimerListener,
// Commands
$this->getCommandManager()->registerCommandListener('version', $this, 'commandVersion', false, 'Shows ManiaControl version.');
$this->getCommandManager()->registerCommandListener('reboot', $this, 'commandReboot', true, 'Reboots ManiaControl.');
$this->getCommandManager()->registerCommandListener('restart', $this, 'commandRestart', true, 'Restarts ManiaControl.');
$this->getCommandManager()->registerCommandListener('shutdown', $this, 'commandShutdown', true, 'Shuts ManiaControl down.');
// Check connection every 30 seconds
@ -549,6 +550,30 @@ class ManiaControl implements CallbackListener, CommandListener, TimerListener,
$this->reboot("ManiaControl Reboot requested by '{$player->login}'!");
}
/**
* Handle Restart AdminCommand
*
* @param array $chatCallback
* @param Player $player
*/
public function commandRestart(array $chatCallback, Player $player) {
if (!$this->getAuthenticationManager()->checkPermission($player, self::SETTING_PERMISSION_REBOOT)) {
$this->getAuthenticationManager()->sendNotAllowed($player);
return;
}
$this->getChat->sendError('The command //restart got disabled, reboot ManiaControl with //reboot instead', $player);
}
/**
* @deprecated
* Restart ManiaControl
*
* @param string $message
*/
public function restart($message = null) {
$this->reboot($message);
}
/**
* Reboot ManiaControl
*

View File

@ -51,7 +51,7 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
// Admin commands
$this->maniaControl->getCommandManager()->registerCommandListener(array('nextmap', 'next', 'skip'), $this, 'command_NextMap', true, 'Skips to the next map.');
$this->maniaControl->getCommandManager()->registerCommandListener(array('restartmap', 'resmap', 'restart', 'res'), $this, 'command_RestartMap', true, 'Restarts the current map.');
$this->maniaControl->getCommandManager()->registerCommandListener(array('restartmap', 'resmap', 'res'), $this, 'command_RestartMap', true, 'Restarts the current map.');
$this->maniaControl->getCommandManager()->registerCommandListener(array('replaymap', 'replay'), $this, 'command_ReplayMap', true, 'Replays the current map (after the end of the map).');
$this->maniaControl->getCommandManager()->registerCommandListener(array('addmap', 'add'), $this, 'command_AddMap', true, 'Adds map from ManiaExchange.');
$this->maniaControl->getCommandManager()->registerCommandListener(array('removemap', 'removethis'), $this, 'command_RemoveMap', true, 'Removes the current map.');

View File

@ -134,13 +134,13 @@ class SystemUtil {
}
/**
* Restart ManiaControl immediately
* Reboot ManiaControl immediately
*/
public static function restart() {
public static function reboot() {
if (SystemUtil::isUnix()) {
self::restartUnix();
self::rebootUnix();
} else {
self::restartWindows();
self::rebootWindows();
}
}
@ -156,9 +156,9 @@ class SystemUtil {
/**
* Perform restart on Unix
*/
private static function restartUnix() {
private static function rebootUnix() {
if (!SystemUtil::checkFunctionAvailability('exec')) {
Logger::log("Can't restart ManiaControl because the function 'exec' is disabled!");
Logger::log("Can't reboot ManiaControl because the function 'exec' is disabled!");
return;
}
$fileName = null;
@ -169,7 +169,7 @@ class SystemUtil {
}
$filePath = MANIACONTROL_PATH . $fileName;
if (!is_readable($filePath)) {
Logger::log("Can't restart ManiaControl because the file '{$fileName}' doesn't exist or isn't readable!");
Logger::log("Can't reboot ManiaControl because the file '{$fileName}' doesn't exist or isn't readable!");
return;
}
$command = 'sh ' . escapeshellarg($filePath) . ' > /dev/null &';
@ -197,11 +197,11 @@ class SystemUtil {
}
/**
* Perform restart on Windows
* Perform reboot on Windows
*/
private static function restartWindows() {
private static function rebootWindows() {
if (!SystemUtil::checkFunctionAvailability('system')) {
Logger::log("Can't restart ManiaControl because the function 'system' is disabled!");
Logger::log("Can't reboot ManiaControl because the function 'system' is disabled!");
return;
}
$fileName = null;
@ -212,7 +212,7 @@ class SystemUtil {
}
$filePath = MANIACONTROL_PATH . $fileName;
if (!is_readable($filePath)) {
Logger::log("Can't restart ManiaControl because the file '{$fileName}' doesn't exist or isn't readable!");
Logger::log("Can't reboot ManiaControl because the file '{$fileName}' doesn't exist or isn't readable!");
return;
}
$command = escapeshellarg($filePath);