Print better info mesages when we change a service

Message ID 1518264894-8343-1-git-send-email-jonatan.schlag@ipfire.org
State New
Headers show
Series
  • Print better info mesages when we change a service
Related show

Commit Message

Jonatan Schlag Feb. 10, 2018, 11:14 p.m. UTC
Signed-off-by: Jonatan Schlag <jonatan.schlag@ipfire.org>
---
 src/functions/functions.service | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

Comments

Michael Tremer Feb. 11, 2018, 1:41 a.m. UTC | #1
Why do we need this?

Best,
-Michael

On Sat, 2018-02-10 at 12:14 +0000, Jonatan Schlag wrote:
> Signed-off-by: Jonatan Schlag <jonatan.schlag@ipfire.org>
> ---
>  src/functions/functions.service | 17 ++++++++++++++++-
>  1 file changed, 16 insertions(+), 1 deletion(-)
> 
> diff --git a/src/functions/functions.service b/src/functions/functions.service
> index 7a12ffd..07bd2cd 100644
> --- a/src/functions/functions.service
> +++ b/src/functions/functions.service
> @@ -45,6 +45,11 @@ service_stop() {
>  	assert isset name
>  
>  	systemctl stop "${name}"
> +	local ret=$?
> +
> +	log INFO "Stopped service '${name}', code=${ret}"
> +
> +	return ${ret}
>  }
>  
>  service_restart() {
> @@ -52,6 +57,11 @@ service_restart() {
>  	assert isset name
>  
>  	systemctl restart "${name}"
> +	local ret=$?
> +
> +	log INFO "Restarted service '${name}', code=${ret}"
> +
> +	return ${ret}
>  }
>  
>  service_reload() {
> @@ -60,7 +70,12 @@ service_reload() {
>  
>  	if service_status "${name}"; then
>  		systemctl reload "${name}"
> -		return $?
> +		local ret=$?
> +
> +		log INFO "Reloaded service '${name}', code=${ret}"
> +
> +		return ${ret}
> +
>  	else
>  		log WARNING "Cannot reload service '${name}' which is
> currently not running."
>  	fi

Patch

diff --git a/src/functions/functions.service b/src/functions/functions.service
index 7a12ffd..07bd2cd 100644
--- a/src/functions/functions.service
+++ b/src/functions/functions.service
@@ -45,6 +45,11 @@  service_stop() {
 	assert isset name
 
 	systemctl stop "${name}"
+	local ret=$?
+
+	log INFO "Stopped service '${name}', code=${ret}"
+
+	return ${ret}
 }
 
 service_restart() {
@@ -52,6 +57,11 @@  service_restart() {
 	assert isset name
 
 	systemctl restart "${name}"
+	local ret=$?
+
+	log INFO "Restarted service '${name}', code=${ret}"
+
+	return ${ret}
 }
 
 service_reload() {
@@ -60,7 +70,12 @@  service_reload() {
 
 	if service_status "${name}"; then
 		systemctl reload "${name}"
-		return $?
+		local ret=$?
+
+		log INFO "Reloaded service '${name}', code=${ret}"
+
+		return ${ret}
+
 	else
 		log WARNING "Cannot reload service '${name}' which is currently not running."
 	fi