This repository has been archived by the owner on Jul 20, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathbuild.sh
executable file
·139 lines (127 loc) · 4.12 KB
/
build.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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
#!/bin/bash
set -x
DEFAULT_AUTOSCALER_CLIENT_SCOPE="cloud_controller.read,cloud_controller.write,uaa.resource,openid,doppler.firehose,scim.read,cloud_controller.admin"
function usage() {
echo "Usage: $0 [options], example: $0 -ac autoscaler_client_id -as autoscaler_client_secret "
echo "Options:"
echo " -cd - cf domain"
echo " -cu - cf user"
echo " -cp - cf password"
echo " -co - cf org"
echo " -cs - cf space"
echo " -ac - autoscaler_client_id"
echo " -as - autoscaler_client_secret"
echo " -aso - autoscaler_client_scope"
echo " -curls - console urls"
echo " -host - scalerui host name"
exit 1
}
function parse_command_line()
{
while [ $# -gt 0 ]; do
OPTION=$1;
shift
case ${OPTION} in
-h)
usage
exit 1
;;
-cd)
CF_DOMAIN=$1; shift
;;
-cu)
CF_USER=$1; shift
;;
-cp)
CF_PASSWORD=$1; shift
;;
-co)
CF_ORG=$1; shift
;;
-cs)
CF_SPACE=$1; shift
;;
-ac)
AUTOSCALER_CLIENT_ID=$1; shift
;;
-as)
AUTOSCALER_CLIENT_SECRET=$1; shift
;;
-aso)
AUTOSCALER_CLIENT_SCOPE=$1; shift
;;
-host)
SCALERUI_HOST=$1; shift
;;
-curls)
CONSOLE_URLS=$1; shift
;;
*)
echo "ERROR: Invalid argument $OPTION"; usage; exit 1
;;
esac
done
# check parameters provided
if [ -z "$CF_DOMAIN" ]; then
echo "ERROR: CF_DOMAIN has not been specified."; usage; exit 1
fi
if [ -z "$CF_USER" ]; then
echo "ERROR: CF_USER has not been specified."; usage; exit 1
fi
if [ -z "$CF_PASSWORD" ]; then
echo "ERROR: CF_PASSWORD has not been specified."; usage; exit 1
fi
if [ -z "$CF_ORG" ]; then
echo "ERROR: CF_ORG has not been specified."; usage; exit 1
fi
if [ -z "$CF_SPACE" ]; then
echo "ERROR: CF_SPACE has not been specified."; usage; exit 1
fi
if [ -z "$AUTOSCALER_CLIENT_ID" ]; then
echo "ERROR: AUTOSCALER_CLIENT_ID has not been specified."; usage; exit 1
fi
if [ -z "$AUTOSCALER_CLIENT_SECRET" ]; then
echo "ERROR: AUTOSCALER_CLIENT_SECRET has not been specified."; usage; exit 1
fi
if [ -z "$AUTOSCALER_CLIENT_SCOPE" ]; then
AUTOSCALER_CLIENT_SCOPE=${DEFAULT_AUTOSCALER_CLIENT_SCOPE}}
fi
if [ -z "$SCALERUI_HOST" ]; then
echo "ERROR: host name of scalerui has not been specified."; usage; exit 1
fi
if [ -z "$CONSOLE_URLS" ]; then
echo "ERROR: console urls have not been specified."; usage; exit 1
fi
}
parse_command_line "$@"
cd ..
## build go project
git pull && git submodule foreach --recursive git submodule sync && git submodule update --init --recursive
source .envrc
go build -o scalerui src/scalerui/cmd/ui/ui.go
chmod +x scalerui
zip -r -p scalerui.zip ./scalerui
## build nodejs project
cd view
npm install
# npm rebuild node-sass --force
npm run build
## produce config files
cd ../scripts
cat ./cf_app_config_template.yml \
| sed "s|<CONSOLE_URLS>|$CONSOLE_URLS|g" \
| sed "s/<CF_DOMAIN>/$CF_DOMAIN/g" \
| sed "s/<AUTOSCALER_CLIENT_ID>/$AUTOSCALER_CLIENT_ID/g" \
| sed "s/<AUTOSCALER_CLIENT_SECRET>/$AUTOSCALER_CLIENT_SECRET/g" \
| sed "s/<AUTOSCALER_CLIENT_SCOPE>/$AUTOSCALER_CLIENT_SCOPE/g" \
| sed "s/<SCALERUI_HOST>/$SCALERUI_HOST/g" > ../cf_app_config.yml
ruby ./yml2js.rb
cp ./config.js ../view/dev
cd ..
zip -r -p scalerui.zip ./cf_app_config.yml
zip -r -p scalerui.zip ./view/dev
## produce manifest
cat scripts/manifest_template.yml | sed "s/<CF_DOMAIN>/$CF_DOMAIN/g" | sed "s/<SCALERUI_HOST>/$SCALERUI_HOST/g" > manifest.yml
## login and push
cf login -a https://api.${CF_DOMAIN} -u ${CF_USER} -p ${CF_PASSWORD} -o ${CF_ORG} -s ${CF_SPACE} --skip-ssl-validation
cf push