-
-
Notifications
You must be signed in to change notification settings - Fork 90
Expand file tree
/
Copy path310-custom-startup-scripts.sh
More file actions
executable file
·53 lines (44 loc) · 1.18 KB
/
310-custom-startup-scripts.sh
File metadata and controls
executable file
·53 lines (44 loc) · 1.18 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
#!/usr/bin/env bash
set -e
set -u
set -o pipefail
############################################################
# Functions
############################################################
###
### Execute custom user-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 -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 custom startup script: ${script_name}" "${debug}"
if ! bash "${script_f}" "${debug}"; 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 sort >/dev/null 2>&1; then
echo "sort 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