From 6311388892f2edc8c49600e371e175cf226dac78 Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Wed, 4 Sep 2013 09:43:11 +0100 Subject: [PATCH] Add --list support to dib-run-parts. Our custom dib-run-parts now supports --list for better compatibility with some OS-provided run-parts tools. Change-Id: I2feb615b2094d9d6522bfe9b422362223bb8e652 Closes-Bug: #1190521 --- elements/dib-run-parts/bin/dib-run-parts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/elements/dib-run-parts/bin/dib-run-parts b/elements/dib-run-parts/bin/dib-run-parts index 3edd9aeb..de695d2b 100755 --- a/elements/dib-run-parts/bin/dib-run-parts +++ b/elements/dib-run-parts/bin/dib-run-parts @@ -17,13 +17,15 @@ # under the License. allowed_regex=${RUN_PARTS_REGEX:-"^[0-9A-Za-z_-]+$"} +show_list= set -ue name=$(basename $0) usage() { - echo "usage: $name scripts_directory" >&2 + echo "usage: $name [OPTION] scripts_directory" >&2 + echo " --list print names of all valid files" >&2 exit 1 } @@ -35,6 +37,11 @@ if [ $# -lt 1 ] ; then usage fi +if [ "$1" == "--list" ] ; then + show_list="1" + shift +fi + target_dir=$1 if ! [ -d $target_dir ] ; then @@ -49,6 +56,13 @@ fi # subdirectories) are run, which is the way run-parts behaves. targets=$(find $target_dir -maxdepth 1 -type f -executable -printf '%f\n' | grep -E "$allowed_regex" | LANG=C sort -n) +if [ "$show_list" == "1" ] ; then + for target in $targets ; do + echo "${target_dir}/${target}" + done + exit 0 +fi + PROFILE_DIR=$(mktemp -d /tmp/profiledir.XXXXXX) if [ -d /tmp/in_target.d/environment.d ] ; then