diff --git a/bin/dib-run-parts b/bin/dib-run-parts new file mode 120000 index 000000000..055c8b3c0 --- /dev/null +++ b/bin/dib-run-parts @@ -0,0 +1 @@ +../elements/dib-run-parts/bin/dib-run-parts \ No newline at end of file diff --git a/elements/dib-run-parts/root.d/dib-run-parts b/elements/dib-run-parts/bin/dib-run-parts old mode 100644 new mode 100755 similarity index 90% rename from elements/dib-run-parts/root.d/dib-run-parts rename to elements/dib-run-parts/bin/dib-run-parts index b528c9eec..3edd9aeb2 --- a/elements/dib-run-parts/root.d/dib-run-parts +++ b/elements/dib-run-parts/bin/dib-run-parts @@ -45,7 +45,9 @@ fi # We specifically only want to sort *by the numbers*. # Lexical sorting is not guaranteed, and identical numbers may be # parallelized later -targets=$(find $target_dir -type f -executable -printf '%f\n' | grep -E "$allowed_regex" | LANG=C sort -n) +# Note: -maxdepth 1 ensures only files in the target directory (but not +# 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) PROFILE_DIR=$(mktemp -d /tmp/profiledir.XXXXXX) diff --git a/elements/dib-run-parts/root.d/90-base-dib-run-parts b/elements/dib-run-parts/root.d/90-base-dib-run-parts index fe4ca43dd..eec2c50d2 100755 --- a/elements/dib-run-parts/root.d/90-base-dib-run-parts +++ b/elements/dib-run-parts/root.d/90-base-dib-run-parts @@ -1,5 +1,6 @@ #!/bin/bash + home=$(dirname $0) exec sudo install -m 0755 -o root -g root -D \ - $home/dib-run-parts \ + $home/../bin/dib-run-parts \ $TARGET_ROOT/usr/local/bin/dib-run-parts diff --git a/lib/common-defaults b/lib/common-defaults index ff06fe781..6fb8eaf75 100644 --- a/lib/common-defaults +++ b/lib/common-defaults @@ -40,3 +40,10 @@ _BASE_ELEMENT_DIR=$(dirname $0)/../elements ELEMENTS_PATH=${ELEMENTS_PATH:+"$ELEMENTS_PATH:$_BASE_ELEMENT_DIR"} export ELEMENTS_PATH=${ELEMENTS_PATH:-$_BASE_ELEMENT_DIR} export DIB_OFFLINE=${DIB_OFFLINE:-''} + +# /sbin and friends aren't automatically included in $PATH when running sudo +# on SUSE Linux which breaks various pieces of this script in exciting ways, +# so inject them into the current $PATH if they're not there. +if ! [[ "$PATH" =~ "/sbin" ]] ; then + export PATH=$PATH:/sbin:/usr/sbin:/usr/local/sbin +fi diff --git a/lib/common-functions b/lib/common-functions index c6382d245..f80d5f42a 100644 --- a/lib/common-functions +++ b/lib/common-functions @@ -155,7 +155,7 @@ function run_d() { check_element check_break before-$1 bash if [ -d ${TMP_HOOKS_PATH}/$1.d ] ; then - run-parts ${TMP_HOOKS_PATH}/$1.d + ${SCRIPT_HOME}/dib-run-parts ${TMP_HOOKS_PATH}/$1.d fi check_break after-$1 bash }