| # Copyright 2021 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 "Chrome OS RMA service" |
| author "chromium-os-dev@chromium.org" |
| |
| # This daemon is started by D-Bus service activation configured in |
| # dbus/org.chromium.Rmad.service. |
| stop on stopping system-services |
| |
| # Make it killable. |
| oom score -100 |
| # Let the daemon crash if it grows too much. "as" for "address space". |
| # TODO(chenghan): Check memory usage after some development. Currently set |
| # to 200 MB. |
| limit as 200000000 unlimited |
| |
| env POWERWASH_REQUEST_FILE=/var/lib/rmad/.powerwash_request |
| env CUTOFF_REQUEST_FILE=/var/lib/rmad/.battery_cutoff_request |
| env TEST_MODE_DIR=/var/lib/rmad/.test |
| |
| script |
| FLAGS="" |
| if [ -d "${TEST_MODE_DIR}" ]; then |
| FLAGS="--test_mode" |
| fi |
| exec /usr/sbin/rmad "${FLAGS}" |
| end script |
| |
| # Wait for daemon for claim its D-Bus name. |
| post-start exec minijail0 -u rmad -g rmad /usr/bin/gdbus wait --system \ |
| --timeout 15 org.chromium.Rmad |
| |
| pre-stop script |
| if [ -e "${POWERWASH_REQUEST_FILE}" ]; then |
| echo "fast safe keepimg rma" > /mnt/stateful_partition/factory_install_reset |
| fi |
| if [ -e "${CUTOFF_REQUEST_FILE}" ]; then |
| crossystem battery_cutoff_request=1 |
| fi |
| end script |