-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.sh
executable file
·44 lines (36 loc) · 855 Bytes
/
run.sh
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
#!/usr/bin/env bash
# Modules runner script
# Stop on failure
set -e
# uncomment for DEBUG
#set -x
# Set Internal Field Separator
IFS=$'\n'
# Init _Core
declare -rg PRELOAD_DIR="$( dirname "${BASH_SOURCE[0]}" )/_Core/PreLoad"
if [[ ! -d "$PRELOAD_DIR" ]]; then
echo "No files to source at: $PRELOAD_DIR"
exit 255
else
for f in "$PRELOAD_DIR"/*.sh; do
source $f || ( echo "Cannot source: $f" && exit 255 )
done
fi
# Include the Framework
includeAllRecursive _Core/Framework
# Check the param
cd "$SCRIPT_ROOT"
checkParam "$1" "Module name"
if [[ -f "$1" ]]; then
declare -rg MODULE_FILE="$1"
elif [[ -f "$1.sh" ]]; then
declare -rg MODULE_FILE="$1.sh"
else
echo "$1 not found!"
exit $ERROR_FILE
fi
# Set real module name
declare -rg MODULE_NAME=${MODULE_FILE::-3}
# Run the module
shift
. ./"$MODULE_FILE"