From 6964c7363ce6916d61fca08771ad6bea6ec5b31a Mon Sep 17 00:00:00 2001 From: Abdelah Yisehak <112805391+abd3-13@users.noreply.github.com> Date: Sat, 4 Jul 2026 15:09:01 +0300 Subject: [PATCH] change: chkopenrc.sh to use rc-status for checking of running services --- Android/app/src/main/assets/chkopenrc.sh | 25 +++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/Android/app/src/main/assets/chkopenrc.sh b/Android/app/src/main/assets/chkopenrc.sh index 98cc8371..5512fe59 100644 --- a/Android/app/src/main/assets/chkopenrc.sh +++ b/Android/app/src/main/assets/chkopenrc.sh @@ -4,6 +4,10 @@ RUNLEVELS_DIR="/etc/runlevels" INITD_DIR="/etc/init.d" +_all_running() { + rc-status -f ini 2>/dev/null | awk -F'=' '/=/ {gsub(/^[ \t]+|[ \t]+$/, "", $1); print $1}' +} + _all_services() { ls "$INITD_DIR" 2>/dev/null | grep -v '^\.' | sort } @@ -22,13 +26,24 @@ _get_desc() { case "$1" in --running) - # Output: name|Description (matches chksystemd.sh --running) - for svc in $(_all_services); do - if rc-service "$svc" status >/dev/null 2>&1; then + # Output: name|Description (matches chksystemd.sh --running) + + if running=$(_all_running 2>/dev/null); then + # Preferred method: use rc-status output directly. + echo "$running" | while IFS= read -r svc; do + [ -n "$svc" ] || continue desc=$(_get_desc "$svc") echo "${svc}|${desc}" - fi - done + done + else + # Fallback: query each service individually. + for svc in $(_all_services); do + if rc-service "$svc" status >/dev/null 2>&1; then + desc=$(_get_desc "$svc") + echo "${svc}|${desc}" + fi + done + fi ;; --enabled) # Output: name