| # Copyright 2018 The ChromiumOS Authors |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| |
| description "Set up esdfs directories" |
| author "chromium-os-dev@chromium.org" |
| |
| # The job is started from arc-setup's OnBootContinue(). |
| # Stop on stopping ui to avoid mount leaks in the login screen (b/288954735). |
| stop on stop-arc-instance or stopping ui |
| |
| # The job does not have script/exec stanza, so it is considered running forever |
| # once started until explicitly stopped. |
| # See: http://upstart.ubuntu.com/cookbook/#jobs-that-run-forever |
| import CHROMEOS_USER |
| import CONTAINER_PID |
| |
| # Use 'never' since terminating this job fails ARC to start. |
| oom score never |
| |
| pre-start script |
| { |
| echo "Pre-start arc-sdcard" |
| set -x |
| # Start the actual mounting process in a separate job. This allows |
| # arc-setup --mode=mount-sdcard to be interrupted cleanly if the container |
| # terminates. |
| exec start arc-sdcard-mount "CHROMEOS_USER=${CHROMEOS_USER}" \ |
| "CONTAINER_PID=${CONTAINER_PID}" |
| } 2>&1 | logger -t "${UPSTART_JOB}" |
| end script |
| |
| post-stop script |
| { |
| echo "Post-stop arc-sdcard" |
| set -x +e |
| # The arc-sdcard-mount job might still be running. Ensure it dies so that |
| # the next container invocation can continue cleanly. |
| stop arc-sdcard-mount |
| find "/sys/kernel/config/sdcardfs/" -mindepth 1 -maxdepth 1 \ |
| -type d -not -name 'extensions' -exec rmdir {} \+ |
| } 2>&1 | logger -t "${UPSTART_JOB}" |
| exec /usr/sbin/arc-setup --mode=unmount-sdcard "--log_tag=${UPSTART_JOB}" |
| end script |