-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdev-start.sh
executable file
·117 lines (97 loc) · 2.33 KB
/
dev-start.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
117
#!/usr/bin/env bash
set -e
green='\x1B[0;32m'
red='\x1B[0;31m'
plain='\x1B[0m' # No Color
IS_DEBUG=false
for arg in "$@"
do
if [ "$arg" == "--debug" ]; then
IS_DEBUG=true
shift
fi
done
isInstalled() {
hash "$1" 2>/dev/null
}
checkRequirement() {
if ! isInstalled $1; then
echo -e "${red}[MISSING DEPENDENCY] $1 not found. Please install $1${plain}"
exit 1
fi
}
checkRequirements() {
# server side
checkRequirement java
checkRequirement sbt
# client side
checkRequirement npm
# elasticsearch and imgops (image resizer)
checkRequirement docker
# image libraries
checkRequirement gm # GraphicsMagick
checkRequirement magick #ImageMagick
checkRequirement convert
checkRequirement pngquant
checkRequirement exiftool
# other
checkRequirement nginx
checkRequirement jq
checkRequirement aws
}
setupImgops() {
if [ ! -f ./imgops/dev/nginx.conf ]; then
bucket=`bash get-stack-resource.sh ImageBucket`
if [ -z "$bucket" ]; then
echo -e "${red}[CANNOT GET ImageBucket] This may be because your default region for the media-service profile has not been set.${plain}"
exit 1
fi
sed -e 's/{{BUCKET}}/'${bucket}'/g' ./imgops/dev/nginx.conf.template > ./imgops/dev/nginx.conf
fi
}
startDockerContainers() {
docker-compose up -d
}
buildJs() {
pushd kahuna
npm install
npm run build-dev
popd
}
startPlayApps() {
if [ "$IS_DEBUG" = true ] ; then
sbt -jvm-debug 5005 runAll
else
sbt runAll
fi
}
# We use auth.properties as a proxy for whether all the configuration files have been downloaded given the implementation of `fetchConfig.sh`.
downloadApplicationConfig() {
if [ ! -f /etc/gu/auth.properties ]; then
bash ./fetch-config.sh
fi
}
fileExists() {
test -e "$1"
}
changeNodeVersion() {
if ! fileExists "$NVM_DIR/nvm.sh"; then
node_version=`cat .nvmrc`
echo -e "${red}nvm not found ${plain} NVM is required to run this project"
echo -e "Install it from https://github.com/creationix/nvm#installation"
exit 1
else
source "$NVM_DIR/nvm.sh"
nvm install
fi
}
main() {
checkRequirements
changeNodeVersion
setupImgops
downloadApplicationConfig
startDockerContainers
buildJs
startPlayApps
}
main