-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathdeploy.sh
99 lines (86 loc) · 3.11 KB
/
deploy.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
#!/bin/bash
if [ "$#" -ne 12 ]; then
echo "USAGE:"
echo "bash deploy.sh -bak [0/1] -web [0/1] -api [0/1] -pred [0/1] -rsc [0/1] -docker [0/1]"
exit 1
fi
SERVER=ijah@172.18.31.115
WEB_DIR=/home/ijah/ijah/web
WEB_DIR_STR='/home/ijah/ijah/web'
PREDICTOR_DIR=/home/ijah/ijah-predictor/python
BACKUP_DIR_STR='/home/ijah/ijah-backup/ijah-web-backup_'
echo "### MAKE PROD CONFIG ####################################################"
cd config
. make_config.sh prod
cd ..
# backup
if [ $2 -ne 0 ]; then
echo "#######################################################################"
# echo "backing up _web_ only ..."
# stamp=`date +%Y-%m-%d-%H-%M-%S`
# copyCMD='cp -r'
# cmd=$copyCMD' '$WEB_DIR_STR' '$BACKUP_DIR_STR$stamp
# ssh $SERVER $cmd
#
# rmCMD='rm -rf'
# arg1=$WEB_DIR_STR'/main.*.bundle.js '
# arg2=$WEB_DIR_STR'/polyfills.*.bundle.js '
# arg3=$WEB_DIR_STR'/vendor.*.bundle.js '
# arg4=$WEB_DIR_STR'/main.*.bundle.map '
# arg5=$WEB_DIR_STR'/main.*.css '
# cmd2=$rmCMD' '$arg1$arg2$arg3$arg4$arg5
# ssh $SERVER $cmd2
fi
# web: build the src in production stage
if [ $4 -ne 0 ]; then
echo "### WEB ###############################################################"
echo "building webserver..."
cd webserver
ng build --dev # ng build --prod
cd ..
echo "deploying webserver..."
rsync -r webserver/dist/* $SERVER:$WEB_DIR
fi
# api
if [ $6 -ne 0 ]; then
echo "#### API ##############################################################"
echo "deploying APIs ..."
rsync -avP webserver/api/* $SERVER:$WEB_DIR/api
# scp -r api_upload/* $SERVER:/home/ijah/node_api_docker/api_upload/
fi
# predictor
if [ $8 -ne 0 ]; then
echo "#######################################################################"
echo 'Have you set the _DBlink_ at config/credential.py? [0/1]'
read predictorConfigSet
if [ "$predictorConfigSet" -ne 0 ]; then
echo "deploying predictors ..."
find ../predictor/ -name "*.pyc" -type f -delete
scp -r ../predictor/ $SERVER:$PREDICTOR_DIR
find ../utility/ -name "*.pyc" -type f -delete
scp -r ../utility/ $SERVER:$PREDICTOR_DIR
find ../config/ -name "*.pyc" -type f -delete
scp -r ../config/ $SERVER:$PREDICTOR_DIR
fi
fi
# resource
if [ ${10} -ne 0 ]; then
echo "### RSC ###############################################################"
echo "deploying resource files ..."
IJAH_MANUAL_ID=ijah_webserver_manual_id.pdf
cp manual/manual-id/out/$IJAH_MANUAL_ID rsc/$IJAH_MANUAL_ID
scp -r rsc/* $SERVER:$WEB_DIR/rsc
fi
# docker
if [ ${12} -ne 0 ]; then
echo "### DOCKER ############################################################"
echo "deploying docker files ..."
scp ../docker/sh/start.sh ../docker/sh/stop.sh $SERVER:/home/ijah/
scp ../docker/dockerfile/nodeapiDockerfile ../docker/sh/node_api_start_stop.sh ../docker/sh/node_api_build.sh $SERVER:/home/ijah/node_api_docker/
# scp ../docker/dockerfile/webDockerfile $SERVER:/home/ijah/ijah/
# scp ../docker/dockerfile/predictorDockerfile $SERVER:/home/ijah/ijah-predictor
fi
echo "### MAKE DEV CONFIG: "$SERVER" ##########################################"
cd config
. make_config.sh dev
cd ..