From 3c5a646ae39ec38b83cba1729abcd3c32aa8a276 Mon Sep 17 00:00:00 2001 From: Jeremy Lecour Date: Thu, 12 Nov 2020 18:35:41 +0100 Subject: [PATCH] bkctld-rm: list jails from incs directory We list jails in "incs" directory, not in "jails" directory so we can clean old incs after a jail is archived --- CHANGELOG.md | 1 + lib/bkctld-rm | 4 +++- lib/includes | 6 +++++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 179315d..db6f390 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed * Better help message composition and formating +* bkctld-rm: list jails from incs directory ### Deprecated diff --git a/lib/bkctld-rm b/lib/bkctld-rm index 1c448c8..3d5a99f 100755 --- a/lib/bkctld-rm +++ b/lib/bkctld-rm @@ -92,7 +92,9 @@ trap "rm -f ${lock_file}; cleanup_tmp;" 0 kill_or_clean_lockfile "${lock_file}" new_lock_file "${lock_file}" -jails_list=$(jails_list) +# We list jails in "incs" directory, not in "jails" directory +# so we can clean old incs after a jail is archived +jails_list=$(jails_with_incs_list) jails_total=$(echo $jails_list | wc -w) jails_count=0 diff --git a/lib/includes b/lib/includes index 9b0c211..91b0547 100755 --- a/lib/includes +++ b/lib/includes @@ -129,12 +129,16 @@ is_btrfs() { test $inode -eq 256 } -# Returns the list of all jails +# Returns the list of jails found in the "jails" directory (default) jails_list() { # TODO: try if this command works the same : # find "${JAILDIR}" -mindepth 1 -maxdepth 1 -type d -printf '%f\n' find "${JAILDIR}" -mindepth 1 -maxdepth 1 -type d | sed 's!.*/!!' | sort -h } +# Returns the list of jails found in the "incs" directory +jails_with_incs_list() { + find "${INCDIR}" -mindepth 1 -maxdepth 1 -type d | sed 's!.*/!!' | sort -h +} # Returns the complete path of a jail jail_path() { jail_name=${1:?}