mirror of
https://github.com/nextcloud/docker.git
synced 2025-04-20 02:46:10 +02:00
Change the hook script (#1964) to be execute as root
Signed-off-by: AkashiSN <btorntireinvynriy@gmail.com>
This commit is contained in:
parent
7bd3b7b6db
commit
fe8e872120
2 changed files with 18 additions and 15 deletions
|
@ -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) located in a hook folder (not sub-folders), 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` will be executed.
|
||||
|
||||
**Example:** Mount using volumes
|
||||
```yaml
|
||||
|
|
|
@ -27,26 +27,29 @@ run_path() {
|
|||
echo "=> Searching for scripts (*.sh) to run, located in the folder: ${hook_folder_path}"
|
||||
|
||||
if [ -z "$(ls -A "${hook_folder_path}")" ]; then
|
||||
echo "==> but the hook folder \"$(basename "${hook_folder_path}")\" is empty, so nothing to do"
|
||||
echo "==> but the hook folder \"$(basename "${hook_folder_path}")\" is empty, so nothing to do"
|
||||
return 0
|
||||
fi
|
||||
|
||||
(
|
||||
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
|
||||
if [ -f "${script_file_path}" ]; then
|
||||
if [ -x "${script_file_path}" ]; then
|
||||
echo "==> Running the script \"${script_file_path}\" (cwd: $(pwd))."
|
||||
"${script_file_path}"
|
||||
return_code="$?"
|
||||
else
|
||||
echo "==> Found the script \"${script_file_path}\", but it didn't have the executable flag,"
|
||||
echo " So running the script as \`user=$user /bin/bash \"${script_file_path}\"\` (cwd: $(pwd))."
|
||||
user=$user /bin/bash "${script_file_path}"
|
||||
return_code="$?"
|
||||
fi
|
||||
|
||||
if [ "${return_code}" -ne "0" ]; then
|
||||
echo "==> Failed at executing \"${script_file_path}\". Exit code: ${return_code}."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "==> Running the script (cwd: $(pwd)): \"${script_file_path}\""
|
||||
|
||||
run_as "${script_file_path}" || return_code="$?"
|
||||
|
||||
if [ "${return_code}" -ne "0" ]; then
|
||||
echo "==> Failed at executing \"${script_file_path}\". Exit code: ${return_code}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "==> Finished the script: \"${script_file_path}\""
|
||||
done
|
||||
)
|
||||
|
|
Loading…
Add table
Reference in a new issue