-
-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add project-specific startup script support (e.g. for cron configurat…
…ion) Allow user to add *.sh files to `$HOST_PATH_HTTPD_DATADIR/*/.devilbox/autostart` which will then be executed on startup of the php container.
- Loading branch information
1 parent
06cb912
commit 06b3a94
Showing
2 changed files
with
61 additions
and
0 deletions.
There are no files selected for viewing
55 changes: 55 additions & 0 deletions
55
Dockerfiles/prod/data/docker-entrypoint.d/311-project-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,55 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
set -u | ||
set -o pipefail | ||
|
||
|
||
############################################################ | ||
# Functions | ||
############################################################ | ||
|
||
### | ||
### Execute project-supplied scripts | ||
### | ||
execute_project_scripts() { | ||
local debug="${1}" | ||
local project | ||
local script_dir | ||
local script_name | ||
|
||
for project_dir in /shared/httpd/*; do | ||
|
||
script_dir=${project_dir}/.devilbox/autostart | ||
|
||
if [ -d "${project_dir}" ] && [ -d "${script_dir}" ]; then | ||
|
||
project=$(basename "${project_dir}") | ||
|
||
script_files="$(find -L "${script_dir}" -type f -iname '*.sh' | sort -n)" | ||
|
||
# loop over them line by line | ||
IFS=' | ||
' | ||
for script_f in ${script_files}; do | ||
|
||
script_name="$(basename "${script_f}")" | ||
|
||
log "info" "Executing project startup script: ${project}:${script_name}" "${debug}" | ||
|
||
if ! bash "${script_f}" "${debug}"; then | ||
log "err" "Failed to execute script" "${debug}" | ||
exit 1 | ||
fi | ||
|
||
done | ||
fi | ||
done | ||
} | ||
|
||
|
||
############################################################ | ||
# Sanity Checks | ||
############################################################ | ||
|
||
# find, sort, and basename are already checked in ./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