| # Copyright 2016 The ChromiumOS Authors | |
| # Use of this source code is governed by a BSD-style license that can be | |
| # found in the LICENSE file. | |
| description "Run ureadahead for ARC++" | |
| author "chromium-os-dev@chromium.org" | |
| # Run this job in parallel with arc_setup_wrapper.sh run_oci hook. The job | |
| # shouldn't be started until 'ureadahead' (which may be in tracing mode) | |
| # is stopped, otherwise ureadahead may corrupt the $PACK file. Depending | |
| # on start-arc-instance ensures that. | |
| start on start-arc-instance | |
| import DISABLE_UREADAHEAD | |
| # 'never' since terminating this job after it starts can cause ARC boot failure. | |
| oom score never | |
| script | |
| { | |
| PACK=/opt/google/containers/android/ureadahead.pack | |
| echo "Start arc-ureadahead" | |
| set -x | |
| # Read-ahead files in the image. | |
| if [ "${HOST_UREADAHEAD_MODE}" = "DISABLED" ]; then | |
| logger -t "${UPSTART_JOB}" "Ureadahead is disabled." | |
| elif [ "${HOST_UREADAHEAD_MODE}" = "GENERATE" ]; then | |
| logger -t "${UPSTART_JOB}" "Ureadahead is in generate mode." | |
| elif [ "${HOST_UREADAHEAD_MODE}" = "DEFAULT" ]; then | |
| if [ -f "${PACK}" ]; then | |
| ureadahead --pack-file="${PACK}" || | |
| echo "Failed to start ureadahead pack for ${PACK}" | |
| else | |
| echo "ureadahead pack is not available at ${PACK}" | |
| fi | |
| else | |
| echo "ureadahead mode is invalid ${HOST_UREADAHEAD_MODE}" | |
| fi | |
| } 2>&1 | logger -t "${UPSTART_JOB}" | |
| end script |