-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
116 lines (97 loc) · 3.19 KB
/
install.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#!/usr/bin/env bash
# echo "Your script args ($#) are: $@"
# Enable xtrace if the DEBUG environment variable is set
if [[ ${DEBUG-} =~ ^1|yes|true$ ]]; then
set -o xtrace # Trace the execution of the script (debug)
fi
# A better class of script...
# set -o errexit # Exit on most errors (see the manual)
set -o errtrace # Make sure any error trap is inherited
# set -o nounset # Disallow expansion of unset variables
set -o pipefail # Use last non-zero exit code in a pipeline
# null value in array
shopt -s nullglob
# Reset
NC="\033[0m" # Text Reset
# Regular Colors
BLACK="\033[0;30m" # Black
RED="\033[0;31m" # Red
REDB="\033[1;41m" # BoldRedBack
GREEN="\033[0;32m" # Green
BGREEN="\033[1;32m" # Green
YELLOW="\033[0;33m" # Yellow
BLUE="\033[0;34m" # Blue
PURPLE="\033[0;35m" # Purple
CYAN="\033[0;36m" # Cyan
BCYAN="\033[1;36m" # Cyan
BWHITE="\033[1;97m" # White
WHITE="\033[0;97m" # White
LWHITE="\033[1;30m" # White
BYELLOW="\e[30;48;5;82m" # Yellow
BORANGE="\e[38;5;208m" # Orange
BUNLINE="\e[1;4m"
BGRAY="\e[0;90m"
BLBACK="\e[30;48;5;81m"
git --version 2>&1 >/dev/null
GIT_IS_AVAILABLE=$?
function errcho() {
>&2 echo -e "${RED}$@${NC}";
}
function usage() {
echo -e "${BWHITE}install ${CYAN}dockAPEX${NC}${BWHITE}]${NC} - prepare instance folder and download dockapex as submodul "
# Tree chars └ ─ ├ ─ │
echo
echo -e "${BWHITE}USAGE${NC}"
echo -e " ${0} \"instance folder\""
echo
echo -e "${BWHITE}Examples:${NC}"
echo -e " ${0} demo"
echo
echo
exit $1
}
if [[ $GIT_IS_AVAILABLE > 0 ]]; then
errcho ""
errcho " ⚠ Please install git before running this command."
errcho ""
exit 1
fi
TARGET_PATH=.
if [[ $# > 0 ]]; then
if [[ $# > 1 ]]; then
errcho ""
errcho " ⚠ Too many arguments. Make sure you use just one argument when you want to create a new folder or install dpex in this one."
errcho ""
exit 2
fi
TARGET_PATH=${1}
fi
echo -e "${CYAN}Installing docAPEX in Folder: ${TARGET_PATH}${NC}"
if [[ ! -d "${TARGET_PATH}" ]]; then
mkdir -p "${TARGET_PATH}"
fi
cd "${TARGET_PATH}"
# init your project with git
if [[ ! -d ".git" ]]; then
echo -e "${CYAN}Initializing git${NC}"
git init
echo
fi
echo -e "${CYAN}clone dockAPEX as submodule${NC}"
git submodule add https://github.com/MaikMichel/dockAPEX.git .dockAPEX
echo
echo -e "${CYAN}dockAPEX installed in Folder: ${BUNLINE}${TARGET_PATH}/.dockAPEX${NC}"
echo
if [[ ${TARGET_PATH} != "." ]]; then
echo -e "${CYAN}Before you start to work, you have to go to your instance folder ${BUNLINE}${TARGET_PATH}${NC}"
echo -e "${BWHITE}${BUNLINE}cd ${TARGET_PATH}${NC}"
echo
fi
echo -e "${BGRAY}to generate environmen file call:${NC}"
echo -e "${WHITE}.dockAPEX/dpex.sh ${TARGET_PATH}.env genfiles${NC}"
echo -e ""
echo -e "${BGRAY}edit configuration parameters in files ${TARGET_PATH}.env and ${TARGET_PATH}.sec${NC}"
echo -e "${BGRAY}run the stack${NC}"
echo -e "${WHITE}.dockAPEX/dpex.sh ${TARGET_PATH}.env up --build --detach${NC}"
echo -e ""
echo -e "${BORANGE}To learn more, see the readme: ${BUNLINE}${TARGET_PATH}/.dockAPEX/readme.md${NC}"