Skip to content

Commit

Permalink
change from using find to using a for-loop to located the .sh files
Browse files Browse the repository at this point in the history
Signed-off-by: Dennis Vestergaard Værum <github@varum.dk>
  • Loading branch information
dvaerum authored and J0WI committed Jun 13, 2023
1 parent a31036f commit e9e834b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ To use the hooks triggered by the `entrypoint` script, either
- Added your script(s) to the individual of the hook folder(s), which are located at the path `/docker-entrypoint-hooks.d` in the container
- Use volume(s) if you want to use script from the host system inside the container, see example.

**Note:** Only the script(s) ending with `.sh` and marked as executable will be executed.
**Note:** Only the script(s) located in a hook folder (not sub-folders), ending with `.sh` and marked as executable, will be executed.

**Example:** Mount using volumes
```yaml
Expand Down
5 changes: 2 additions & 3 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,13 @@ run_path() {
echo "=> Searching for scripts (*.sh) to run in the folder: ${hook_folder_path}"

(
cd "${hook_folder_path}"
find . -type f -iname '*.sh' -print | sort | while read script_file_path; do
for script_file_path in "${hook_folder_path}/"*.sh; do
if ! [ -x "${script_file_path}" ] && [ -f "${script_file_path}" ]; then
echo "==> The script \"${script_file_path}\" in the folder \"${hook_folder_path}\" was skipping, because it didn't have the executable flag"
continue
fi

echo "==> Running the script: \"${script_file_path}\""
echo "==> Running the script (cwd: $(pwd)): \"${script_file_path}\""

run_as "${script_file_path}" || return_code="$?"

Expand Down

0 comments on commit e9e834b

Please sign in to comment.