Commit aa19f4b1 authored by Franco Fichtner's avatar Franco Fichtner

services: refactor return values

Suggested by: @fabianfrz
parent f759d902
...@@ -2937,8 +2937,6 @@ function is_radvd_enabled() { ...@@ -2937,8 +2937,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'];
} }
...@@ -2947,6 +2945,7 @@ function service_control_start($name, $extras) ...@@ -2947,6 +2945,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);
...@@ -2966,15 +2965,14 @@ function service_control_start($name, $extras) ...@@ -2966,15 +2965,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'])) {
...@@ -3005,13 +3003,11 @@ function service_control_stop($name, $extras) ...@@ -3005,13 +3003,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'];
} }
...@@ -3040,8 +3036,8 @@ function service_control_restart($name, $extras) ...@@ -3040,8 +3036,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