| # Copyright 2016 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 "Remove stale ARC directories." |
| author "chromium-os-dev@chromium.org" |
| |
| start on remove-old-arc-data or arc-booted |
| |
| # Stop the job on 'stopping ui' because once ui is stopped, ARC data files |
| # in the user's home directory will not be accessible anyway. |
| stop on stopping ui |
| |
| # The following environment variable is passed from session_manager |
| # and is imported from the event that starts the job. |
| import ANDROID_DATA_OLD_DIR |
| |
| script |
| { |
| echo "Start arc-stale-directory-remover" |
| set -x |
| |
| # Do nothing unless the variable is set. Currently this script only handles |
| # that directory. |
| [ -z "$ANDROID_DATA_OLD_DIR" ] && \ |
| (echo "\$ANDROID_DATA_OLD_DIR is not set, do nothing." && exit 1) |
| |
| if [ -d "$ANDROID_DATA_OLD_DIR" ]; then |
| # Remove contents of the directory, /home/root/<hash>/android-data-old/. |
| # Note that this script does not remove the directory itself to ensure |
| # that RemoveArcData() in session_manager always works regardless of |
| # whether this script is running. Also note that the directory does not |
| # have any dot files and hence "/*" always matches all entries in the |
| # directory. |
| nice rm -rf "$ANDROID_DATA_OLD_DIR"/* |
| fi |
| echo "Done." |
| } 2>&1 | logger -t "${UPSTART_JOB}" |
| end script |