I think we should get rid of system daemon management completly, at
least from our core scripts. We still offer a hook that the user can
override on custom systems to restart modem daemons in case of crash.
We continue to manage vvmd and mmsd throught superd cause they are user
daemons and we choosed to use one daemon manager for that.
Signed-off-by: Stacy Harper <contact@stacyharper.net>
---
.../default_hooks/sxmo_hook_contextmenu.sh | 5 +-
configs/default_hooks/sxmo_hook_icons.sh | 1 +
.../sxmo_hook_restart_modem_daemons.sh | 106 +++++++++++++
configs/default_hooks/sxmo_hook_start.sh | 23 +--
scripts/modem/sxmo_modemdaemons.sh | 143 ------------------
scripts/modem/sxmo_modemmonitor.sh | 1 -
6 files changed, 114 insertions(+), 165 deletions(-)
create mode 100644 configs/default_hooks/sxmo_hook_restart_modem_daemons.sh
delete mode 100755 scripts/modem/sxmo_modemdaemons.sh
diff --git a/configs/default_hooks/sxmo_hook_contextmenu.sh b/configs/default_hooks/sxmo_hook_contextmenu.sh
index 3a84bdc3..629e8b32 100644
--- a/configs/default_hooks/sxmo_hook_contextmenu.sh
@@ -43,10 +43,7 @@ case "$WMCLASS" in
sxmo_daemons.sh running modem_monitor -q &&
printf %b "$icon_ton ^ 1 ^ sxmo_daemons.sh stop modem_monitor" || printf %b "$icon_tof ^ 1 ^ sxmo_daemons.sh start modem_monitor sxmo_modemmonitor.sh"
) && sxmo_hook_statusbar.sh modem_monitor
- $icon_phn Modem Daemons $(
- sxmo_modemdaemons.sh status > /dev/null &&
- printf %b "$icon_ton ^ 1 ^ sxmo_modemdaemons.sh stop" || printf %b "$icon_tof ^ 1 ^ sxmo_modemdaemons.sh start"
- ) && sxmo_hook_statusbar.sh modem
+ $icon_wrh Restart System Daemons ^ 1 ^ sxmo_hook_restart_modem_daemons.sh && sxmo_hook_statusbar.sh modem
$icon_inf Modem Info ^ 0 ^ sxmo_modeminfo.sh
$icon_phl Modem Log ^ 0 ^ sxmo_modemlog.sh
$icon_img Config MMS ^ 1 ^ sxmo_mmsdconfig.sh
diff --git a/configs/default_hooks/sxmo_hook_icons.sh b/configs/default_hooks/sxmo_hook_icons.sh
index fef5a8b9..262907dd 100644
--- a/configs/default_hooks/sxmo_hook_icons.sh
+++ b/configs/default_hooks/sxmo_hook_icons.sh
@@ -121,6 +121,7 @@ icon_vim=''
icon_wif=""
icon_win="" #window
icon_wn2=""
+icon_wrh=""
icon_wtr="" #weather
icon_ytb="" #youtube
icon_zmi=""
diff --git a/configs/default_hooks/sxmo_hook_restart_modem_daemons.sh b/configs/default_hooks/sxmo_hook_restart_modem_daemons.sh
new file mode 100644
index 00000000..4c7bdb9a
--- /dev/null
+++ b/configs/default_hooks/sxmo_hook_restart_modem_daemons.sh
@@ -0,0 +1,106 @@
+#!/bin/sh
+# SPDX-License-Identifier: AGPL-3.0-only
+# Copyright 2022 Sxmo Contributors
+
+# This script restart the modem-related daemons on the system
+# e.g., eg25-manager, modemmonitor, etc.
+
+# include common definitions
+# shellcheck source=scripts/core/sxmo_common.sh
+. sxmo_common.sh
+
+daemon_start() {
+ if ! daemon_exists "$1"; then
+ sxmo_notify_user.sh "$1 does not exist on the system"
+ return 1
+ fi
+ if daemon_isrunning "$1"; then
+ sxmo_notify_user.sh "$1 is already running"
+ return 0
+ fi
+ case "$OS" in
+ alpine|postmarketos)
+ doas rc-service "$1" start
+ ;;
+ arch|archarm|debian)
+ [ "$1" = "modemmanager" ] && set -- ModemManager
+ doas systemctl start "$1"
+ ;;
+ esac
+}
+
+daemon_stop() {
+ if ! daemon_exists "$1"; then
+ sxmo_notify_user.sh "$1 does not exist on the system"
+ return 1
+ fi
+ if ! daemon_isrunning "$1"; then
+ sxmo_notify_user.sh "$1 is already stopped"
+ return 0
+ fi
+ case "$OS" in
+ alpine|postmarketos)
+ doas rc-service "$1" stop
+ ;;
+ arch|archarm)
+ [ "$1" = "modemmanager" ] && set -- ModemManager
+ doas systemctl stop "$1"
+ ;;
+ esac
+}
+
+daemon_isrunning() {
+ if ! daemon_exists "$1"; then
+ sxmo_log "$1 does not exist on the system"
+ return 1
+ fi
+ case "$OS" in
+ alpine|postmarketos)
+ rc-service "$1" status | grep -q started
+ ;;
+ arch|archarm|debian)
+ [ "$1" = "modemmanager" ] && set -- ModemManager
+ systemctl is-active --quiet "$1"
+ ;;
+ esac
+}
+
+daemon_exists() {
+ case "$OS" in
+ alpine|postmarketos)
+ [ -f /etc/init.d/"$1" ]
+ ;;
+ arch|archarm|debian)
+ [ "$1" = "modemmanager" ] && set -- ModemManager
+ systemctl status "$1" > /dev/null 2>&1
+ [ $? -ne 4 ]
+ ;;
+ esac
+}
+
+if [ "$SXMO_EG25" = 1 ]; then
+
+ if daemon_isrunning eg25-manager; then
+ sxmo_notify_user.sh "Already running eg25-manager..."
+ else
+ sxmo_notify_user.sh "Starting eg25-manager..."
+ daemon_start eg25-manager
+ sleep 30
+ fi
+ if ! daemon_isrunning eg25-manager; then
+ sxmo_notify_user.sh --urgency=critical "The eg25-manager failed to start!"
+ exit 1
+ fi
+fi
+
+if daemon_isrunning modemmanager; then
+ sxmo_notify_user.sh "Already running modemmanager..."
+else
+ sxmo_notify_user.sh "Starting modemmanager..."
+ daemon_start modemmanager
+ sleep 5
+fi
+if ! daemon_isrunning modemmanager; then
+ sxmo_notify_user.sh --urgency=critical "The modemmanager failed to start!"
+ exit 1
+fi
diff --git a/configs/default_hooks/sxmo_hook_start.sh b/configs/default_hooks/sxmo_hook_start.sh
index 67a9b145..8c0085a3 100644
--- a/configs/default_hooks/sxmo_hook_start.sh
+++ b/configs/default_hooks/sxmo_hook_start.sh
@@ -79,24 +79,13 @@ superctl start pipewire
superctl start pipewire-pulse
superctl start wireplumber
-# Verify modemmanager and eg25-manager are running
-if ! sxmo_modemdaemons.sh status; then
- sxmo_notify_user.sh --urgency=critical "Warning! Modem daemons are not running."
-else
+(
+ sleep 5 # let some time to pipewire
+ superctl start callaudiod
- (
- sleep 5 # let some time to pipewire
- superctl start callaudiod
-
- # Turn on the dbus-monitors for modem-related tasks
- sxmo_daemons.sh start modem_monitor sxmo_modemmonitor.sh
- ) &
-
- # Prevent crust for 120s if this is a reboot (uptime < 3mins)
- if [ "$(cut -d '.' -f1 < /proc/uptime)" -lt 180 ]; then
- sxmo_daemons.sh start modem_nocrust sleep 120
- fi
-fi
+ # Turn on the dbus-monitors for modem-related tasks
+ sxmo_daemons.sh start modem_monitor sxmo_modemmonitor.sh
+) &
sxmo_migrate.sh state || sxmo_notify_user.sh --urgency=critical \
"Config needs migration" "$? file(s) in your sxmo configuration are out of date and disabled - using defaults until you migrate (run sxmo_migrate.sh)"
diff --git a/scripts/modem/sxmo_modemdaemons.sh b/scripts/modem/sxmo_modemdaemons.sh
deleted file mode 100755
index 7e567f39..00000000
--- a/scripts/modem/sxmo_modemdaemons.sh
@@ -1,143 +0,0 @@
-#!/bin/sh
-# SPDX-License-Identifier: AGPL-3.0-only
-# Copyright 2022 Sxmo Contributors
-
-# This script handles the modem-related daemons on the system, e.g., eg25-manager, modemmonitor, etc.
-
-# include common definitions
-# shellcheck source=scripts/core/sxmo_common.sh
-. "$(dirname "$0")/sxmo_common.sh"
-
-daemon_start() {
- if ! daemon_exists "$1"; then
- sxmo_notify_user.sh "$1 does not exist on the system"
- return 1
- fi
- if daemon_isrunning "$1"; then
- sxmo_notify_user.sh "$1 is already running"
- return 0
- fi
- case "$OS" in
- alpine|postmarketos)
- doas rc-service "$1" start
- ;;
- arch|archarm|debian)
- [ "$1" = "modemmanager" ] && set -- ModemManager
- doas systemctl start "$1"
- ;;
- esac
-}
-
-daemon_stop() {
- if ! daemon_exists "$1"; then
- sxmo_notify_user.sh "$1 does not exist on the system"
- return 1
- fi
- if ! daemon_isrunning "$1"; then
- sxmo_notify_user.sh "$1 is already stopped"
- return 0
- fi
- case "$OS" in
- alpine|postmarketos)
- doas rc-service "$1" stop
- ;;
- arch|archarm)
- [ "$1" = "modemmanager" ] && set -- ModemManager
- doas systemctl stop "$1"
- ;;
- esac
-}
-
-daemon_isrunning() {
- if ! daemon_exists "$1"; then
- sxmo_log "$1 does not exist on the system"
- return 1
- fi
- case "$OS" in
- alpine|postmarketos)
- rc-service "$1" status | grep -q started
- ;;
- arch|archarm|debian)
- [ "$1" = "modemmanager" ] && set -- ModemManager
- systemctl is-active --quiet "$1"
- ;;
- esac
-}
-
-daemon_exists() {
- case "$OS" in
- alpine|postmarketos)
- [ -f /etc/init.d/"$1" ]
- ;;
- arch|archarm|debian)
- [ "$1" = "modemmanager" ] && set -- ModemManager
- systemctl status "$1" > /dev/null 2>&1
- [ $? -ne 4 ]
- ;;
- esac
-}
-
-case "$1" in
- start)
-
- sxmo_notify_user.sh "Starting modemmanager..."
-
- daemon_start modemmanager
- if ! daemon_isrunning modemmanager; then
- sxmo_notify_user.sh --urgency=critical "The modemmanager failed to start!"
- exit 1
- fi
-
- if [ "$SXMO_EG25" = 1 ]; then
- sxmo_notify_user.sh "Starting eg25-manager..."
-
- daemon_start eg25-manager
- if ! daemon_isrunning eg25-manager; then
- sxmo_notify_user.sh --urgency=critical "The eg25-manager failed to start!"
- exit 1
- fi
- fi
-
- sxmo_notify_user.sh --urgency=critical "Do not restart or reboot for 120s!"
- # blocks crust for 120s. see can_suspend
- sxmo_daemons.sh start modem_nocrust sleep 120
-
- sxmo_notify_user.sh "Finished starting modem daemons."
- ;;
- stop)
-
- if sxmo_daemons.sh running modem_nocrust -q; then
- sxmo_notify_user.sh "Modem still warming up..."
- exit 1
- fi
-
- if [ "$SXMO_EG25" = 1 ]; then
- # stop eg25-manager first.
- # eg25-manager takes 30s to shutdown (which is unnecessary but will cause problems
- # if we try to start it within that period)
- # It is up to the user to put post_stop() { sleep 32 } in /etc/init.d/eg25-manager
- sxmo_notify_user.sh "Stopping eg25-manager. WARNING: please wait 30s before restarting."
-
- if ! daemon_stop eg25-manager; then
- sxmo_notify_user.sh --urgency=critical "The eg25-manager failed to stop!"
- fi
- fi
-
- sxmo_notify_user.sh "Stopping modemmanager..."
-
- if ! daemon_stop modemmanager; then
- sxmo-notify_user.sh --urgency=critical "The modemmanager failed to stop!"
- fi
-
- # according to biktorgj we need 2s to stop, so maybe roll this into post_stop() in init script
- sleep 2
-
- sxmo_notify_user.sh "Finished stopping daemons."
- ;;
- status)
- if [ "$SXMO_EG25" = 1 ]; then
- daemon_isrunning eg25-manager || exit 1
- fi
- daemon_isrunning modemmanager || exit 1
- ;;
-esac
diff --git a/scripts/modem/sxmo_modemmonitor.sh b/scripts/modem/sxmo_modemmonitor.sh
index b786fb57..6cc4b93d 100755
--- a/scripts/modem/sxmo_modemmonitor.sh
+++ b/scripts/modem/sxmo_modemmonitor.sh
@@ -17,7 +17,6 @@ gracefulexit() {
sxmo_daemons.sh stop modem_monitor_text
sxmo_daemons.sh stop modem_monitor_finished_voice
sxmo_daemons.sh stop modem_monitor_state_change
- sxmo_daemons.sh stop modem_monitor_check_daemons
sxmo_daemons.sh stop modem_monitor_mms
sxmo_daemons.sh stop modem_monitor_vvm
exit
--
2.36.1