-
Notifications
You must be signed in to change notification settings - Fork 1
/
launch
executable file
·64 lines (54 loc) · 1.57 KB
/
launch
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
60
61
62
63
64
#!/usr/bin/env bash
# Trace what's being executed (useful for debug)
# set -o xtrace
# Exit on error
set -o errexit
# Exit on unset variables
set -o nounset
# Catch the error code of the program who crashed in piping commands
set -o pipefail
declare -r __ROOT_PATH__="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
declare -r __BASE__="$(basename "${BASH_SOURCE[0]}")"
declare -r __FILE__="${__ROOT_PATH__}/${__BASE__}"
declare -r __BUILD_SYSTEM_PATH__="${__ROOT_PATH__}/build-system"
declare -r __OPTIONS__=$*
declare __LOG_LEVEL__="ERROR"
declare -r COMPONENTS_LIST_FILE="${__ROOT_PATH__}/components"
declare __ACTION__=""
declare __ARE_OPTIONS_CORRECT__="no"
### Libraries
source ${__BUILD_SYSTEM_PATH__}/utils.sh
source ${__BUILD_SYSTEM_PATH__}/launch.sh
for ARG in $*
do
case ${ARG} in
"-v"|"--verbose")
declare __LOG_LEVEL__="INFO"
;;
"-d"|"--debug")
declare __LOG_LEVEL__="DEBUG"
;;
"start"|"stop"|"restart")
declare __ACTION__="${ARG}"
declare __ARE_OPTIONS_CORRECT__="yes"
;;
*)
customlog "ERROR" "\`${ARG}' is not parsed by \`${__BASE__}' script." ${ERROR_ARGS}
;;
esac
done
if [ "${__ARE_OPTIONS_CORRECT__}" == "no" ]
then
customlog "ERROR" "usage: ${__BASE__} [-v|-d] start|stop|restart" ${ERROR_ARGS}
fi
cat ${COMPONENTS_LIST_FILE} | while read COMPONENT_NAME
do
echo ${COMPONENT_NAME} | grep -q '^#' && continue;
if iscomponent ${COMPONENT_NAME}
then
launch "${COMPONENT_NAME}" ${__ACTION__}
else
customlog "ERROR" "The list in \`.components' contains at least one non-existing component." ${ERROR_COMPONENTS}
fi
done
exit ${SUCCESS}