Before this change, the status of the sysfs paths from the kernel events was cached with a cache file. This is necessary to mark configured modems as available for the netifd. Using the new monitor service via the mmcli command 'mmcli -M' simplifies the whole process. There is no need to start sub shells in the background anymore that monitors whether the modem has already been added to the ModemManager. For this purpose, a new service was added that reacts on add and remove events for modems in the ModemManager and, if necessary, marks the logical netifd interface as available. Signed-off-by: Florian Eckert <fe@dev.tdt.de>
32 lines
535 B
Bash
32 lines
535 B
Bash
#!/bin/sh
|
|
|
|
. /usr/share/ModemManager/modemmanager.common
|
|
|
|
trap_with_arg() {
|
|
func="$1" ; shift
|
|
for sig ; do
|
|
# shellcheck disable=SC2064
|
|
trap "$func $sig" "$sig"
|
|
done
|
|
}
|
|
|
|
func_trap() {
|
|
logger "ModemManager-wrapper[$$]" "Sending signal ${1}..."
|
|
kill "-${1}" "$CHILD" 2>/dev/null
|
|
}
|
|
|
|
main() {
|
|
trap_with_arg func_trap INT TERM KILL
|
|
|
|
mkdir -p "${MODEMMANAGER_RUNDIR}"
|
|
chmod 0755 "${MODEMMANAGER_RUNDIR}"
|
|
|
|
/usr/sbin/ModemManager "$@" 1>/dev/null 2>/dev/null &
|
|
CHILD="$!"
|
|
|
|
mm_report_events_from_cache
|
|
|
|
wait "$CHILD"
|
|
}
|
|
|
|
main "$@"
|