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
This commit is contained in:
Chris Jones 2013-09-04 09:43:11 +01:00
parent 564a7c7712
commit 43f720c2e3
1 changed files with 15 additions and 1 deletions

View File

@ -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