-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathupload-installation-manager.sh
executable file
·162 lines (140 loc) · 7.86 KB
/
upload-installation-manager.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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
#!/bin/bash
#
# CODENVY CONFIDENTIAL
# ________________
#
# [2012] - [2015] Codenvy, S.A.
# All Rights Reserved.
# NOTICE: All information contained herein is, and remains
# the property of Codenvy S.A. and its suppliers,
# if any. The intellectual and technical concepts contained
# herein are proprietary to Codenvy S.A.
# and its suppliers and may be covered by U.S. and Foreign Patents,
# patents in process, and are protected by trade secret or copyright law.
# Dissemination of this information or reproduction of this material
# is strictly forbidden unless prior written permission is obtained
# from Codenvy S.A..
#
SERVER=$1
if [ "${SERVER}" == "prod" ]; then
echo "============[ Production will be updated ]=============="
SSH_KEY_NAME=~/.ssh/cl-server-prod-20130219
SSH_AS_USER_NAME=codenvy
AS_IP=updater.codenvycorp.com
elif [ "${SERVER}" == "stg" ]; then
echo "============[ Staging will be updated ]=============="
SSH_KEY_NAME=~/.ssh/as1-cldide_cl-server.skey
SSH_AS_USER_NAME=codenvy
AS_IP=updater.codenvy-stg.com
elif [ "${SERVER}" == "ngt" ]; then
echo "============[ Nightly will be updated ]=============="
SSH_KEY_NAME=~/.ssh/as1-cldide_cl-server.skey
SSH_AS_USER_NAME=codenvy
AS_IP=172.19.11.153
else
echo "Unknown server destination"
exit 1
fi
if [ ! -z "$2" ]; then
SSH_KEY_NAME=$2
fi
uploadInstallationManagerCli() {
FILE="installation-manager"
ARTIFACT=${FILE}"-cli"
DESCRIPTION="Codenvy Installation manager"
FILENAME=`ls ${ARTIFACT}-assembly/target | grep -G ${FILE}-.*-binary[.]tar.gz`
VERSION=`ls ${ARTIFACT}-assembly/target | grep -G ${FILE}-.*[.]jar | grep -vE 'sources|original' | sed 's/'${FILE}'-//' | sed 's/.jar//'`
SOURCE=${ARTIFACT}-assembly/target/${FILENAME}
doUpload
}
uploadCodenvyServerInstallScript() {
ARTIFACT=install-codenvy
FILENAME=install-codenvy.sh
SOURCE=installation-manager-resources/src/main/resources/im-scripts/${FILENAME}
DESCRIPTION="Script to install Codenvy in single-server configuration"
if [[ -f ${SOURCE} ]]; then
doUpload
[ "${SERVER}" == "stg" ] && ssh -i ${SSH_KEY_NAME} ${SSH_AS_USER_NAME}@${AS_IP} "sed -i 's/codenvy.com/codenvy-stg.com/g' ${DESTINATION}/${FILENAME}"
[ "${SERVER}" == "ngt" ] && ssh -i ${SSH_KEY_NAME} ${SSH_AS_USER_NAME}@${AS_IP} "sed -i 's/https:\/\/codenvy.com/http:\/\/updater-nightly.codenvy-dev.com/g' ${DESTINATION}/${FILENAME}"
fi
}
uploadCodenvyServerInstallMultiScript() {
ARTIFACT=install-codenvy-multi
FILENAME=install-codenvy-multi.sh
SOURCE=installation-manager-resources/src/main/resources/im-scripts/${FILENAME}
DESCRIPTION="Script to install Codenvy in multi-server configuration"
if [[ -f ${SOURCE} ]]; then
doUpload
[ "${SERVER}" == "stg" ] && ssh -i ${SSH_KEY_NAME} ${SSH_AS_USER_NAME}@${AS_IP} "sed -i 's/codenvy.com/codenvy-stg.com/g' ${DESTINATION}/${FILENAME}"
fi
}
uploadCodenvyServerInstallInstallationManagerScript() {
ARTIFACT=install-im-cli
FILENAME=install-im-cli.sh
SOURCE=installation-manager-resources/src/main/resources/im-scripts/${FILENAME}
DESCRIPTION="Script to install Codenvy installation manager"
if [[ -f ${SOURCE} ]]; then
doUpload
[ "${SERVER}" == "stg" ] && ssh -i ${SSH_KEY_NAME} ${SSH_AS_USER_NAME}@${AS_IP} "sed -i 's/codenvy.com/codenvy-stg.com/g' ${DESTINATION}/${FILENAME}"
[ "${SERVER}" == "ngt" ] && ssh -i ${SSH_KEY_NAME} ${SSH_AS_USER_NAME}@${AS_IP} "sed -i 's/https:\/\/start.codenvy.com\/install-single/http:\/\/updater-nightly.codenvy-dev.com\/update\/repository\/public\/download\/install-codenvy/g' ${DESTINATION}/${FILENAME}"
fi
}
uploadCodenvySingleServerInstallProperties() {
ARTIFACT=codenvy-single-server-properties
FILENAME=codenvy.properties
VERSION=$1
SOURCE=installation-manager-resources/src/main/resources/codenvy-properties/${VERSION}/codenvy-single-server.properties
DESCRIPTION="Codenvy single-server installation properties"
if [[ -f ${SOURCE} ]]; then
doUpload
[ "${SERVER}" == "stg" ] && ssh -i ${SSH_KEY_NAME} ${SSH_AS_USER_NAME}@${AS_IP} "sed -i 's/saas_api_endpoint=https:\/\/codenvy.com\/api/saas_api_endpoint=https:\/\/codenvy-stg.com\/api/g' ${DESTINATION}/${FILENAME}"
[ "${SERVER}" == "stg" ] && ssh -i ${SSH_KEY_NAME} ${SSH_AS_USER_NAME}@${AS_IP} "sed -i 's/installation_manager_update_server_endpoint=https:\/\/codenvy.com\/update/installation_manager_update_server_endpoint=https:\/\/codenvy-stg.com\/update/g' ${DESTINATION}/${FILENAME}"
[ "${SERVER}" == "ngt" ] && ssh -i ${SSH_KEY_NAME} ${SSH_AS_USER_NAME}@${AS_IP} "sed -i 's/saas_api_endpoint=https:\/\/codenvy.com\/api/saas_api_endpoint=https:\/\/nightly.codenvy-stg.com\/api/g' ${DESTINATION}/${FILENAME}"
[ "${SERVER}" == "ngt" ] && ssh -i ${SSH_KEY_NAME} ${SSH_AS_USER_NAME}@${AS_IP} "sed -i 's/installation_manager_update_server_endpoint=https:\/\/codenvy.com\/update/installation_manager_update_server_endpoint=http:\/\/updater-nightly.codenvy-dev.com\/update/g' ${DESTINATION}/${FILENAME}"
fi
}
uploadCodenvyMultiServerInstallProperties() {
ARTIFACT=codenvy-multi-server-properties
FILENAME=codenvy.properties
VERSION=$1
SOURCE=installation-manager-resources/src/main/resources/codenvy-properties/${VERSION}/codenvy-multi-server.properties
DESCRIPTION="Codenvy multi-server installation properties"
if [[ -f ${SOURCE} ]]; then
doUpload
[ "${SERVER}" == "stg" ] && ssh -i ${SSH_KEY_NAME} ${SSH_AS_USER_NAME}@${AS_IP} "sed -i 's/saas_api_endpoint=https:\/\/codenvy.com\/api/saas_api_endpoint=https:\/\/codenvy-stg.com\/api/g' ${DESTINATION}/${FILENAME}"
[ "${SERVER}" == "stg" ] && ssh -i ${SSH_KEY_NAME} ${SSH_AS_USER_NAME}@${AS_IP} "sed -i 's/installation_manager_update_server_endpoint=https:\/\/codenvy.com\/update/installation_manager_update_server_endpoint=https:\/\/codenvy-stg.com\/update/g' ${DESTINATION}/${FILENAME}"
[ "${SERVER}" == "ngt" ] && ssh -i ${SSH_KEY_NAME} ${SSH_AS_USER_NAME}@${AS_IP} "sed -i 's/saas_api_endpoint=https:\/\/codenvy.com\/api/saas_api_endpoint=https:\/\/nightly.codenvy-stg.com\/api/g' ${DESTINATION}/${FILENAME}"
[ "${SERVER}" == "ngt" ] && ssh -i ${SSH_KEY_NAME} ${SSH_AS_USER_NAME}@${AS_IP} "sed -i 's/installation_manager_update_server_endpoint=https:\/\/codenvy.com\/update/installation_manager_update_server_endpoint=http:\/\/updater-nightly.codenvy-dev.com\/update/g' ${DESTINATION}/${FILENAME}"
fi
}
doUpload() {
DESTINATION=update-server-repository/${ARTIFACT}/${VERSION}
MD5=`md5sum ${SOURCE} | cut -d ' ' -f 1`
SIZE=`du -b ${SOURCE} | cut -f1`
BUILD_TIME=`stat -c %y ${SOURCE}`
BUILD_TIME=${BUILD_TIME:0:19}
echo "file=${FILENAME}" > .properties
echo "artifact=${ARTIFACT}" >> .properties
echo "version=${VERSION}" >> .properties
echo "description=${DESCRIPTION}" >> .properties
echo "authentication-required=false" >> .properties
echo "build-time="${BUILD_TIME} >> .properties
echo "md5=${MD5}" >> .properties
echo "size=${SIZE}" >> .properties
ssh -i ${SSH_KEY_NAME} ${SSH_AS_USER_NAME}@${AS_IP} "mkdir -p /home/${SSH_AS_USER_NAME}/${DESTINATION}"
scp -o StrictHostKeyChecking=no -i ${SSH_KEY_NAME} ${SOURCE} ${SSH_AS_USER_NAME}@${AS_IP}:${DESTINATION}/${FILENAME}
scp -o StrictHostKeyChecking=no -i ${SSH_KEY_NAME} .properties ${SSH_AS_USER_NAME}@${AS_IP}:${DESTINATION}/.properties
rm .properties
}
uploadInstallationManagerCli
uploadCodenvyServerInstallMultiScript
uploadCodenvyServerInstallInstallationManagerScript
uploadCodenvyServerInstallScript
for DIR in installation-manager-resources/src/main/resources/codenvy-properties/*; do
VERSION=`basename ${DIR}`
uploadCodenvySingleServerInstallProperties ${VERSION}
done
for DIR in installation-manager-resources/src/main/resources/codenvy-properties/*; do
VERSION=`basename ${DIR}`
uploadCodenvyMultiServerInstallProperties ${VERSION}
done