diff mbox series

[v2,2/5] base-files: add restart function wrapper

Message ID 20201217093537.22653-3-fe@dev.tdt.de
State New
Headers show
Series ubus: extend the service object with a restart method | expand

Commit Message

Florian Eckert Dec. 17, 2020, 9:35 a.m. UTC
Thies commit add the new wrapper function to rc.common to execute the new ubus
service method "restart" on a service restart.

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
---
 package/base-files/files/etc/rc.common | 13 +++++++++++++
 1 file changed, 13 insertions(+)
diff mbox series

Patch

diff --git a/package/base-files/files/etc/rc.common b/package/base-files/files/etc/rc.common
index f39b69464e..ad5af4b7a1 100755
--- a/package/base-files/files/etc/rc.common
+++ b/package/base-files/files/etc/rc.common
@@ -139,6 +139,19 @@  extra_command "enabled" "Check if service is started on boot"
 		fi
 	}
 
+	restart() {
+		if eval "type restart_service" 2>/dev/null >/dev/null; then
+			restart_service "$@"
+		else
+			trap '' TERM
+			stop "$@"
+			trap - TERM
+			start "$@"
+		fi
+		procd_open_service "$(basename ${basescript:-$initscript})" "$initscript"
+		procd_close_service "restart"
+	}
+
 	trace() {
 		TRACE_SYSCALLS=1
 		start "$@"