command line params for .sh or .bat file names

This commit is contained in:
Steffen Schröder 2014-08-25 17:35:10 +02:00
parent f13c9517d3
commit 7a87fa5aa6

View File

@ -128,12 +128,18 @@ class SystemUtil {
Logger::log("Can't restart ManiaControl because the function 'exec' is disabled!"); Logger::log("Can't restart ManiaControl because the function 'exec' is disabled!");
return; return;
} }
$fileName = MANIACONTROL_PATH . 'ManiaControl.sh'; $fileName = null;
if (!is_readable($fileName)) { if ($scriptName = CommandLineHelper::getParameter('-sh')) {
Logger::log("Can't restart ManiaControl because the file 'ManiaControl.sh' doesn't exist or isn't readable!"); $fileName = $scriptName;
} else {
$fileName = 'ManiaControl.sh';
}
$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!");
return; return;
} }
$command = 'sh ' . escapeshellarg($fileName) . ' > /dev/null &'; $command = 'sh ' . escapeshellarg($filePath) . ' > /dev/null &';
exec($command); exec($command);
} }
@ -165,7 +171,18 @@ class SystemUtil {
Logger::log("Can't restart ManiaControl because the function 'system' is disabled!"); Logger::log("Can't restart ManiaControl because the function 'system' is disabled!");
return; return;
} }
$command = escapeshellarg(MANIACONTROL_PATH . "ManiaControl.bat"); $fileName = null;
system($command); // TODO: windows gets stuck here as long controller is running if ($scriptName = CommandLineHelper::getParameter('-bat')) {
$fileName = $scriptName;
} else {
$fileName = 'ManiaControl.bat';
}
$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!");
return;
}
$command = escapeshellarg($filePath);
system($command); // TODO: windows stops here as long as controller is running
} }
} }