Repository: incubator-stratos Updated Branches: refs/heads/master 6089f8a69 -> e57ef3914
Silent mode and code restructure Signed-off-by: Manula Thantriwatte <[email protected]> Project: http://git-wip-us.apache.org/repos/asf/incubator-stratos/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-stratos/commit/e57ef391 Tree: http://git-wip-us.apache.org/repos/asf/incubator-stratos/tree/e57ef391 Diff: http://git-wip-us.apache.org/repos/asf/incubator-stratos/diff/e57ef391 Branch: refs/heads/master Commit: e57ef3914f236bcc6703f052925933bc0dec5222 Parents: 6089f8a Author: Dinesh Bandara <[email protected]> Authored: Mon Mar 31 10:40:36 2014 +0530 Committer: Manula Thantriwatte <[email protected]> Committed: Mon Mar 31 10:54:57 2014 +0530 ---------------------------------------------------------------------- tools/stratos-installer/stratos-setup.sh | 627 +++++++++++++------------- 1 file changed, 310 insertions(+), 317 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/e57ef391/tools/stratos-installer/stratos-setup.sh ---------------------------------------------------------------------- diff --git a/tools/stratos-installer/stratos-setup.sh b/tools/stratos-installer/stratos-setup.sh index ce06c90..8f9519a 100755 --- a/tools/stratos-installer/stratos-setup.sh +++ b/tools/stratos-installer/stratos-setup.sh @@ -46,69 +46,10 @@ function help { echo "" echo "-p: <profile> Apache Stratos products to be installed on this node. Provide one name of a profile." echo " The available profiles are cc, as, sm or default. 'default' means you need to setup all servers in this machine. Default is 'default' profile" - echo "-s: Start servers after installation." + echo "-s: Silent mode - Start servers after installation." echo "" } -while getopts p: opts -do - case $opts in - p) - profile_list=${OPTARG} - ;; - s) - auto_start_servers="true" - ;; - \?) - help - exit 1 - ;; - esac -done - - -arr=$(echo $profile_list | tr " " "\n") - -for x in $arr -do - if [[ $x = "cc" ]]; then - profile="cc" - elif [[ $x = "as" ]]; then - profile="as" - elif [[ $x = "sm" ]]; then - profile="sm" - else - echo "Inavlid profile : 'default' profile will be selected." - fi -done - -echo "You have selected profile : $profile" - -profile_list=`echo $profile_list | sed 's/^ *//g' | sed 's/ *$//g'` -if [[ -z $profile_list || $profile_list = "" ]]; then - help - exit 1 -fi - -if [[ $host_user == "" ]]; then - echo "user provided in conf/stratos-setup.conf is null. Please provide a user" - exit 1 -fi - -echo "user provided in conf/stratos-setup.conf is $host_user. If you want to provide some other user name please specify it at the prompt." -echo "If you want to continue with $host_user just press enter to continue" -read username -if [[ $username != "" ]]; then - host_user=$username -fi -user=`id $host_user` -if [[ $? = 1 ]]; then - echo "User $host_user does not exist. The system will create it." - adduser --home /home/$host_user $host_user -fi - -export $host_user - # Check validity of IP function valid_ip() { @@ -127,12 +68,8 @@ function valid_ip() return $stat } -function helpsetup() { - echo "" - echo "Please set up the $1 related environment variables correctly in conf/stratos-setup.conf" - echo "" -} - +# General functions +# ------------------------------------------------------------------- function general_conf_validate() { if [[ ! -d $setup_path ]]; then echo "Please specify the setup_path folder which contains stratos setup" @@ -165,17 +102,59 @@ function general_conf_validate() { exit 1 fi - if [[ $profile = "default" ]]; then - read -p "Do you want to configure ActiveMQ [y/n]: " answer - if [[ $answer = y ]] ; then - mb_ip=$host_ip - else - echo "Provided mb_ip in conf/stratos-setup.conf will be used" - config_mb="false" - fi + if [[ $auto_start_servers != "true" ]]; then + if [[ $profile = "default" ]]; then + read -p "Do you want to configure ActiveMQ [y/n]: " answer + if [[ $answer = y ]] ; then + mb_ip=$host_ip + else + echo "Provided mb_ip in conf/stratos-setup.conf will be used" + config_mb="false" + fi + fi fi } +# Setup General +function general_setup() { + + cp -f ./config/all/repository/conf/activemq/jndi.properties $stratos_extract_path/repository/conf/ + + pushd $stratos_extract_path + echo "In repository/conf/carbon.xml" + sed -i "s@<Offset>0</Offset>@<Offset>${offset}</Offset>@g" repository/conf/carbon.xml + + echo "In repository/conf/jndi.properties" + sed -i "s@MB_HOSTNAME:MB_LISTEN_PORT@$mb_ip:$mb_port@g" repository/conf/jndi.properties + popd + + for activemq_client_lib in "${activemq_client_libs[@]}" + do + cp -f $stratos_packs/$activemq_client_lib $stratos_extract_path/repository/components/lib/ + done +} + +function activemq_validate() { + if [[ ! -f $activemq_pack ]]; then + echo "Please copy the activemq zip to the stratos pack folder and update the JAR name in conf/stratos-setup.conf file" + exit 1 + fi +} + +# ActiveMQ jar validation +function mb_jars_validate() { + for activemq_client_lib in "${activemq_client_libs[@]}" + do + lib_path=$stratos_packs/$activemq_client_lib + if [[ ! -f $lib_path ]]; then + echo "Please copy the $activemq_client_lib into the stratos pack folder" + exit 1 + fi + done +} + +# CC related functions +# ------------------------------------------------------------------- function cc_related_popup() { while read -p "Please provide cloud controller ip:" cc_ip do @@ -208,247 +187,32 @@ function cc_related_popup() { done } -function sm_related_popup() { - while read -p "Please provide Stratos Manager ip:" sm_ip - do - if !(valid_ip $sm_ip); then - echo "Please provide valid ips for SM" - else - export sm_ip - break - fi - done - - while read -p "Please provide Stratos Manager hostname:" sm_hostname - do - if [[ -z $sm_hostname ]]; then - echo "Please specify valid hostname for SM" - else - export sm_hostname - break - fi - done - - while read -p "Please provide Stratos Manager port offset:" sm_port_offset - do - if [[ -z $sm_port_offset ]]; then - echo "Please specify the port offset of SM" - else - export sm_port_offset - break - fi - done -} - -function as_related_popup() { - while read -p "Please provide Auto Scalar ip:" as_ip - do - if !(valid_ip $as_ip); then - echo "Please provide valid ips for AS" - else - export as_ip - break - fi - done - - while read -p "Please provide Auto Scala hostname:" as_hostname - do - if [[ -z $as_hostname ]]; then - echo "Please specify valid hostname for AS" - else - export as_hostname - break - fi - done - - while read -p "Please provide Auto Scala port offset:" as_port_offset - do - if [[ -z $as_port_offset ]]; then - echo "Please specify the port offset of AS" - else - export as_port_offset - break - fi - done -} - -function mb_jars_validate() { - for activemq_client_lib in "${activemq_client_libs[@]}" - do - lib_path=$stratos_packs/$activemq_client_lib - if [[ ! -f $lib_path ]]; then - echo "Please copy the $activemq_client_lib into the stratos pack folder" - exit 1 - fi - done -} - -function activemq_validate() { - if [[ ! -f $activemq_pack ]]; then - echo "Please copy the activemq zip to the stratos pack folder and update the JAR name in conf/stratos-setup.conf file" - exit 1 - fi -} - function cc_conf_validate() { if [[ $ec2_provider_enabled = "false" && $openstack_provider_enabled = "false" && $vcloud_provider_enabled = "false" ]]; then echo "Please enable at least one of the IaaS providers in conf/stratos-setup.conf file" exit 1 fi - if [[ $openstack_provider_enabled = "true" ]]; then - if [[ ( -z $openstack_identity || -z $openstack_credential || -z $openstack_jclouds_endpoint ) ]]; then - echo "Please set openstack configuration information in conf/stratos-setup.conf file" - exit 1 - fi - fi - if [[ $ec2_provider_enabled = "true" ]]; then - if [[ ( -z $ec2_identity || -z $ec2_credential || -z $ec2_keypair_name ) ]]; then - echo "Please set ec2 configuration information in conf/stratos-setup.conf file" - exit 1 - fi - fi - if [[ $vcloud_provider_enabled = "true" ]]; then - if [[ ( -z $vcloud_identity || -z $vcloud_credential || -z $vcloud_jclouds_endpoint ) ]]; then - echo "Please set vcloud configuration information in conf/stratos-setup.conf file" - exit 1 - fi - fi -} - - -function as_conf_validate() { - if [[ !($profile = "default") ]]; then - cc_related_popup - sm_related_popup - export as_cc_https_port=$((9443 + $cc_port_offset)) - export as_sm_https_port=$((9443 + $sm_port_offset)) - else - cc_hostname=$stratos_domain - sm_hostname=$stratos_domain - export as_cc_https_port=$((9443 + $offset)) - export as_sm_https_port=$((9443 + $offset)) - fi -} - - -function sm_conf_validate() { - if [[ -z $puppet_ip ]]; then - echo "Please specify the ip of puppet master" - exit 1 - elif !(valid_ip $puppet_ip); then - echo "Please provide valid ip for puppet master" - exit 1 - fi - if [[ -z $puppet_hostname ]]; then - echo "Please specify the puppet master's hostname" - exit 1 - fi - if [[ -z $puppet_environment ]]; then - echo "Please specify the relevant puppet environment" - exit 1 - fi - if [[ ! -f $mysql_connector_jar ]]; then - echo "Please copy the mysql connector jar to the stratos release pack folder and update the JAR name in conf/stratos-setup.conf file" - exit 1 - fi - - if [[ !($profile = "default") ]]; then - cc_related_popup - as_related_popup - export sm_cc_https_port=$((9443 + $cc_port_offset)) - export sm_as_https_port=$((9443 + $as_port_offset)) - else - export cc_hostname=$stratos_domain - export as_hostname=$stratos_domain - export sm_cc_https_port=$((9443 + $offset)) - export sm_as_https_port=$((9443 + $offset)) - fi - export sm_https_port=$((9443 + $offset)) -} - - -function cep_conf_validate() { - if [[ ! -d $cep_artifacts_path ]]; then - echo "Please specify the cep_artifacts_path folder which contains cep artifacts files" - exit 1 - fi - if [[ ! -f $cep_extension_jar ]]; then - echo "Please copy the cep extension jar into the same folder as this command(stratos release pack folder) and update conf/stratos-setup.conf file" - exit 1 - fi -} - - -# Make sure the user is running as root. -if [ "$UID" -ne "0" ]; then - echo ; echo " You must be root to run $0. (Try running 'sudo bash' first.)" ; echo - exit 69 -fi - -general_conf_validate -mb_jars_validate -if [[ $profile = "cc" ]]; then - cc_conf_validate -elif [[ $profile = "as" ]]; then - as_conf_validate -elif [[ $profile = "sm" ]]; then - sm_conf_validate -else - echo "In default profile CEP will be configured." - activemq_validate - cc_conf_validate - as_conf_validate - sm_conf_validate - cep_conf_validate -fi - -if [[ ! -d $log_path ]]; then - mkdir -p $log_path -fi - - -echo "" -echo "For all the questions asked while during executing the script please just press the enter button" -echo "" - - -# Extract stratos zip file -if [[ !(-d $stratos_extract_path) ]]; then - echo "Extracting Apache Stratos" - unzip -q $stratos_pack_zip -d $stratos_path - mv -f $stratos_path/apache-stratos-4.0.0-SNAPSHOT $stratos_extract_path -fi - -if [[ ($profile = "default" && $config_mb = "true") ]]; then - echo "Extracting ActiveMQ" - tar -xzf $activemq_pack -C $stratos_path -fi - -# ------------------------------------------------ -# Setup General -# ------------------------------------------------ -function general_setup() { - - cp -f ./config/all/repository/conf/activemq/jndi.properties $stratos_extract_path/repository/conf/ - - pushd $stratos_extract_path - echo "In repository/conf/carbon.xml" - sed -i "s@<Offset>0</Offset>@<Offset>${offset}</Offset>@g" repository/conf/carbon.xml - - echo "In repository/conf/jndi.properties" - sed -i "s@MB_HOSTNAME:MB_LISTEN_PORT@$mb_ip:$mb_port@g" repository/conf/jndi.properties - popd - - for activemq_client_lib in "${activemq_client_libs[@]}" - do - cp -f $stratos_packs/$activemq_client_lib $stratos_extract_path/repository/components/lib/ - done + if [[ $openstack_provider_enabled = "true" ]]; then + if [[ ( -z $openstack_identity || -z $openstack_credential || -z $openstack_jclouds_endpoint ) ]]; then + echo "Please set openstack configuration information in conf/stratos-setup.conf file" + exit 1 + fi + fi + if [[ $ec2_provider_enabled = "true" ]]; then + if [[ ( -z $ec2_identity || -z $ec2_credential || -z $ec2_keypair_name ) ]]; then + echo "Please set ec2 configuration information in conf/stratos-setup.conf file" + exit 1 + fi + fi + if [[ $vcloud_provider_enabled = "true" ]]; then + if [[ ( -z $vcloud_identity || -z $vcloud_credential || -z $vcloud_jclouds_endpoint ) ]]; then + echo "Please set vcloud configuration information in conf/stratos-setup.conf file" + exit 1 + fi + fi } - -# ------------------------------------------------ # Setup cc -# ------------------------------------------------ function cc_setup() { echo "Setup CC" >> $LOG echo "Configuring the Cloud Controller" @@ -474,9 +238,55 @@ function cc_setup() { } -# ------------------------------------------------ -# Setup AS -# ------------------------------------------------ +# AS related functions +# ------------------------------------------------------------------- +function as_related_popup() { + while read -p "Please provide Auto Scalar ip:" as_ip + do + if !(valid_ip $as_ip); then + echo "Please provide valid ips for AS" + else + export as_ip + break + fi + done + + while read -p "Please provide Auto Scala hostname:" as_hostname + do + if [[ -z $as_hostname ]]; then + echo "Please specify valid hostname for AS" + else + export as_hostname + break + fi + done + + while read -p "Please provide Auto Scala port offset:" as_port_offset + do + if [[ -z $as_port_offset ]]; then + echo "Please specify the port offset of AS" + else + export as_port_offset + break + fi + done +} + +function as_conf_validate() { + if [[ !($profile = "default") ]]; then + cc_related_popup + sm_related_popup + export as_cc_https_port=$((9443 + $cc_port_offset)) + export as_sm_https_port=$((9443 + $sm_port_offset)) + else + cc_hostname=$stratos_domain + sm_hostname=$stratos_domain + export as_cc_https_port=$((9443 + $offset)) + export as_sm_https_port=$((9443 + $offset)) + fi +} + +# Setup AS function as_setup() { echo "Setup AS" >> $LOG echo "Configuring the Auto Scalar" @@ -496,9 +306,76 @@ function as_setup() { } -# ------------------------------------------------ +# SM related functions +# ------------------------------------------------------------------- +function sm_related_popup() { + while read -p "Please provide Stratos Manager ip:" sm_ip + do + if !(valid_ip $sm_ip); then + echo "Please provide valid ips for SM" + else + export sm_ip + break + fi + done + + while read -p "Please provide Stratos Manager hostname:" sm_hostname + do + if [[ -z $sm_hostname ]]; then + echo "Please specify valid hostname for SM" + else + export sm_hostname + break + fi + done + + while read -p "Please provide Stratos Manager port offset:" sm_port_offset + do + if [[ -z $sm_port_offset ]]; then + echo "Please specify the port offset of SM" + else + export sm_port_offset + break + fi + done +} + +function sm_conf_validate() { + if [[ -z $puppet_ip ]]; then + echo "Please specify the ip of puppet master" + exit 1 + elif !(valid_ip $puppet_ip); then + echo "Please provide valid ip for puppet master" + exit 1 + fi + if [[ -z $puppet_hostname ]]; then + echo "Please specify the puppet master's hostname" + exit 1 + fi + if [[ -z $puppet_environment ]]; then + echo "Please specify the relevant puppet environment" + exit 1 + fi + if [[ ! -f $mysql_connector_jar ]]; then + echo "Please copy the mysql connector jar to the stratos release pack folder and update the JAR name in conf/stratos-setup.conf file" + exit 1 + fi + + if [[ !($profile = "default") ]]; then + cc_related_popup + as_related_popup + export sm_cc_https_port=$((9443 + $cc_port_offset)) + export sm_as_https_port=$((9443 + $as_port_offset)) + else + export cc_hostname=$stratos_domain + export as_hostname=$stratos_domain + export sm_cc_https_port=$((9443 + $offset)) + export sm_as_https_port=$((9443 + $offset)) + fi + export sm_https_port=$((9443 + $offset)) +} + # Setup SM -# ------------------------------------------------ function sm_setup() { echo "Setup SM" >> $LOG echo "Configuring Stratos Manager" @@ -539,10 +416,20 @@ function sm_setup() { echo "End configuring the SM" } +# CEP related functions +# ------------------------------------------------------------------- +function cep_conf_validate() { + if [[ ! -d $cep_artifacts_path ]]; then + echo "Please specify the cep_artifacts_path folder which contains cep artifacts files" + exit 1 + fi + if [[ ! -f $cep_extension_jar ]]; then + echo "Please copy the cep extension jar into the same folder as this command(stratos release pack folder) and update conf/stratos-setup.conf file" + exit 1 + fi +} -# ------------------------------------------------ # Setup CEP -# ------------------------------------------------ function cep_setup() { echo "Setup CEP" >> $LOG echo "Configuring the Complex Event Processor" @@ -576,6 +463,115 @@ function cep_setup() { } +# ------------------------------------------------ +# Execution +# ------------------------------------------------ + +while getopts p:s opts +do + case $opts in + p) + profile_list=${OPTARG} + ;; + s) + auto_start_servers="true" + ;; + \?) + help + exit 1 + ;; + esac +done + +arr=$(echo $profile_list | tr " " "\n") + +for x in $arr +do + if [[ $x = "default" ]]; then + profile="default" + elif [[ $x = "cc" ]]; then + profile="cc" + elif [[ $x = "as" ]]; then + profile="as" + elif [[ $x = "sm" ]]; then + profile="sm" + else + echo "Inavlid profile : 'default' profile will be selected." + fi +done + +echo "You have selected profile : $profile" + +profile_list=`echo $profile_list | sed 's/^ *//g' | sed 's/ *$//g'` +if [[ -z $profile_list || $profile_list = "" ]]; then + help + exit 1 +fi + +if [[ $host_user == "" ]]; then + echo "user provided in conf/stratos-setup.conf is null. Please provide a user" + exit 1 +fi + +echo "user provided in conf/stratos-setup.conf is $host_user. If you want to provide some other user name please specify it at the prompt." +echo "If you want to continue with $host_user just press enter to continue" +read username +if [[ $username != "" ]]; then + host_user=$username +fi +user=`id $host_user` +if [[ $? = 1 ]]; then + echo "User $host_user does not exist. The system will create it." + adduser --home /home/$host_user $host_user +fi + +export $host_user + +# Make sure the user is running as root. +if [ "$UID" -ne "0" ]; then + echo ; echo " You must be root to run $0. (Try running 'sudo bash' first.)" ; echo + exit 69 +fi + +general_conf_validate +mb_jars_validate +if [[ $profile = "cc" ]]; then + cc_conf_validate +elif [[ $profile = "as" ]]; then + as_conf_validate +elif [[ $profile = "sm" ]]; then + sm_conf_validate +else + echo "In default profile CEP will be configured." + activemq_validate + cc_conf_validate + as_conf_validate + sm_conf_validate + cep_conf_validate +fi + +if [[ ! -d $log_path ]]; then + mkdir -p $log_path +fi + + +echo "" +echo "For all the questions asked while during executing the script please just press the enter button" +echo "" + + +# Extract stratos zip file +if [[ !(-d $stratos_extract_path) ]]; then + echo "Extracting Apache Stratos" + unzip -q $stratos_pack_zip -d $stratos_path + mv -f $stratos_path/apache-stratos-4.0.0-SNAPSHOT $stratos_extract_path +fi + +if [[ ($profile = "default" && $config_mb = "true") ]]; then + echo "Extracting ActiveMQ" + tar -xzf $activemq_pack -C $stratos_path +fi + general_setup if [[ $profile = "cc" ]]; then cc_setup @@ -641,6 +637,3 @@ if [[ $profile == "default" || $profile == "sm" ]]; then echo "Management Console : https://$stratos_domain:$sm_https_port/console" echo "**************************************************************" fi - - -
