-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·34 lines (25 loc) · 993 Bytes
/
install.sh
File metadata and controls
executable file
·34 lines (25 loc) · 993 Bytes
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
#!/bin/bash
set -e
cd $(dirname "$0")
source .env
SSL_DIR=$NGINX_DIR/conf.d/ssl
for dir in "$NGINX_DIR" "$SSL_DIR" "$ES_DATA_DIR"; do
test -d $dir && echo "$dir already exist"
done
mkdir -p {$NGINX_DIR,$SSL_DIR,$ES_DATA_DIR}
if [[ "yes" == $USE_EXISTENT_CERTIFICATE ]]; then
cp {$CRT_PATH,$KEY_PATH} $SSL_DIR
else
CRT_PATH=$SSL_DIR/nginx_es_api_ss.crt
KEY_PATH=$SSL_DIR/nginx_es_api_ss.key
openssl req -x509 -nodes -days $CRT_EXPIRE -batch -newkey rsa:2048 -keyout $KEY_PATH -out $CRT_PATH
fi
cp nginx.conf.default nginx.conf
CRT_PATH=/etc/nginx/conf.d/ssl/$(echo $CRT_PATH | awk -F/ '{print $NF}')
KEY_PATH=/etc/nginx/conf.d/ssl/$(echo $KEY_PATH | awk -F/ '{print $NF}')
sed -i "s/%CRT_PATH%/$(echo $CRT_PATH | sed 's/\//\\\//g')/" nginx.conf
sed -i "s/%KEY_PATH%/$(echo $KEY_PATH | sed 's/\//\\\//g')/" nginx.conf
sed -i "s/%API_SERVER_NAME%/$API_SERVER_NAME/" nginx.conf
sed -i "s/%API_PORT%/$API_PORT/" nginx.conf
mv nginx.conf $NGINX_DIR
docker-compose up -d