-
-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow for custom user-supplied startup scripts
- Loading branch information
Showing
4 changed files
with
67 additions
and
1 deletion.
There are no files selected for viewing
49 changes: 49 additions & 0 deletions
49
Dockerfiles/prod/data/docker-entrypoint.d/310-custom-startup-scripts.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
set -u | ||
set -o pipefail | ||
|
||
|
||
############################################################ | ||
# Functions | ||
############################################################ | ||
|
||
### | ||
### Execute custom uesr-supplied scripts | ||
### | ||
execute_custom_scripts() { | ||
local script_dir="${1}" | ||
local debug="${2}" | ||
|
||
if [ ! -d "${script_dir}" ]; then | ||
run "mkdir -p ${script_dir}" "${debug}" | ||
fi | ||
script_files="$( find "${script_dir}" -type f -iname '*.sh' )" | ||
|
||
# loop over them line by line | ||
IFS=' | ||
' | ||
for script_f in ${script_files}; do | ||
script_name="$( basename "${script_f}" )" | ||
log "info" "Executing custom startup script: ${script_name}" "${debug}" | ||
if ! bash "${script_f}"; then | ||
log "err" "Failed to execute script" "${debug}" | ||
exit 1 | ||
fi | ||
done | ||
} | ||
|
||
|
||
############################################################ | ||
# Sanity Checks | ||
############################################################ | ||
|
||
if ! command -v find >/dev/null 2>&1; then | ||
echo "find not found, but required." | ||
exit 1 | ||
fi | ||
if ! command -v basename >/dev/null 2>&1; then | ||
echo "basename not found, but required." | ||
exit 1 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters