modemmonitortoggle may take an argument "on" or "off" to force toggling to a desired state

Signed-off-by: Anjandev Momi <anjan@momi.ca>
This commit is contained in:
Maarten van Gompel 2020-12-02 00:34:49 +01:00 committed by Anjandev Momi
parent c915de82d8
commit 17e3b623bf

View file

@ -1,7 +1,12 @@
#!/usr/bin/env sh
if pgrep -f sxmo_modemmonitor.sh; then
# This script toggles the modem monitor
# It optionally takes a parameter "on" or "off"
# forcing it to toggle only to that desired state if applicable.
if [ "$1" != "on" ] && pgrep -f sxmo_modemmonitor.sh; then
pgrep -f sxmo_modemmonitor.sh | grep -Ev "^${$}$" | xargs -IP kill -TERM P
else
elif [ "$1" != "off" ]; then
setsid -f sxmo_modemmonitor.sh &
fi