-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.sh
More file actions
executable file
·67 lines (59 loc) · 1.49 KB
/
run.sh
File metadata and controls
executable file
·67 lines (59 loc) · 1.49 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
60
61
62
63
64
65
66
67
#!/usr/bin/env bash
#
# Author: mail _^_ AT _^_ wangbo _^_ im
#
#
# Enable strict bash mode
set -euo pipefail
IFS=$'\t\n'
LOG_LEVEL="${LOG_LEVEL:-WARN}"
export LOG_LEVEL
#
# Dirs
SCRIPT_FILE_PATH=`realpath $0`
SCRIPT_DIR_PATH=`dirname "${SCRIPT_FILE_PATH}"`
MAIN_SCRIPT_PATH="${SCRIPT_DIR_PATH}/main.script"
# source common config
for each_i in "${SCRIPT_DIR_PATH}"/include.*.conf; do
if [ -f "$each_i" ]; then . "$each_i"; fi
done
__usage() {
__warn ""
__warn "Usage: ${SCRIPT_FILE_PATH##*/} COMMAND PATH_TO_TARGET_PROJECT_DIR"
__warn ""
__warn -e "\twhere COMMAND is one command listing here:"
__warn -e "\t\tstart stop restart status"
__warn -e "\t PATH_TO_TARGET_PROJECT_DIR is a symlink to or a directory for target project"
__warn ""
}
if [ $# -eq 2 ]; then
d="$2"
d="${d%%/}/"
if [ -d "$d" ]; then
case "$1" in
"run"|"start"|"stop"|"check"|"status")
bash "$MAIN_SCRIPT_PATH" "$d" "$1"
;;
"restart")
bash "$MAIN_SCRIPT_PATH" "$d" stop start
;;
"help")
__usage
;;
*)
__fatal "Unknown command \"$1\""
__usage
exit 1
;;
esac
else
__fatal "Project directory \"$d\" not exists"
__usage
exit 1
fi
else
__fatal "Incorrect number of arguments"
__usage
exit 1
fi
# vim:set nu rnu list et sr ts=4 sw=4 ft=sh: