-
Notifications
You must be signed in to change notification settings - Fork 97
/
cf.sh
executable file
·79 lines (65 loc) · 1.62 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
#!/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(){
APP_NAME=$1
cd $APP_NAME
cf push $APP_NAME --no-start -b https://github.com/cloudfoundry/java-buildpack.git
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_photo_service(){
cf cs mongolab sandbox photo-service-mongodb
deploy_app photo-service
}
function deploy_bookmark_service(){
cf cs elephantsql turtle bookmark-service-postgresql
deploy_app bookmark-service
}
function deploy_passport_service(){
deploy_app passport-service
}
function reset(){
cf d eureka-service
cf d photo-service
cf d passport-service
cf d bookmark-service
cf ds photo-service-mongodb
cf ds bookmark-service-postgresql
cf ds eureka-service
cf delete-orphaned-routes
}
mvn -DskipTests=true clean install
login
reset
deploy_eureka
deploy_photo_service
deploy_bookmark_service
deploy_passport_service