| # Copyright (c) 2012 The Chromium OS Authors. All rights reserved. |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| |
| description "starts modemmanager once udev has been started." |
| author "chromium-os-dev@chromium.org" |
| |
| oom score -100 |
| |
| # Log level: ERR, WARN, INFO, DEBUG |
| env MM_LOGLEVEL=INFO |
| |
| import MM_LOGLEVEL |
| |
| start on starting system-services |
| stop on stopping system-services |
| |
| respawn |
| # if the job respawns 3 times in 30 seconds, stop trying. |
| respawn limit 3 30 |
| # Do not respawn if we exited on purpose (e.g. service disabled). |
| normal exit 0 |
| |
| # Keep track of the ModemManager process launched by minijail instead of the |
| # minijail process. minijail exits immediately after launching ModemManager. |
| expect fork |
| |
| pre-start script |
| case "${MM_LOGLEVEL}" in |
| DEBUG|INFO|WARN|ERR) |
| ;; |
| *) |
| logger -p err -t "${UPSTART_JOB}" "Unsupported log level: ${MM_LOGLEVEL}" |
| exit 1 |
| ;; |
| esac |
| end script |
| |
| script |
| # Override logging level if sticky flag exists. |
| if [ -f /var/cache/modem-utilities/log_mm_debug ]; then |
| MM_LOGLEVEL=DEBUG |
| fi |
| # Run ModemManager under the 'modem' user/group. Keep the CAP_SYS_ADMIN |
| # capability to allow ModemManager to set 'closing_wait' to none on the modem |
| # serial port via ioctl(TIOCGSERIAL). Set NoNewPrivs. CAP_NET_ADMIN is needed |
| # to create net links for Qrtr devices. |
| exec minijail0 -u modem -g modem -n -i -c cap_net_admin,cap_sys_admin=e \ |
| -S /usr/share/policy/modemmanager.policy -- \ |
| /usr/sbin/ModemManager --log-level="${MM_LOGLEVEL}" |
| end script |