-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy.sh.leonard
84 lines (67 loc) · 1.62 KB
/
deploy.sh.leonard
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
#!/bin/bash
#
## Initial variables
#
PROJECT_ROOT_PATH=`cd $(dirname $BASH_SOURCE); pwd`
HOST_NAME=""
PRIVATE_KEY=""
ERPNEXT_INITIAL_SETUP=false
MONGODB_INITIAL_SETUP=false
NEXTACTION_SETUP=false
#
## Reset in case getopts has been used previously in the shell
#
OPTIND=1
while getopts "h:i:emn" opt; do
case "$opt" in
h )
HOST_NAME="$OPTARG"
;;
i )
PRIVATE_KEY="$OPTARG"
;;
e )
ERPNEXT_INITIAL_SETUP=true
;;
m )
MONGODB_INITIAL_SETUP=true
;;
n )
NEXTACTION_SETUP=true
;;
esac
done
erpnext_initial_setup() {
ssh -i $PRIVATE_KEY root@$HOST_NAME /bin/bash -c "'
docker rm -f erpdata erpnext &> /dev/null
docker create -v /home/frappe/frappe-bench/sites/site1.local/ -v /var/lib/mysql --name erpdata davidgu/erpnext
docker run -d -p 3000:80 --name erpnext --volumes-from erpdata davidgu/erpnext
'"
}
mongodb_initial_setup() {
ssh -i $PRIVATE_KEY root@$HOST_NAME /bin/bash -c "'
rm -rf /opt/mongo_data &> /dev/null
mkdir /opt/mongo_data &> /dev/null
docker rm -f mongo &> /dev/null
docker run -d -p 27017:27017 --name mongo -v /opt/mongo_data:/data/db mongo
'"
}
nextaction_setup() {
ssh -i $PRIVATE_KEY root@$HOST_NAME /bin/bash -c "'
docker rm -f nextaction &> /dev/null
'"
mupx setup
mupx deploy
ssh -i $PRIVATE_KEY root@$HOST_NAME /bin/bash -c "'
rm -rf /opt/mongodb &> /dev/null
'"
}
if [[ "$ERPNEXT_INITIAL_SETUP" = true ]]; then
erpnext_initial_setup
fi
if [[ "$MONGODB_INITIAL_SETUP" = true ]]; then
mongodb_initial_setup
fi
if [[ "$NEXTACTION_SETUP" = true ]]; then
nextaction_setup
fi