-
-
Notifications
You must be signed in to change notification settings - Fork 90
Expand file tree
/
Copy path311-project-startup-scripts.sh
More file actions
59 lines (43 loc) · 1.55 KB
/
311-project-startup-scripts.sh
File metadata and controls
59 lines (43 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/env bash
set -e
set -u
set -o pipefail
############################################################
# Functions
############################################################
###
### Execute project-supplied scripts
###
execute_project_scripts() {
local debug="${1}"
local script_dir
local script_name
local DEVILBOX_PROJECT_DIR
local DEVILBOX_PROJECT_NAME
local DEVILBOX_PROJECT_DOCROOT
for DEVILBOX_PROJECT_DIR in /shared/httpd/*; do
script_dir=${DEVILBOX_PROJECT_DIR}/$(env_get HTTPD_TEMPLATE_DIR ".devilbox")/autostart
if [ -d "${DEVILBOX_PROJECT_DIR}" ] && [ -d "${script_dir}" ]; then
DEVILBOX_PROJECT_NAME=$(basename "${DEVILBOX_PROJECT_DIR}")
export DEVILBOX_PROJECT_NAME
DEVILBOX_PROJECT_DOCROOT=${DEVILBOX_PROJECT_DIR}/$(env_get HTTPD_DOCROOT_DIR "htdocs")
export DEVILBOX_PROJECT_DOCROOT
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: ${DEVILBOX_PROJECT_NAME}:${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