| # 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 started arc-remove-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 |
| |
| import CHROMEOS_USER |
| |
| script |
| { |
| set -u |
| echo "Start arc-stale-directory-remover" |
| |
| user_root_path="$(cryptohome-path system $CHROMEOS_USER)" |
| # Ensure the user directory exists |
| if [ ! -d "$user_root_path" ]; then |
| echo "<3> ${user_root_path} doesn't exist" |
| exit 1 |
| fi |
| |
| android_data_old_dir="${user_root_path}"/android-data-old |
| |
| 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 arc-remove-data.conf 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 --prio-prefix -t "${UPSTART_JOB}" |
| end script |