Commit 39d08e57 authored by Franco Fichtner's avatar Franco Fichtner

services: refactor return values

Suggested by: @fabianfrz

(cherry picked from commit aa19f4b1)
parent 7d568ea2
...@@ -2927,8 +2927,6 @@ function is_radvd_enabled() { ...@@ -2927,8 +2927,6 @@ function is_radvd_enabled() {
function service_control_start($name, $extras) function service_control_start($name, $extras)
{ {
$msg = sprintf(gettext('%s has been started.'), htmlspecialchars($name));
if (!empty($extras['id'])) { if (!empty($extras['id'])) {
$filter['id'] = $extras['id']; $filter['id'] = $extras['id'];
} }
...@@ -2937,6 +2935,7 @@ function service_control_start($name, $extras) ...@@ -2937,6 +2935,7 @@ function service_control_start($name, $extras)
if (!isset($service['name'])) { if (!isset($service['name'])) {
return sprintf(gettext("Could not start unknown service `%s'"), htmlspecialchars($name)); return sprintf(gettext("Could not start unknown service `%s'"), htmlspecialchars($name));
} }
if (isset($service['configd']['start'])) { if (isset($service['configd']['start'])) {
foreach ($service['configd']['start'] as $cmd) { foreach ($service['configd']['start'] as $cmd) {
configd_run($cmd); configd_run($cmd);
...@@ -2956,15 +2955,14 @@ function service_control_start($name, $extras) ...@@ -2956,15 +2955,14 @@ function service_control_start($name, $extras)
mwexec($cmd); mwexec($cmd);
} }
} else { } else {
$msg = sprintf(gettext("Could not start service `%s'"), htmlspecialchars($name)); return sprintf(gettext("Could not start service `%s'"), htmlspecialchars($name));
} }
return $msg; return sprintf(gettext('%s has been started.'), htmlspecialchars($name));
} }
function service_control_stop($name, $extras) function service_control_stop($name, $extras)
{ {
$msg = sprintf(gettext("%s has been stopped."), htmlspecialchars($name));
$filter = array(); $filter = array();
if (!empty($extras['id'])) { if (!empty($extras['id'])) {
...@@ -2995,13 +2993,11 @@ function service_control_stop($name, $extras) ...@@ -2995,13 +2993,11 @@ function service_control_stop($name, $extras)
killbyname($service['name']); killbyname($service['name']);
} }
return $msg; return sprintf(gettext("%s has been stopped."), htmlspecialchars($name));
} }
function service_control_restart($name, $extras) function service_control_restart($name, $extras)
{ {
$msg = sprintf(gettext("%s has been restarted."), htmlspecialchars($name));
if (!empty($extras['id'])) { if (!empty($extras['id'])) {
$filter['id'] = $extras['id']; $filter['id'] = $extras['id'];
} }
...@@ -3030,8 +3026,8 @@ function service_control_restart($name, $extras) ...@@ -3030,8 +3026,8 @@ function service_control_restart($name, $extras)
mwexec($cmd); mwexec($cmd);
} }
} else { } else {
$msg = sprintf(gettext("Could not restart service `%s'"), htmlspecialchars($name)); return sprintf(gettext("Could not restart service `%s'"), htmlspecialchars($name));
} }
return $msg; return sprintf(gettext("%s has been restarted."), htmlspecialchars($name));
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment