forked from cloudfoundry/bosh-io-web
-
Notifications
You must be signed in to change notification settings - Fork 0
/
push-cf.sh
executable file
·66 lines (51 loc) · 1.68 KB
/
push-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
#!/bin/bash
set -e
# Application names
old=bosh-hub-old
new=bosh-hub-new
curr=bosh-hub
if [ ! -f prod-conf/web.json ]; then
echo 'Missing web.json config'
exit 1
fi
./build.sh
echo "Generating new assets ID"
echo `date|md5` > ./prod-conf/assets-id
echo "Generate new private token outside of ./public"
echo $(LC_CTYPE=C tr -dc A-Za-z0-9 < /dev/urandom | fold -w ${1:-32} | head -n 1) > ./prod-conf/private-token
echo "Pushing to cf"
if cf app $new; then echo "$new must not exist"; exit 1; fi
if cf app $old; then echo "$old must not exist"; exit 1; fi
echo "Pushing new version"
cf push $new -i 2 -k 2G -b https://github.com/ddollar/heroku-buildpack-multi.git
rm -f ./prod-conf/assets-id ./prod-conf/private-token
read -p "Map routes to new version (y/n)? " CONT
if [ "$CONT" != "y" ]; then
echo "Exiting. $new is running. Delete before redeploying."
exit 1
fi
echo "Mapping routes to new version"
cf unmap-route $new cfapps.io -n $new
cf map-route $new cfapps.io -n $curr
cf map-route $new cfapps.io -n bosh
cf map-route $new cloudfoundry.org -n bosh
cf map-route $new bosh.io -n www
cf map-route $new bosh.io
echo "Swapping version: current->old"
cf rename $curr $old
echo "Unmapping routes from old version"
cf map-route $old cfapps.io -n $old
cf unmap-route $old cfapps.io -n $curr
cf unmap-route $old cfapps.io -n bosh
cf unmap-route $old cloudfoundry.org -n bosh
cf unmap-route $old bosh.io -n www
cf unmap-route $old bosh.io
echo "Swapping version: current->old, new->current"
cf rename $new $curr
read -p "Delete old version (y/n) ? " CONT
if [ "$CONT" != "y" ]; then
echo "Exiting. $old is running. Delete before redeploying."
exit 1
fi
echo "Deleting old version"
cf delete $old