From 7d1964370d4ccd1364add2f8919d1505d2f0e2e6 Mon Sep 17 00:00:00 2001 From: Jeremy Lecour Date: Fri, 28 Aug 2020 10:21:13 +0200 Subject: [PATCH] jails and incs lists are sorted alphanumerically --- CHANGELOG.md | 2 ++ lib/bkctld-list | 4 +--- lib/includes | 36 ++++++++++++++++++------------------ 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 70a0b9e..1488371 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added +* jails and incs lists are sorted alphanumerically + ### Changed ### Deprecated diff --git a/lib/bkctld-list b/lib/bkctld-list index 25647d9..3815871 100755 --- a/lib/bkctld-list +++ b/lib/bkctld-list @@ -10,6 +10,4 @@ set -eu LIBDIR="$(dirname $0)" && . "${LIBDIR}/includes" [ -d "${JAILDIR}" ] || exit 0 -#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!.*/!!' +jails_list diff --git a/lib/includes b/lib/includes index 639dd3f..5650911 100755 --- a/lib/includes +++ b/lib/includes @@ -94,14 +94,9 @@ is_btrfs() { # Returns the list of all jails jails_list() { - # shellcheck disable=SC2091 - "${LIBDIR}/bkctld-list" -} -# Returns the list of all incs for a jail -incs_list() { - jail_name=${1:?} - # shellcheck disable=SC2091 - ls "$(incs_path "${jail_name}")/" + # 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 complete path of a jail jail_path() { @@ -109,6 +104,18 @@ jail_path() { echo "${JAILDIR}/${jail_name}" } +jail_config_dir() { + jail_name=${1:?} + + echo "${CONFDIR}/${jail_name}.d" +} +jail_incs_policy_file() { + jail_name=${1:?} + + jail_config_dir=$(jail_config_dir "${jail_name}") + + echo "${jail_config_dir}/incs_policy" +} # Returns the path of incs for a jail incs_path() { jail_name=${1:?} @@ -131,17 +138,10 @@ inc_exists() { # inc_path must not be quoted because it can contain globs ls -d ${inc_path} > /dev/null 2>&1 } -jail_config_dir() { +# Returns the list of all incs for a jail +incs_list() { jail_name=${1:?} - - echo "${CONFDIR}/${jail_name}.d" -} -jail_incs_policy_file() { - jail_name=${1:?} - - jail_config_dir=$(jail_config_dir "${jail_name}") - - echo "${jail_config_dir}/incs_policy" + find "$(incs_path "${jail_name}")" -mindepth 1 -maxdepth 1 -type d | sed 's!.*/!!' | sort -h } current_jail_incs_policy_file() { jail_name=${1:?}