From d430cce8ff478d3bdd99cef0f171cca24b7665da Mon Sep 17 00:00:00 2001 From: Maxim Karasev Date: Sun, 29 Aug 2021 22:55:41 +0300 Subject: [PATCH] Fix non-eg25 modems in modemmonitortoggle Signed-off-by: Stacy Harper --- scripts/modem/sxmo_modemmonitortoggle.sh | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/scripts/modem/sxmo_modemmonitortoggle.sh b/scripts/modem/sxmo_modemmonitortoggle.sh index eafa805..0cf1824 100755 --- a/scripts/modem/sxmo_modemmonitortoggle.sh +++ b/scripts/modem/sxmo_modemmonitortoggle.sh @@ -19,7 +19,7 @@ else fi daemon_start() { - case $OS in + case "$OS" in "Alpine Linux"|postmarketOS) sudo rc-service "$1" start ;; @@ -31,7 +31,7 @@ daemon_start() { } daemon_stop() { - case $OS in + case "$OS" in "Alpine Linux"|postmarketOS) sudo rc-service "$1" stop ;; @@ -43,7 +43,8 @@ daemon_stop() { } daemon_isrunning() { - case $OS in + daemon_exists "$1" || return 0 + case "$OS" in "Alpine Linux"|postmarketOS) rc-service "$1" status | grep -q started ;; @@ -54,6 +55,17 @@ daemon_isrunning() { esac } +daemon_exists() { + case "$OS" in + "Alpine Linux"|postmarketOS) + [ -f /etc/init.d/"$1" ] + ;; + "Arch Linux ARM"|alarm) + systemctl status "$1" >/dev/null + ;; + esac +} + ensure_daemon() { TRIES=0 while ! daemon_isrunning "$1"; do @@ -69,7 +81,8 @@ ensure_daemon() { } ensure_daemons() { - if (daemon_isrunning eg25-manager) && (daemon_isrunning modemmanager); then + if (daemon_isrunning eg25-manager) && \ + (daemon_isrunning modemmanager); then return fi