Skip to content

Commit

Permalink
CDEC-402: Allow install-codenvy.sh script to install only IM CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
Anatoliy Bazko committed Nov 24, 2015
1 parent bc3dd14 commit 4ca936e
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 134 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,13 @@ setRunOptions() {
ARTIFACT="codenvy"
CODENVY_TYPE="single"
SILENT=false
VERSION=`curl -s https://codenvy.com/update/repository/properties/${ARTIFACT}?label=stable | sed 's/.*"version":"\([^"]*\)".*/\1/'`
for var in "$@"; do
if [[ "$var" == "--multi" ]]; then
CODENVY_TYPE="multi"
elif [[ "$var" == "--silent" ]]; then
SILENT=true
elif [[ "$var" == "--im-cli" ]]; then
ARTIFACT="installation-manager-cli"
elif [[ "$var" =~ --version=.* ]]; then
VERSION=`echo "$var" | sed -e "s/--version=//g"`
elif [[ "$var" =~ --hostname=.* ]]; then
Expand All @@ -113,6 +114,26 @@ setRunOptions() {
SYSTEM_ADMIN_PASSWORD=`echo "$var" | sed -e "s/--systemAdminPassword=//g"`
fi
done

if [[ ${ARTIFACT} == "codenvy" ]]; then
LAST_INSTALLATION_STEP=13
ARTIFACT_DISPLAY="Codenvy"
if [[ -z ${VERSION} ]]; then
VERSION=`curl -s https://codenvy.com/update/repository/properties/${ARTIFACT}?label=stable | sed 's/.*"version":"\([^"]*\)".*/\1/'`
fi
else
LAST_INSTALLATION_STEP=3
ARTIFACT_DISPLAY="Installation Manager CLI"
CODENVY_TYPE="single"
INSTALLATION_STEPS=("Configuring system..."
"Installing required packages... [java]"
"Install the Codenvy installation manager..."
"");
if [[ -z ${VERSION} ]]; then
VERSION=`curl -s https://codenvy.com/update/repository/properties/${ARTIFACT} | sed 's/.*"version":"\([^"]*\)".*/\1/'`
fi
fi

CONFIG="codenvy.properties"
EXTERNAL_DEPENDENCIES[0]="https://codenvy.com/update/repository/public/download/${ARTIFACT}/${VERSION}||0"

Expand Down Expand Up @@ -228,9 +249,6 @@ doInstallCodenvy() {
break;
done
done

setStepIndicator 13
sleep 2
}

downloadConfig() {
Expand Down Expand Up @@ -273,7 +291,7 @@ preConfigureSystem() {
installPackageIfNeed wget
validateExitCode $?

if [[ ! -f ${CONFIG} ]]; then
if [[ ! -f ${CONFIG} ]] && [[ ${ARTIFACT} == "codenvy" ]]; then
downloadConfig
fi
}
Expand Down Expand Up @@ -576,7 +594,7 @@ doCheckAvailablePorts_multi() {
printPreInstallInfo_single() {
clear

println "Welcome. This program installs Codenvy ${VERSION}."
println "Welcome. This program installs ${ARTIFACT_DISPLAY} ${VERSION}."
println
println "Checking system pre-requisites..."
println
Expand All @@ -589,8 +607,10 @@ printPreInstallInfo_single() {

checkResourceAccess

println "Configuring system properties with file://${CONFIG}..."
println
if [[ ${ARTIFACT} == "codenvy" ]]; then
println "Configuring system properties with file://${CONFIG}..."
println
fi

if [ -n "${SYSTEM_ADMIN_NAME}" ]; then
insertProperty "admin_ldap_user_name" ${SYSTEM_ADMIN_NAME}
Expand Down Expand Up @@ -774,16 +794,19 @@ doCheckResourceAccess() {
printPreInstallInfo_multi() {
clear

println "Welcome. This program installs Codenvy ${VERSION}."
println "Welcome. This program installs ${ARTIFACT_DISPLAY} ${VERSION}."
println
println "Checking system pre-requisites..."
println

preConfigureSystem
doCheckAvailableResourcesLocally 1000000 1 14000000

println "Configuring system properties with file://${CONFIG}..."
println

if [[ ${ARTIFACT} == "codenvy" ]]; then
println "Configuring system properties with file://${CONFIG}..."
println
fi

if [ -n "${SYSTEM_ADMIN_NAME}" ]; then
insertProperty "admin_ldap_user_name" ${SYSTEM_ADMIN_NAME}
Expand Down Expand Up @@ -1030,7 +1053,7 @@ updateTimer() {

updateProgress() {
local current_step=$1
local last_step=13
local last_step=${LAST_INSTALLATION_STEP}
local factor=2

local progress_number=$(( ${current_step}*100/${last_step} ))
Expand Down Expand Up @@ -1186,7 +1209,7 @@ doUpdateInternetAccessChecker() {
return ${checkFailed}
}

printPostInstallInfo() {
printPostInstallInfo_codenvy() {
if [ -z ${SYSTEM_ADMIN_NAME} ]; then
SYSTEM_ADMIN_NAME=`grep admin_ldap_user_name= ${CONFIG} | cut -d '=' -f2`
fi
Expand All @@ -1211,6 +1234,11 @@ printPostInstallInfo() {
println "$(printWarning "!!! Set up DNS or add a hosts rule on your clients to reach this hostname.")"
}

printPostInstallInfo_installation-manager-cli() {
println
println "Codenvy Installation Manager is installed into ${DIR}/codenvy-cli directory"
}

setRunOptions "$@"
printPreInstallInfo_${CODENVY_TYPE}

Expand All @@ -1226,7 +1254,14 @@ doConfigureSystem
doInstallJava
doInstallImCli

doDownloadBinaries
doInstallCodenvy
if [[ ${ARTIFACT} == "codenvy" ]]; then
doDownloadBinaries
doInstallCodenvy
fi

setStepIndicator ${LAST_INSTALLATION_STEP}
sleep 2

printPostInstallInfo_${ARTIFACT}


printPostInstallInfo
Original file line number Diff line number Diff line change
@@ -1,117 +1,3 @@
#!/bin/bash

# bash <(curl -s https://codenvy.com/update/repository/public/download/install-im-cli)
set -e

setRunOptions() {
DIR="${HOME}/codenvy-im"
ARTIFACT="installation-manager-cli"

VERSION=`curl -s https://codenvy.com/update/repository/properties/${ARTIFACT} | sed 's/.*"version":"\([^"]*\)".*/\1/'`
for var in "$@"; do
if [[ "$var" =~ --version=.* ]]; then
VERSION=`echo "$var" | sed -e "s/--version=//g"`
fi
done
}

validateOS() {
if [ -f /etc/redhat-release ]; then
OS="Red Hat"
else
printLn "Operation system isn't supported."
exit 1
fi
OS_VERSION=`cat /etc/redhat-release | sed 's/.* \([0-9.]*\) .*/\1/' | cut -f1 -d '.'`
}

# $1 - command name
installPackageIfNeed() {
command -v $1 >/dev/null 2>&1 || { # check if requered command had been already installed earlier
printPrompt; echo "Installing $1 "
sudo yum install $1 -y -q
}
}

installJava() {
printLn "Installing java"
wget -q --no-cookies --no-check-certificate --header 'Cookie: oraclelicense=accept-securebackup-cookie' 'http://download.oracle.com/otn-pub/java/jdk/8u45-b14/jre-8u45-linux-x64.tar.gz' --output-document=jre.tar.gz

tar -xf jre.tar.gz -C ${DIR}
mv ${DIR}/jre1.8.0_45 ${DIR}/jre

rm jre.tar.gz
}

installIm() {
printLn "Downloading Installation Manager"

IM_URL="https://codenvy.com/update/repository/public/download/${ARTIFACT}/${VERSION}"
IM_FILE=$(curl -sI ${IM_URL} | grep -o -E 'filename=(.*)[.]tar.gz' | sed -e 's/filename=//')

curl -s -o ${IM_FILE} -L ${IM_URL}

mkdir ${DIR}/codenvy-cli
tar -xf ${IM_FILE} -C ${DIR}/codenvy-cli

sed -i "2iJAVA_HOME=${HOME}/codenvy-im/jre" ${DIR}/codenvy-cli/bin/codenvy
echo "export PATH=\$PATH:\$HOME/codenvy-im/codenvy-cli/bin" >> ${HOME}/.bashrc
}

printPrompt() {
echo -en "\e[94m[CODENVY]\e[0m "
}

printLn() {
printPrompt; echo "$1"
}

printPreInstallInfo() {
printLn "Welcome. This program installs Codenvy Installation Manager."
printLn ""
}

preconfigureSystem() {
sudo yum clean all &> /dev/null
installPackageIfNeed curl

validateOS
setRunOptions "$@"
}


doInstallStep1() {
printLn ""
printLn "STEP 1: CONFIGURE SYSTEM"

if [ -d ${DIR} ]; then rm -rf ${DIR}; fi
mkdir ${DIR}
}

doInstallStep2() {
printLn ""
printLn "STEP 2: INSTALL JAVA AND OTHER REQUIRED PACKAGES"

installPackageIfNeed tar
installPackageIfNeed wget
installPackageIfNeed unzip
installJava
}

doInstallStep3() {
printLn ""
printLn "STEP 3: INSTALL THE CODENVY INSTALLATION MANAGER"

installIm

printLn "Codenvy Installation Manager is installed into ${DIR}/codenvy-cli directory"
}

clear
preconfigureSystem "$@"

printPreInstallInfo

doInstallStep1
doInstallStep2
doInstallStep3
bash <(curl -L -s https://start.codenvy.com/install-single) --im-cli --silent $@
6 changes: 3 additions & 3 deletions upload-installation-manager.sh
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,15 @@ uploadCodenvyServerInstallMultiScript() {
[ "${SERVER}" == "stg" ] && ssh -i ${SSH_KEY_NAME} ${SSH_AS_USER_NAME}@${AS_IP} "sed -i 's/codenvy.com/codenvy-stg.com/g' ${DESTINATION}/${FILENAME}"
}

uploadCodenvyServerInstallInstalationManagerScript() {
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"
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}"
[ "${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}"
}

uploadCodenvySingleServerInstallProperties() {
Expand Down Expand Up @@ -128,7 +128,7 @@ doUpload() {

uploadInstallationManagerCli
uploadCodenvyServerInstallMultiScript
uploadCodenvyServerInstallInstalationManagerScript
uploadCodenvyServerInstallInstallationManagerScript
uploadCodenvyServerInstallScript

for DIR in installation-manager-resources/src/main/resources/codenvy-properties/*; do
Expand Down

0 comments on commit 4ca936e

Please sign in to comment.