b.liu | e958203 | 2025-04-17 19:18:16 +0800 | [diff] [blame^] | 1 | #!/bin/sh /etc/rc.common |
| 2 | # Copyright (C) 2016 Aleksander Morgado <aleksander@aleksander.es> |
| 3 | |
| 4 | USE_PROCD=1 |
| 5 | START=70 |
| 6 | |
| 7 | stop_service() { |
| 8 | # Load common utils |
| 9 | . /usr/share/ModemManager/modemmanager.common |
| 10 | # Set all configured interfaces as unavailable |
| 11 | mm_cleanup_interfaces |
| 12 | } |
| 13 | |
| 14 | start_service() { |
| 15 | # Setup ModemManager service |
| 16 | # |
| 17 | # We will make sure that the rundir always exists, and we initially cleanup |
| 18 | # all interfaces flagging them as unavailable. |
| 19 | # |
| 20 | # The cached events processing will wait for MM to be available in DBus |
| 21 | # and will make sure all ports are re-notified to ModemManager every time |
| 22 | # it starts. |
| 23 | # |
| 24 | # All these commands need to be executed on every MM start, even after |
| 25 | # procd-triggered respawns, which is why they're all included as instance command |
| 26 | # |
| 27 | procd_open_instance |
| 28 | procd_set_param command sh -c ". /usr/share/ModemManager/modemmanager.common; \ |
| 29 | mkdir -m 0755 -p ${MODEMMANAGER_RUNDIR}; \ |
| 30 | mm_cleanup_interfaces; \ |
| 31 | ( mm_report_events_from_cache ) >/dev/null 2>&1 & \ |
| 32 | /usr/sbin/ModemManager" |
| 33 | procd_set_param respawn "${respawn_threshold:-3600}" "${respawn_timeout:-5}" "${respawn_retry:-5}" |
| 34 | procd_set_param pidfile "${MODEMMANAGER_PID_FILE}" |
| 35 | procd_close_instance |
| 36 | } |