Skip to content

Run custom hooks in entrypoint for non empty directories #2094

@d0niek

Description

@d0niek

Hi all!

You allow to run custom script via hooks here.

First you're looking for any files in hook directory:

if [ -z "$(ls -A "${hook_folder_path}")" ]; then

Then you iterate over *.sh files:

for script_file_path in "${hook_folder_path}/"*.sh; do

The problem is when hook directory contains some file(s) which don't have *.sh extension. if condition pass but for loop will give an one empty file and this will create an issue:

nextcloud_1  | => Searching for scripts (*.sh) to run, located in the folder: /docker-entrypoint-hooks.d/pre-upgrade
nextcloud_1  | ==> Running the script (cwd: /var/www/html): "/docker-entrypoint-hooks.d/pre-upgrade/*.sh"
nextcloud_1  | sh: 1: /docker-entrypoint-hooks.d/pre-upgrade/*.sh: not found
nextcloud_1  | ==> Failed at executing "/docker-entrypoint-hooks.d/pre-upgrade/*.sh". Exit code: 127

Here is my little hack to omit this. Create empty.sh file.

I think you should change ls -A ${hook_folder_path} with find ${hook_folder_path} -name "*.sh"

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions