| # 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 |
| |
| # Note: This job is used by both ARC and ARCVM. |
| script |
| do_removal() { |
| if [ -d "$1" ]; then |
| echo "Removing $1" |
| # Remove contents of the directory. |
| # 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 "$1"/* |
| fi |
| } |
| { |
| 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 |
| |
| if grep -qs "1" /run/chrome/is_arcvm; then |
| # On ARCVM, stale *.odex files are kept in /data/vendor/arc. |
| do_removal \ |
| "${user_root_path}"/android-data/data/vendor/arc/old_arc_executables_pre_ota \ |
| || true |
| fi |
| |
| # Remove unnecessary /data directories (and for ARC, stale *.odex files |
| # too.) |
| do_removal "${user_root_path}"/android-data-old |
| |
| echo "Done." |
| } 2>&1 | logger --prio-prefix -t "${UPSTART_JOB}" |
| end script |