oonf-olsrd2: add support to check if service is running
authorMaciej Krüger <mkg20001@gmail.com>
Sat, 9 Apr 2022 23:58:41 +0000 (01:58 +0200)
committerNick Hainke <vincent@systemli.org>
Sun, 11 Jun 2023 07:37:15 +0000 (09:37 +0200)
Signed-off-by: Maciej Krüger <mkg20001@gmail.com>
oonf-init-scripts/files/oonf_init.sh
oonf-olsrd2/Makefile
oonf-olsrd2/files/olsrd2.init

index 8ab5b3b90661fcbe01b884e191d9159af87c1b0a..a945c4e6643e80252f9b4d8301c7e2cd3b1cd921 100755 (executable)
@@ -118,3 +118,20 @@ reload()
   oonf_add_devices_to_configuration
   oonf_reread_config
 }
+
+running()
+{
+  # check if we have a pidfile and then check if that pid still exists.
+  # since we don't use -e this has to be explicitly returned. exit would stop the process.
+  test -e "/tmp/run/olsrd2.pid" && test -e "/proc/$(cat "/tmp/run/olsrd2.pid")" && return 0
+  return 1
+}
+
+status()
+{
+  if running; then
+    echo "running"
+  else
+    echo "stopped"
+  fi
+}
index 9494cb38e407b173f3e3ec4fa1e884ade0b77312..38c63839018ba9716b5e700c4574dfa36f4a9467 100644 (file)
@@ -1,7 +1,7 @@
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=oonf-olsrd2
-PKG_RELEASE:=1
+PKG_RELEASE:=2
 
 PKG_SOURCE_PROTO:=git
 PKG_SOURCE_URL:=https://github.com/OLSR/OONF.git
index 04b30ffa4a7a4d65e2fb9944e4570273a9418f2e..59795c2a16add0206bd61bcda0d995b48e903166 100755 (executable)
@@ -5,4 +5,7 @@ DAEMON='olsrd2'
 
 [ -n "$IPKG_INSTROOT" ] || {
         . /lib/functions/oonf_init.sh
+
+        extra_command "running" "Check if service is running"
+        extra_command "status" "Service status"
 }