summaryrefslogtreecommitdiffstats
path: root/modules-available/rebootcontrol/pages/exec.inc.php
diff options
context:
space:
mode:
Diffstat (limited to 'modules-available/rebootcontrol/pages/exec.inc.php')
-rw-r--r--modules-available/rebootcontrol/pages/exec.inc.php31
1 files changed, 26 insertions, 5 deletions
diff --git a/modules-available/rebootcontrol/pages/exec.inc.php b/modules-available/rebootcontrol/pages/exec.inc.php
index 6b5ea407..422f88f8 100644
--- a/modules-available/rebootcontrol/pages/exec.inc.php
+++ b/modules-available/rebootcontrol/pages/exec.inc.php
@@ -15,11 +15,19 @@ class SubPage
{
$uuids = array_values(Request::post('uuid', Request::REQUIRED, 'array'));
$machines = RebootUtils::getFilteredMachineList($uuids, 'action.exec');
- if (empty($machines))
- return;
+ if (empty($machines)) {
+ ErrorHandler::traceError('No machines');
+ }
RebootUtils::sortRunningFirst($machines);
- $script = preg_replace('/\r\n?/', "\n", Request::post('script', Request::REQUIRED, 'string'));
- $task = RebootControl::runScript($machines, $script);
+ $preset = self::presetFromRequest();
+ if ($preset !== null) {
+ $script = $preset->buildFromPost();
+ }
+ if (empty($script)) {
+ $script = preg_replace('/\r\n?/', "\n",
+ Request::post('script', Request::REQUIRED, 'string'));
+ }
+ $task = RebootControl::runScript($machines, $script, 15);
if (Taskmanager::isTask($task)) {
Util::redirect("?do=rebootcontrol&show=task&what=task&taskid=" . $task["id"]);
}
@@ -46,7 +54,20 @@ class SubPage
return;
}
Session::set('exec-' . $id, false);
- Render::addTemplate('exec-enter-command', ['clients' => $machines, 'id' => $id]);
+ $preset = self::presetFromRequest();
+ Render::addTemplate('exec-enter-command', ['clients' => $machines, 'id' => $id, 'preset' => $preset]);
+ }
+
+ private static function presetFromRequest(): ?ExecTemplate
+ {
+ $presetId = Request::any('preset', null, 'string');
+ if ($presetId === null)
+ return null;
+ $preset = ExecTemplate::get($presetId);
+ if ($preset === null) {
+ Message::addError('exec-template-not-found', $presetId);
+ }
+ return $preset;
}
public static function doAjax()