-
Notifications
You must be signed in to change notification settings - Fork 65
/
cf.sh
executable file
·103 lines (82 loc) · 1.96 KB
/
cf.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
#!/bin/bash
set -e
#
# the big CloudFoundry installer
#
CLOUD_DOMAIN=${DOMAIN:-run.pivotal.io}
CLOUD_TARGET=api.${DOMAIN}
function login(){
cf api | grep ${CLOUD_TARGET} || cf api ${CLOUD_TARGET} --skip-ssl-validation
cf a | grep OK || cf login
}
function app_domain(){
D=`cf apps | grep $1 | tr -s ' ' | cut -d' ' -f 6 | cut -d, -f1`
echo $D
}
function deploy_app(){
# common to all nodes
cf cs cloudamqp tiger doge-rabbitmq
APP_NAME=$1
cd $APP_NAME
cf push $APP_NAME --no-start
APPLICATION_DOMAIN=`app_domain $APP_NAME`
echo determined that application_domain for $APP_NAME is $APPLICATION_DOMAIN.
cf env $APP_NAME | grep APPLICATION_DOMAIN || cf set-env $APP_NAME APPLICATION_DOMAIN $APPLICATION_DOMAIN
cf restart $APP_NAME
cd ..
}
function deploy_service(){
N=$1
D=`app_domain $N`
JSON='{"uri":"http://'$D'"}'
echo cf cups $N -p $JSON
cf cups $N -p $JSON
}
function deploy_eureka() {
NAME=eureka-service
deploy_app $NAME
deploy_service $NAME
}
function deploy_config(){
NAME=config-service
deploy_app $NAME
deploy_service $NAME
}
function deploy_doge(){
cf cs mongolab sandbox doge-mongo
deploy_app doge-service
}
function deploy_account(){
cf cs elephantsql turtle doge-postgresql
deploy_app account-service
}
function deploy_hystrix(){
deploy_app hystrix-service
}
function deploy_webapp(){
deploy_app webapp
}
function reset(){
cf d config-service
cf d eureka-service
cf d doge-service
cf d account-service
cf d hystrix-service
cf d webapp
cf ds config-service
cf ds eureka-service
cf delete-orphaned-routes
}
### INSTALLATION STEPS
### feel free to comment out all the steps that you don't need
### and selectively uncomment them if the script in total encounters
### IO errors and such.
mvn -DskipTests=true clean install
login
reset
deploy_config
deploy_eureka
deploy_doge
deploy_account
deploy_hystrix
deploy_webapp