You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by is...@apache.org on 2014/03/28 13:33:29 UTC

git commit: Single JVM installation script supports for profiles

Repository: incubator-stratos
Updated Branches:
  refs/heads/master 2651d6aab -> b1caebf69


Single JVM installation script supports for profiles

Signed-off-by: M. Isuru Tharanga Chrishantha Perera <is...@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/incubator-stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-stratos/commit/b1caebf6
Tree: http://git-wip-us.apache.org/repos/asf/incubator-stratos/tree/b1caebf6
Diff: http://git-wip-us.apache.org/repos/asf/incubator-stratos/diff/b1caebf6

Branch: refs/heads/master
Commit: b1caebf69d5acc151e1920feddff8c2b708918ec
Parents: 2651d6a
Author: Dinesh Bandara <di...@wso2.com>
Authored: Fri Mar 28 17:52:24 2014 +0530
Committer: M. Isuru Tharanga Chrishantha Perera <is...@apache.org>
Committed: Fri Mar 28 18:01:31 2014 +0530

----------------------------------------------------------------------
 tools/stratos-installer/conf/stratos-setup.conf | 139 +---
 tools/stratos-installer/stratos-clean.sh        | 104 +++
 tools/stratos-installer/stratos-ec2.sh          |  49 +-
 tools/stratos-installer/stratos-openstack.sh    |  37 +-
 tools/stratos-installer/stratos-setup.sh        | 648 +++++++++----------
 .../stratos-installer/stratos-start-servers.sh  |  72 +--
 tools/stratos-installer/stratos-vcloud.sh       |  37 +-
 7 files changed, 504 insertions(+), 582 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/b1caebf6/tools/stratos-installer/conf/stratos-setup.conf
----------------------------------------------------------------------
diff --git a/tools/stratos-installer/conf/stratos-setup.conf b/tools/stratos-installer/conf/stratos-setup.conf
index 582cde5..a29047c 100644
--- a/tools/stratos-installer/conf/stratos-setup.conf
+++ b/tools/stratos-installer/conf/stratos-setup.conf
@@ -24,37 +24,16 @@
 # ----------------------------------------------------------------------------
 #
 #  Configure below parameters to install Apache Stratos using ../setup.sh.
-#  General configuration parameters are mandatory and other sections are optional. Configure each section on each node where
-#  Stratos product is installed.
+#  General configuration parameters are mandatory and other sections are optional. 
 #
 # ----------------------------------------------------------------------------
 
 
-#########################################################################################################
-#########################################################################################################
-#########################################################################################################
-##############################         User Configs Start              ##################################
-#########################################################################################################
-#########################################################################################################
-#########################################################################################################
-
 # ----------------------------------------------------------------------------
 # General configuration
 # ----------------------------------------------------------------------------
-export setup_path= #path to stratos-installer directory
-
-####### path to packages/binaries/jars
-####### apache-stratos-4.0.0-SNAPSHOT.zip
-####### apache-activemq-5.8.0-bin.tar.gz
-####### org.apache.stratos.cep.extension-1.0.0-SNAPSHOT.jar
-####### mysql-connector-java-5.1.25.jar
-####### activemq jars: In activemq 5.8 case you need following jars;
-####### from activemq lib directory: activemq-broker-5.8.0.jar  activemq-client-5.8.0.jar  geronimo-j2ee-management_1.1_spec-1.0.1.jar  geronimo-jms_1.1_spec-1.1.1.jar  
-####### hawtbuf-1.2.jar from http://repo1.maven.org/maven2/org/fusesource/hawtbuf/hawtbuf/1.2/hawtbuf-1.2.jar
-export stratos_pack_path= #Path to stratos-packs directory 
-
-export mysql_connector_jar=$stratos_pack_path/"mysql-connector-java-5.1.29-bin.jar" #mysql connector jar file name
-
+export setup_path= #Folder path containing stratos_setup
+export stratos_packs= #Folder path containing stratos package and other third party packs and jars 
 export stratos_path= #Folder which stratos will be installed
 
 export JAVA_HOME= #Java home path
@@ -65,18 +44,24 @@ export host_user="" #A host user account for the machine which run Stratos compo
 
 export stratos_domain="stratos.apache.org"
 
-export machine_ip="127.0.0.1"
+export host_ip="127.0.0.1" # Machine ip on host machine
 export offset=0
 
-export mb_ip="127.0.0.1"	# Machine ip on which mb run
-export mb_port=61616 #default port which the message broker service runs - it's 61616 in activemq case.
+export puppet_ip="127.0.0.1" 	# Machine ip on which puppet master run
+export puppet_hostname="puppet-hostname" # Host name given to identify the puppet master
+export puppet_environment="puppet_environment" # Name of puppet environment
 
-export cep_artifacts_path= #Folder path containing cep artifacts files
+export mb_ip="127.0.0.1" # Machine ip on which mb run
+export mb_port=61616 #default port which the message broker service runs
+ 
+export stratos_extract_path=$stratos_path/"apache-stratos"
+export stratos_pack_zip=$stratos_packs/"apache-stratos-4.0.0-SNAPSHOT.zip" 
+
+export activemq_pack=$stratos_packs/"apache-activemq-5.8.0-bin.tar.gz"
+export activemq_path=$stratos_path/"apache-activemq-5.8.0"
+
+export resource_path=$setup_path/resources
 
-export puppet_ip="127.0.0.1" 	# Machine ip on which puppet master run
-export puppet_hostname="puppet.stratos.com" # Host name given to identify the puppet master
-# puppet_environment is not necessary to change, if you do not have any specific configuration
-export puppet_environment="stratos" # Name of puppet environment
 
 # IaaS Providers
 # ----------------------------------------------------------------------------
@@ -98,7 +83,7 @@ export openstack_identity="stratos:stratos" # Openstack project name:Openstack l
 export openstack_credential="password" # Openstack login password
 export openstack_jclouds_endpoint="http://hostname:5000/v2.0"
 export openstack_keypair_name=""
-export openstack_security_groups="security-groups"
+export openstack_security_groups=""
 
 # vCloud
 export vcloud_provider_enabled=false
@@ -106,7 +91,11 @@ export vcloud_identity="stratos" # vCloud login user
 export vcloud_credential="password" # vCloud login password
 export vcloud_jclouds_endpoint="https://vcloud/api"
 
-# userstore database configuration
+
+# Database configuration
+# ----------------------------------------------------------------------------
+export mysql_connector_jar=$stratos_packs/"mysql-connector-java-5.1.29-bin.jar" #mysql connector jar file name
+
 export userstore_db_hostname="localhost"
 export userstore_db_schema="userstore"
 export userstore_db_port="3306"
@@ -114,86 +103,8 @@ export userstore_db_user="root"
 export userstore_db_pass="root"
 
 
-#########################################################################################################
-#########################################################################################################
-#########################################################################################################
-##############################         User Configs End                ##################################
-#########################################################################################################
-#########################################################################################################
-#########################################################################################################
-
-export cep_ip=$machine_ip	# Machine ip on which cep run
-export cc_ip=$machine_ip 	# Machine ip on which cc run
-export as_ip=$machine_ip	# Machine ip on which auto scalar run
-export sm_ip=$machine_ip	# Machine ip on which sc run
-
-export cc_port_offset=$offset
-export sm_port_offset=$offset
-export as_port_offset=$offset
-export cep_port_offset=$offset
-export mb_port_offset=$offset
-
-export mb_hostname="mb.$stratos_domain"
-export cep_hostname="cep.$stratos_domain"
-export sm_hostname="$stratos_domain"
-export cc_hostname="cc.$stratos_domain"
-export as_hostname="as.$stratos_domain"
-
-export resource_path=$setup_path/resources
-
-# ----------------------------------------------------------------------------
-# General configuration
-# ----------------------------------------------------------------------------
-export stratos_dist_path=$stratos_path/"apache-stratos-4.0.0-SNAPSHOT"
-export stratos_pack=$stratos_pack_path/"apache-stratos-4.0.0-SNAPSHOT.zip"
-
-# ----------------------------------------------------------------------------
-# MB configuration
-# ----------------------------------------------------------------------------
-export mb_path=$stratos_path/"apache-activemq-5.8.0"
-export mb_pack_path=$stratos_pack_path/"apache-activemq-5.8.0-bin.tar.gz"
-
-
-# ----------------------------------------------------------------------------
 # CEP configuration
 # ----------------------------------------------------------------------------
-export cep_extension_jar=$stratos_pack_path/"org.apache.stratos.cep.extension-1.0.0-SNAPSHOT.jar" # cep extensions jar file name
-
-export cep_path=$stratos_dist_path
-
-export cep_mb_ip=$mb_ip
-export cep_mb_listen_port=$(($mb_port + $mb_port_offset))
-
-
-# ----------------------------------------------------------------------------
-# CC configuration
-# ----------------------------------------------------------------------------
-export cc_path=$stratos_dist_path
-
-export cc_mb_listen_port=$(($mb_port + $mb_port_offset))
-export cc_https_port=$((9443 + $cc_port_offset))
-
-# ----------------------------------------------------------------------------
-# Auto Scalar configuration
-# ----------------------------------------------------------------------------
-export as_path=$stratos_dist_path
-
-export as_mb_listen_port=$(($mb_port + $mb_port_offset))
-export as_cc_https_port=$((9443 + $cc_port_offset))
-export as_sm_https_port=$((9443 + $sm_port_offset))
-
-
-# ----------------------------------------------------------------------------
-# SM configuration
-# ----------------------------------------------------------------------------
-export sm_path=$stratos_dist_path
-
-export sm_puppet_ip=$puppet_ip
-export sm_puppet_hostname=$puppet_hostname
-export sm_puppet_environment=$puppet_environment
-export sm_mb_listen_port=$(($mb_port + $mb_port_offset))
-export sm_cc_https_port=$((9443 + $cc_port_offset))
-export sm_as_https_port=$((9443 + $as_port_offset))
-export sm_https_port=$((9443 + $sm_port_offset))
-export sm_http_port=$((9763 + $sm_port_offset))
+export cep_artifacts_path= #Folder path containing cep artifacts files
+export cep_extension_jar=$stratos_pack/"org.apache.stratos.cep.extension-1.0.0-SNAPSHOT.jar" # cep extensions jar file name
 

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/b1caebf6/tools/stratos-installer/stratos-clean.sh
----------------------------------------------------------------------
diff --git a/tools/stratos-installer/stratos-clean.sh b/tools/stratos-installer/stratos-clean.sh
new file mode 100755
index 0000000..261dee7
--- /dev/null
+++ b/tools/stratos-installer/stratos-clean.sh
@@ -0,0 +1,104 @@
+#!/bin/bash
+# ----------------------------------------------------------------------------
+#
+#  Licensed to the Apache Software Foundation (ASF) under one
+#  or more contributor license agreements.  See the NOTICE file
+#  distributed with this work for additional information
+#  regarding copyright ownership.  The ASF licenses this file
+#  to you under the Apache License, Version 2.0 (the
+#  "License"); you may not use this file except in compliance
+#  with the License.  You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing,
+#  software distributed under the License is distributed on an
+#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+#  KIND, either express or implied.  See the License for the
+#  specific language governing permissions and limitations
+#  under the License.
+#
+# ----------------------------------------------------------------------------
+#
+#  This script is for cleaning the host machine where one or more of the Stratos servers are run.
+# ----------------------------------------------------------------------------
+
+source "./conf/stratos-setup.conf"
+
+if [ "$UID" -ne "0" ]; then
+	echo ; echo "  You must be root to run $0.  (Try running 'sudo bash' first.)" ; echo 
+	exit 69
+fi
+
+function help {
+    echo ""
+    echo "Clean the host machine where one or more of the Stratos2 servers are run."
+    echo "usage:"
+    echo "stratos-clean.sh -u <mysql username> -p <mysql password>"
+    echo ""
+}
+
+while getopts u:p: opts
+do
+  case $opts in
+    u)
+        mysql_user=${OPTARG}
+        ;;
+    p)
+        mysql_pass=${OPTARG}
+        ;;
+    *)
+        help
+        #exit 1
+        ;;
+  esac
+done
+
+function helpclean {
+    echo ""
+    echo "Enter DB credentials if you need to clear Stratos DB"
+    echo "usage:"
+    echo "clean.sh -u <mysql username> -p <mysql password>"
+    echo ""
+}
+
+function clean_validate {
+    if [ -z $stratos_path ]; then
+        echo "stratos_path is not set"
+        exit 1
+    fi
+    if [ -z $log_path ]; then
+        echo "log_path is not set"
+        exit 1
+    fi
+}
+
+clean_validate
+if [[ ( -n $mysql_user && -n $mysql_pass ) ]]; then
+	read -p "Please confirm that you want to remove stratos databases, servers and logs [y/n] " answer
+	if [[ $answer != y ]] ; then
+    		exit 1
+	fi
+fi
+echo 'Stopping all java processes'
+killall java
+echo 'Waiting for applications to exit'
+sleep 15
+
+if [[ ( -n $mysql_user && -n $mysql_pass ) ]]; then
+   echo 'Removing userstore database'
+   mysql -u $mysql_user -p$mysql_pass -e "DROP DATABASE IF EXISTS $userstore_db_schema;"
+fi
+
+if [[ -d $stratos_path/scripts ]]; then
+   echo 'Removing scripts'
+   rm -rf $stratos_path/scripts
+fi
+
+if [[ -d $stratos_path ]]; then
+   echo 'Removing Stratos'
+   rm -rf $stratos_path/*
+fi
+
+echo 'Removing logs'
+rm -rf $log_path/*

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/b1caebf6/tools/stratos-installer/stratos-ec2.sh
----------------------------------------------------------------------
diff --git a/tools/stratos-installer/stratos-ec2.sh b/tools/stratos-installer/stratos-ec2.sh
index de26fcc..7e39a80 100755
--- a/tools/stratos-installer/stratos-ec2.sh
+++ b/tools/stratos-installer/stratos-ec2.sh
@@ -35,45 +35,22 @@ if [[ ! -d $log_path ]]; then
     mkdir -p $log_path
 fi
 
-pushd $cc_path
+pushd $stratos_extract_path
 
 echo "Set EC2 provider specific info in repository/conf/cloud-controller.xml" >> $LOG
 
-cp -f repository/conf/cloud-controller.xml repository/conf/cloud-controller.xml.orig
-cat repository/conf/cloud-controller.xml.orig | sed -e "s@EC2_PROVIDER_START@@g" > repository/conf/cloud-controller.xml
- 
-cp -f repository/conf/cloud-controller.xml repository/conf/cloud-controller.xml.orig
-cat repository/conf/cloud-controller.xml.orig | sed -e "s@EC2_IDENTITY@$ec2_identity@g" > repository/conf/cloud-controller.xml
-       
-cp -f repository/conf/cloud-controller.xml repository/conf/cloud-controller.xml.orig
-cat repository/conf/cloud-controller.xml.orig | sed -e "s@EC2_CREDENTIAL@$ec2_credential@g" > repository/conf/cloud-controller.xml
-       
-cp -f repository/conf/cloud-controller.xml repository/conf/cloud-controller.xml.orig
-cat repository/conf/cloud-controller.xml.orig | sed -e "s@EC2_OWNER_ID@$ec2_owner_id@g" > repository/conf/cloud-controller.xml
-
-cp -f repository/conf/cloud-controller.xml repository/conf/cloud-controller.xml.orig
-cat repository/conf/cloud-controller.xml.orig | sed -e "s@EC2_AVAILABILITY_ZONE@$ec2_availability_zone@g" > repository/conf/cloud-controller.xml
-       
-cp -f repository/conf/cloud-controller.xml repository/conf/cloud-controller.xml.orig
-cat repository/conf/cloud-controller.xml.orig | sed -e "s@EC2_SECURITY_GROUPS@$ec2_security_groups@g" > repository/conf/cloud-controller.xml
-
-cp -f repository/conf/cloud-controller.xml repository/conf/cloud-controller.xml.orig
-cat repository/conf/cloud-controller.xml.orig | sed -e "s@EC2_KEYPAIR@$ec2_keypair_name@g" > repository/conf/cloud-controller.xml
-
-cp -f repository/conf/cloud-controller.xml repository/conf/cloud-controller.xml.orig
-cat repository/conf/cloud-controller.xml.orig | sed -e "s@EC2_PROVIDER_END@@g" > repository/conf/cloud-controller.xml
-   
-cp -f repository/conf/cloud-controller.xml repository/conf/cloud-controller.xml.orig
-cat repository/conf/cloud-controller.xml.orig | sed -e "s@OPENSTACK_PROVIDER_START@!--@g" > repository/conf/cloud-controller.xml
-    
-cp -f repository/conf/cloud-controller.xml repository/conf/cloud-controller.xml.orig
-cat repository/conf/cloud-controller.xml.orig | sed -e "s@OPENSTACK_PROVIDER_END@--@g" > repository/conf/cloud-controller.xml
-
-cp -f repository/conf/cloud-controller.xml repository/conf/cloud-controller.xml.orig
-cat repository/conf/cloud-controller.xml.orig | sed -e "s@VCLOUD_PROVIDER_START@!--@g" > repository/conf/cloud-controller.xml
-
-cp -f repository/conf/cloud-controller.xml repository/conf/cloud-controller.xml.orig
-cat repository/conf/cloud-controller.xml.orig | sed -e "s@VCLOUD_PROVIDER_END@--@g" > repository/conf/cloud-controller.xml
+sed -i "s@EC2_PROVIDER_START@@g"  repository/conf/cloud-controller.xml
+sed -i "s@EC2_IDENTITY@$ec2_identity@g" repository/conf/cloud-controller.xml
+sed -i "s@EC2_CREDENTIAL@$ec2_credential@g" repository/conf/cloud-controller.xml
+sed -i "s@EC2_OWNER_ID@$ec2_owner_id@g" repository/conf/cloud-controller.xml
+sed -i "s@EC2_AVAILABILITY_ZONE@$ec2_availability_zone@g" repository/conf/cloud-controller.xml
+sed -i "s@EC2_SECURITY_GROUPS@$ec2_security_groups@g" repository/conf/cloud-controller.xml
+sed -i "s@EC2_KEYPAIR@$ec2_keypair_name@g" repository/conf/cloud-controller.xml
+sed -i "s@EC2_PROVIDER_END@@g" repository/conf/cloud-controller.xml
+sed -i "s@OPENSTACK_PROVIDER_START@!--@g" repository/conf/cloud-controller.xml
+sed -i "s@OPENSTACK_PROVIDER_END@--@g" repository/conf/cloud-controller.xml
+sed -i "s@VCLOUD_PROVIDER_START@!--@g" repository/conf/cloud-controller.xml
+sed -i "s@VCLOUD_PROVIDER_END@--@g" repository/conf/cloud-controller.xml
 
 popd
 

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/b1caebf6/tools/stratos-installer/stratos-openstack.sh
----------------------------------------------------------------------
diff --git a/tools/stratos-installer/stratos-openstack.sh b/tools/stratos-installer/stratos-openstack.sh
index fe9c97f..925333c 100755
--- a/tools/stratos-installer/stratos-openstack.sh
+++ b/tools/stratos-installer/stratos-openstack.sh
@@ -35,35 +35,18 @@ if [[ ! -d $log_path ]]; then
     mkdir -p $log_path
 fi
 
-pushd $cc_path
+pushd $stratos_extract_path
 
 echo "Set OpenStack provider specific info in repository/conf/cloud-controller.xml" >> $LOG
 
-cp -f repository/conf/cloud-controller.xml repository/conf/cloud-controller.xml.orig
-cat repository/conf/cloud-controller.xml.orig | sed -e "s@OPENSTACK_PROVIDER_START@@g" > repository/conf/cloud-controller.xml
-
-cp -f repository/conf/cloud-controller.xml repository/conf/cloud-controller.xml.orig
-cat repository/conf/cloud-controller.xml.orig | sed -e "s@OPENSTACK_IDENTITY@$openstack_identity@g" > repository/conf/cloud-controller.xml
-
-cp -f repository/conf/cloud-controller.xml repository/conf/cloud-controller.xml.orig
-cat repository/conf/cloud-controller.xml.orig | sed -e "s@OPENSTACK_CREDENTIAL@$openstack_credential@g" > repository/conf/cloud-controller.xml
-
-cp -f repository/conf/cloud-controller.xml repository/conf/cloud-controller.xml.orig
-cat repository/conf/cloud-controller.xml.orig | sed -e "s@OPENSTACK_ENDPOINT@$openstack_jclouds_endpoint@g" > repository/conf/cloud-controller.xml
-
-cp -f repository/conf/cloud-controller.xml repository/conf/cloud-controller.xml.orig
-cat repository/conf/cloud-controller.xml.orig | sed -e "s@OPENSTACK_PROVIDER_END@@g" > repository/conf/cloud-controller.xml
-
-cp -f repository/conf/cloud-controller.xml repository/conf/cloud-controller.xml.orig
-cat repository/conf/cloud-controller.xml.orig | sed -e "s@EC2_PROVIDER_START@!--@g" > repository/conf/cloud-controller.xml
-
-cp -f repository/conf/cloud-controller.xml repository/conf/cloud-controller.xml.orig
-cat repository/conf/cloud-controller.xml.orig | sed -e "s@EC2_PROVIDER_END@--@g" > repository/conf/cloud-controller.xml
-
-cp -f repository/conf/cloud-controller.xml repository/conf/cloud-controller.xml.orig
-cat repository/conf/cloud-controller.xml.orig | sed -e "s@VCLOUD_PROVIDER_START@!--@g" > repository/conf/cloud-controller.xml
-
-cp -f repository/conf/cloud-controller.xml repository/conf/cloud-controller.xml.orig
-cat repository/conf/cloud-controller.xml.orig | sed -e "s@VCLOUD_PROVIDER_END@--@g" > repository/conf/cloud-controller.xml
+sed -i "s@OPENSTACK_PROVIDER_START@@g" repository/conf/cloud-controller.xml
+sed -i "s@OPENSTACK_IDENTITY@$openstack_identity@g"  repository/conf/cloud-controller.xml
+sed -i "s@OPENSTACK_CREDENTIAL@$openstack_credential@g"  repository/conf/cloud-controller.xml
+sed -i "s@OPENSTACK_ENDPOINT@$openstack_jclouds_endpoint@g"  repository/conf/cloud-controller.xml
+sed -i "s@OPENSTACK_PROVIDER_END@@g"  repository/conf/cloud-controller.xml
+sed -i "s@EC2_PROVIDER_START@!--@g"  repository/conf/cloud-controller.xml
+sed -i "s@EC2_PROVIDER_END@--@g"  repository/conf/cloud-controller.xml
+sed -i "s@VCLOUD_PROVIDER_START@!--@g"  repository/conf/cloud-controller.xml
+sed -i "s@VCLOUD_PROVIDER_END@--@g"  repository/conf/cloud-controller.xml
 
 popd

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/b1caebf6/tools/stratos-installer/stratos-setup.sh
----------------------------------------------------------------------
diff --git a/tools/stratos-installer/stratos-setup.sh b/tools/stratos-installer/stratos-setup.sh
index a65fa40..ebd249d 100755
--- a/tools/stratos-installer/stratos-setup.sh
+++ b/tools/stratos-installer/stratos-setup.sh
@@ -26,44 +26,33 @@
 # Die on any error:
 set -e
 
-SLEEP=60
-
 source "./conf/stratos-setup.conf"
 export LOG=$log_path/stratos-setup.log
 
-mb="false"
-cc="false"
-as="false"
-sm="false"
-cep="false"
-product_list="mb;cc;cep;as;sm"
-enable_internal_git=false
+profile_list="default;cc;as;sm"
+profile="default"
+config_mb="true"
 activemq_client_libs=(activemq-broker-5.8.0.jar  activemq-client-5.8.0.jar  geronimo-j2ee-management_1.1_spec-1.0.1.jar  geronimo-jms_1.1_spec-1.1.1.jar  hawtbuf-1.2.jar)
-auto_start_servers="false"
 
 function help {
     echo ""
     echo "Usage:"
-    echo "stratos-setup.sh -u <host username> -p \"all\" [-s]"
+    echo "setup.sh -p \"<profile>\""
+    echo "product list : [default, cc, as, sm]"
     echo "Example:"
-    echo "sudo ./setup.sh -p \"all\""
+    echo "sudo ./setup.sh -p \"default\""
+    echo "sudo ./setup.sh -p \"cc\""
     echo ""
-    echo "-u: <host username> The login user of the host."
-    echo "-s: Start servers after installation."
+    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 ""
 }
 
-while getopts u:p:g:s opts
+while getopts p: opts
 do
   case $opts in
     p)
-        product_list=${OPTARG}
-        ;;
-    g)
-        enable_internal_git=${OPTARG}
-        ;;
-    s)
-        auto_start_servers="true"
+        profile_list=${OPTARG}
         ;;
     \?)
         help
@@ -73,36 +62,25 @@ do
 done
 
 
-arr=$(echo $product_list | tr " " "\n")
+arr=$(echo $profile_list | tr " " "\n")
 
 for x in $arr
 do
-    if [[ $x = "mb" ]]; then
-        mb="true"
-    fi
     if [[ $x = "cc" ]]; then
-        cc="true"
-    fi
-    if [[ $x = "cep" ]]; then
-        cep="true"
-    fi
-    if [[ $x = "as" ]]; then
-        as="true"
-    fi
-    if [[ $x = "sm" ]]; then
-        sm="true"
-    fi
-    if [[ $x = "all" ]]; then
-        mb="true"
-        cep="true"
-        cc="true"
-        as="true"
-        sm="true"
+        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
 
-product_list=`echo $product_list | sed 's/^ *//g' | sed 's/ *$//g'`
-if [[ -z $product_list || $product_list = "" ]]; then
+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
@@ -144,27 +122,23 @@ function valid_ip()
     return $stat
 }
 
-function helpsetup {
+function helpsetup() {
     echo ""
     echo "Please set up the $1 related environment variables correctly in conf/stratos-setup.conf"
     echo ""
 }
 
-function general_conf_validate {
+function general_conf_validate() {
     if [[ ! -d $setup_path ]]; then
         echo "Please specify the setup_path folder which contains stratos setup"
         exit 1
     fi
-    if [[ ! -d $stratos_path ]]; then
-        echo "Please specify the stratos_path folder which stratos will be installed"
-        exit 1
-    fi
-    if [[ ! -d $stratos_pack_path ]]; then
-        echo "Please specify the stratos_pack_path folder which contains stratos packs."
+    if [[ ! -d $stratos_packs ]]; then
+        echo "Please specify the stratos_packs folder which contains stratos packages"
         exit 1
     fi
-    if [[ ! -f $stratos_pack ]]; then
-        echo "Stratos_pack cannot be found at $stratos_pack"
+    if [[ ! -d $stratos_path ]]; then
+        echo "Please specify the stratos_path folder which stratos will be installed"
         exit 1
     fi
     if [[ ! -d $JAVA_HOME ]]; then
@@ -177,78 +151,157 @@ function general_conf_validate {
         echo "Please specify the stratos domain"
         exit 1
     fi
-    if [[ (-z $mb_port_offset || -z $mb_ip || -z $mb_hostname) ]]; then
-        echo "Please specify the ip, the port offset and the hostname of MB"
+    if [[ ! -f $stratos_pack_zip ]]; then
+        echo "Please copy the startos zip to the stratos pack folder"
         exit 1
     fi
-    if !(valid_ip $mb_ip); then 
-        echo "Please provide valid ip for MB's ip"
+    if [[ -z $mb_port ]]; then
+        echo "Please specify the port of MB"
         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
+    fi
 }
 
-function activemq_client_jar_validate {
-    if [[ ($cep = "true" || $cc = "true" || $as = "true" || $sm = "true") ]]; then
-	for activemq_client_lib in "${activemq_client_libs[@]}"
-	do
-	        lib_path=$stratos_pack_path/$activemq_client_lib
-		if [[ ! -f $lib_path ]]; then
-		    echo "Please copy the following activemq client jar into the $stratos_pack_path:"
-		    echo $activemq_client_lib
-		    exit 1
-		fi
-	done
+function cc_related_popup() {
+    while read -p "Please provide cloud controller ip:" cc_ip
+    do
+	if !(valid_ip $cc_ip); then
+	    echo "Please provide valid ips for CC"	 
+	else 
+            export cc_ip
+	    break 
+	fi
+    done 
+
+    while read -p "Please provide cloud controller hostname:" cc_hostname
+    do
+	if [[ -z $cc_hostname ]]; then
+	    echo "Please specify valid hostname for CC"	 
+	else 
+            export cc_hostname
+	    break 
+	fi
+    done
 
-    fi
+    while read -p "Please provide cloud controller port offset:" cc_port_offset
+    do
+	if [[ -z $cc_port_offset ]]; then
+	    echo "Please specify the port offset of CC"	 
+	else 
+            export cc_port_offset
+	    break 
+	fi
+    done
 }
 
-function mb_conf_validate {
-    if [[ -z $mb_path ]]; then
-	helpsetup MB
-	exit 1
-    fi
+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 cep_conf_validate {
-    if [[ (-z $cep_path || -z $cep_port_offset) ]]; then
-	helpsetup CEP
-	exit 1
-    fi
-    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
+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 cc_conf_validate {
-    if [[ (-z $cc_path || -z $cc_port_offset) ]]; then
-	helpsetup CC
-	exit 1
+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"
@@ -257,48 +310,23 @@ function cc_conf_validate {
     fi
 }
 
-function as_conf_validate {
-    if [[ (-z $as_path || -z $as_port_offset) ]]; then
-	helpsetup AS
-	exit 1
-    fi
-    if [[ -z $cc_port_offset || -z $sm_port_offset ]]; then
-        echo "Please specify the port offset of SM and/or CC"
-        exit 1
-    fi
-    if [[ -z $sm_ip || -z $cc_ip ]]; then
-        echo "Please specify the ips of SM and/or CC"
-        exit 1
-    elif !(valid_ip $sm_ip && valid_ip $cc_ip ); then
-        echo "Please provide valid ips for SM and/or CC"
-        exit 1
-    fi
-    if [[ -z $cc_hostname || -z $sm_hostname ]]; then
-	echo "Please specify valid hostname for SM and/or CC"
-	exit 1
+
+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 $sm_path || -z $sm_port_offset) ]]; then
-	helpsetup SM
-	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 [[ -z $cc_port_offset || -z $as_port_offset ]]; then
-        echo "Please specify the port offset of AS and/or CC"
-        exit 1
-    fi
-    if [[ -z $sm_ip || -z $as_ip || -z $cc_ip ]]; then
-        echo "Please specify the ips of SM and/or AS and/or CC"
-        exit 1
-    elif !(valid_ip $sm_ip && valid_ip $cc_ip && valid_ip $as_ip); then
-        echo "Please provide valid ips for SM and/or AS and/or CC"
-        exit 1
-    fi
+
+function sm_conf_validate() {
     if [[ -z $puppet_ip ]]; then
         echo "Please specify the ip of puppet master"
         exit 1
@@ -314,30 +342,36 @@ function sm_conf_validate {
         echo "Please specify the relevant puppet environment"
         exit 1
     fi
-    if [[ -z $cc_hostname || -z $as_hostname ]]; then
-	echo "Please specify valid hostname for AS and/or CC"
-	exit 1
+    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))
 }
 
 
-general_conf_validate
-activemq_client_jar_validate
-if [[ $mb = "true" ]]; then
-    mb_conf_validate
-fi
-if [[ $cep = "true" ]]; then
-    cep_conf_validate
-fi
-if [[ $cc = "true" ]]; then
-    cc_conf_validate
-fi
-if [[ $as = "true" ]]; then
-    as_conf_validate
-fi
-if [[ $sm = "true" ]]; then
-    sm_conf_validate
-fi
+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.
@@ -346,6 +380,23 @@ if [ "$UID" -ne "0" ]; then
 	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
@@ -355,116 +406,51 @@ echo ""
 echo "For all the questions asked while during executing the script please just press the enter button"
 echo ""
 
-if [[ $mb = "true" ]]; then
-    if [[ ! -d $mb_path ]]; then
-        echo "Extracting $mb_pack_path"
-        tar -zxvf  $mb_pack_path -C $stratos_path
-    fi
-fi
 
-if [[ ! -d $resource_path ]]; then
-     cp -rf ./resources $stratos_path
+# 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 [[ ! -d $stratos_pack ]]; then
-     echo "Extracting $stratos_pack"
-     unzip -q $stratos_pack -d $stratos_path
+if [[ ($profile = "default" && $config_mb = "true") ]]; then
+    echo "Extracting ActiveMQ"
+    tar -xzf $activemq_pack -C $stratos_path
 fi
 
-
-
 # ------------------------------------------------
-# Setup MB
+# Setup General
 # ------------------------------------------------
-function mb_setup {
-    echo "Setup ActiveMQ" >> $LOG
-    echo "Configuring the Message Broker"
-
-    pushd $mb_path
-
-    echo "End configuring the Message Broker"
-    popd #mb_path
-}
-
-if [[ $mb = "true" ]]; then
-    mb_setup
-fi
-
-function general_setup {
-    echo "Setup Stratos" >> $LOG
-    echo "Configuring Stratos ..."
+function general_setup() {
 
-    cp -f ./config/cep/repository/conf/activemq/jndi.properties $stratos_dist_path/repository/conf/
-    for activemq_client_lib in "${activemq_client_libs[@]}" 
-    do
-    	cp -f $stratos_pack_path/$activemq_client_lib $stratos_dist_path/repository/components/lib/
-    done
-
-    pushd $stratos_dist_path
+    cp -f ./config/all/repository/conf/activemq/jndi.properties $stratos_extract_path/repository/conf/
 
+    pushd $stratos_extract_path
     echo "In repository/conf/carbon.xml"
-    cp -f repository/conf/carbon.xml repository/conf/carbon.xml.orig
-    cat repository/conf/carbon.xml.orig | sed -e "s@<Offset>0</Offset>@<Offset>${offset}</Offset>@g" > repository/conf/carbon.xml
+    sed -i "s@<Offset>0</Offset>@<Offset>${offset}</Offset>@g" repository/conf/carbon.xml
 
     echo "In repository/conf/jndi.properties"
-    cp -f repository/conf/jndi.properties repository/conf/jndi.properties.orig
-    cat repository/conf/jndi.properties.orig | sed -e "s@MB_HOSTNAME:MB_LISTEN_PORT@$mb_hostname:$cep_mb_listen_port@g" > repository/conf/jndi.properties
-
+    sed -i "s@MB_HOSTNAME:MB_LISTEN_PORT@$mb_ip:$mb_port@g" repository/conf/jndi.properties
     popd
-}
-
-general_setup 
-
-# ------------------------------------------------
-# Setup CEP
-# ------------------------------------------------
-function cep_setup {
-    echo "Setup CEP" >> $LOG
-    echo "Configuring the Complex Event Processor"
 
-    cp -f $cep_extension_jar $cep_path/repository/components/lib/
-    cp -f $cep_artifacts_path/eventbuilders/*.xml $cep_path/repository/deployment/server/eventbuilders/
-    cp -f $cep_artifacts_path/inputeventadaptors/*.xml $cep_path/repository/deployment/server/inputeventadaptors/
-    cp -f $cep_artifacts_path/outputeventadaptors/*.xml $cep_path/repository/deployment/server/outputeventadaptors/
-    cp -f $cep_artifacts_path/executionplans/*.xml $cep_path/repository/deployment/server/executionplans/
-    cp -f $cep_artifacts_path/eventformatters/*.xml $cep_path/repository/deployment/server/eventformatters/
-    cp -f $cep_artifacts_path/streamdefinitions/*.xml $cep_path/repository/conf/
-
-    pushd $cep_path
-
-    echo "In outputeventadaptors"
-    cp -f repository/deployment/server/outputeventadaptors/JMSOutputAdaptor.xml repository/deployment/server/outputeventadaptors/JMSOutputAdaptor.xml.orig
-    cat repository/deployment/server/outputeventadaptors/JMSOutputAdaptor.xml.orig | sed -e "s@CEP_HOME@$cep_path@g" > repository/deployment/server/outputeventadaptors/JMSOutputAdaptor.xml
-
-    echo "In repository/conf/siddhi/siddhi.extension"
-    cp -f repository/conf/siddhi/siddhi.extension repository/conf/siddhi/siddhi.extension.orig
-    echo "org.apache.stratos.cep.extension.GradientFinderWindowProcessor" >> repository/conf/siddhi/siddhi.extension.orig
-    echo "org.apache.stratos.cep.extension.SecondDerivativeFinderWindowProcessor" >> repository/conf/siddhi/siddhi.extension.orig
-    echo "org.apache.stratos.cep.extension.FaultHandlingWindowProcessor" >> repository/conf/siddhi/siddhi.extension.orig
-    mv -f repository/conf/siddhi/siddhi.extension.orig repository/conf/siddhi/siddhi.extension
-
-    echo "End configuring the Complex Event Processor"
-    popd #cep_path
+    for activemq_client_lib in "${activemq_client_libs[@]}" 
+    do
+    	cp -f $stratos_packs/$activemq_client_lib $stratos_extract_path/repository/components/lib/
+    done
 }
-if [[ $cep = "true" ]]; then
-    cep_setup
-fi
 
 
 # ------------------------------------------------
-# Setup CC
+# Setup cc
 # ------------------------------------------------
-function cc_setup {
+function cc_setup() {
     echo "Setup CC" >> $LOG
     echo "Configuring the Cloud Controller"
 
-    echo "Creating payload directory ... " >> $LOG
-    if [[ ! -d $cc_path/repository/resources/payload ]]; then
-        mkdir -p $cc_path/repository/resources/payload
-    fi
-
-    cp -f ./config/cc/repository/conf/cloud-controller.xml $cc_path/repository/conf/
+    cp -f ./config/all/repository/conf/cloud-controller.xml $stratos_extract_path/repository/conf/ 
 
+    export cc_path=$stratos_extract_path
     echo "In repository/conf/cloud-controller.xml"
     if [[ $ec2_provider_enabled = true ]]; then
         ./stratos-ec2.sh
@@ -476,146 +462,142 @@ function cc_setup {
         ./stratos-vcloud.sh
     fi
 
-    pushd $cc_path
+    pushd $stratos_extract_path
     
-    cp -f repository/conf/cloud-controller.xml repository/conf/cloud-controller.xml.orig
-    cat repository/conf/cloud-controller.xml.orig | sed -e "s@MB_HOSTNAME:MB_LISTEN_PORT@$mb_hostname:$cc_mb_listen_port@g" > repository/conf/cloud-controller.xml
-
-    popd #cc_path
+    popd 
     echo "End configuring the Cloud Controller"
 }
 
-if [[ $cc = "true" ]]; then
-   cc_setup
-fi
 
 # ------------------------------------------------
 # Setup AS
 # ------------------------------------------------   
-function as_setup {
+function as_setup() {
     echo "Setup AS" >> $LOG
     echo "Configuring the Auto Scalar"
 
-    cp -f ./config/as/repository/conf/autoscaler.xml $as_path/repository/conf/
+    cp -f ./config/all/repository/conf/autoscaler.xml $stratos_extract_path/repository/conf/
 
-    pushd $as_path
+    pushd $stratos_extract_path
 
     echo "In repository/conf/autoscaler.xml"
-    cp -f repository/conf/autoscaler.xml repository/conf/autoscaler.xml.orig
-    cat repository/conf/autoscaler.xml.orig | sed -e "s@CC_HOSTNAME@$cc_hostname@g" > repository/conf/autoscaler.xml
-
-    cp -f repository/conf/autoscaler.xml repository/conf/autoscaler.xml.orig
-    cat repository/conf/autoscaler.xml.orig | sed -e "s@CC_LISTEN_PORT@$as_cc_https_port@g" > repository/conf/autoscaler.xml
-
-    cp -f repository/conf/autoscaler.xml repository/conf/autoscaler.xml.orig
-    cat repository/conf/autoscaler.xml.orig | sed -e "s@SM_HOSTNAME@$sm_hostname@g" > repository/conf/autoscaler.xml
+    sed -i "s@CC_HOSTNAME@$cc_hostname@g" repository/conf/autoscaler.xml
+    sed -i "s@CC_LISTEN_PORT@$as_cc_https_port@g" repository/conf/autoscaler.xml
+    sed -i "s@SM_HOSTNAME@$sm_hostname@g" repository/conf/autoscaler.xml
+    sed -i "s@SM_LISTEN_PORT@$as_sm_https_port@g" repository/conf/autoscaler.xml
 
-    cp -f repository/conf/autoscaler.xml repository/conf/autoscaler.xml.orig
-    cat repository/conf/autoscaler.xml.orig | sed -e "s@SM_LISTEN_PORT@$as_sm_https_port@g" > repository/conf/autoscaler.xml
-
-    popd #as_path
-    echo "End configuring the Auto smalar"
+    popd
+    echo "End configuring the Auto scalar"
 }
 
-if [[ $as = "true" ]]; then
-    as_setup
-fi
-
-
 
 # ------------------------------------------------
 # Setup SM
 # ------------------------------------------------
-function sm_setup {
+function sm_setup() {
     echo "Setup SM" >> $LOG
     echo "Configuring Stratos Manager"
 
-    cp -f ./config/sm/repository/conf/cartridge-config.properties $sm_path/repository/conf/
-    cp -f ./config/sm/repository/conf/datasources/master-datasources.xml $sm_path/repository/conf/datasources/
-    cp -f $mysql_connector_jar $sm_path/repository/components/lib/
-
-    pushd $sm_path
-
-    echo "In repository/conf/cartridge-config.properties" >> $LOG
-    cp -f repository/conf/cartridge-config.properties repository/conf/cartridge-config.properties.orig
-    cat repository/conf/cartridge-config.properties.orig | sed -e "s@CC_HOSTNAME:CC_HTTPS_PORT@$cc_hostname:$sm_cc_https_port@g" > repository/conf/cartridge-config.properties
-
-    cp -f repository/conf/cartridge-config.properties repository/conf/cartridge-config.properties.orig
-    cat repository/conf/cartridge-config.properties.orig | sed -e "s@AS_HOSTNAME:AS_HTTPS_PORT@$as_hostname:$sm_as_https_port@g" > repository/conf/cartridge-config.properties
-
-    cp -f repository/conf/cartridge-config.properties repository/conf/cartridge-config.properties.orig
-    cat repository/conf/cartridge-config.properties.orig | sed -e "s@PUPPET_IP@$sm_puppet_ip@g" > repository/conf/cartridge-config.properties
+    cp -f ./config/all/repository/conf/cartridge-config.properties $stratos_extract_path/repository/conf/
+    cp -f ./config/all/repository/conf/datasources/master-datasources.xml $stratos_extract_path/repository/conf/datasources/
+    cp -f $mysql_connector_jar $stratos_extract_path/repository/components/lib/
 
-    cp -f repository/conf/cartridge-config.properties repository/conf/cartridge-config.properties.orig
-    cat repository/conf/cartridge-config.properties.orig | sed -e "s@PUPPET_HOSTNAME@$sm_puppet_hostname@g" > repository/conf/cartridge-config.properties
+    pushd $stratos_extract_path
 
-    cp -f repository/conf/cartridge-config.properties repository/conf/cartridge-config.properties.orig
-    cat repository/conf/cartridge-config.properties.orig | sed -e "s@PUPPET_ENV@$sm_puppet_environment@g" > repository/conf/cartridge-config.properties
+    echo "In repository/conf/cartridge-config.properties"
+    sed -i "s@CC_HOSTNAME:CC_HTTPS_PORT@$cc_hostname:$sm_cc_https_port@g" repository/conf/cartridge-config.properties
+    sed -i "s@AS_HOSTNAME:AS_HTTPS_PORT@$as_hostname:$sm_as_https_port@g" repository/conf/cartridge-config.properties
+    sed -i "s@PUPPET_IP@$puppet_ip@g" repository/conf/cartridge-config.properties
+    sed -i "s@PUPPET_HOSTNAME@$puppet_hostname@g" repository/conf/cartridge-config.properties
+    sed -i "s@PUPPET_ENV@$puppet_environment@g" repository/conf/cartridge-config.properties
 
-    echo "In repository/conf/datasources/master-datasources.xml" >> $LOG
-    cp -f repository/conf/datasources/master-datasources.xml repository/conf/datasources/master-datasources.xml.orig
-    cat repository/conf/datasources/master-datasources.xml.orig | sed -e "s@USERSTORE_DB_HOSTNAME@$userstore_db_hostname@g" > repository/conf/datasources/master-datasources.xml
-
-    cp -f repository/conf/datasources/master-datasources.xml repository/conf/datasources/master-datasources.xml.orig
-    cat repository/conf/datasources/master-datasources.xml.orig | sed -e "s@USERSTORE_DB_PORT@$userstore_db_port@g" > repository/conf/datasources/master-datasources.xml
-
-    cp -f repository/conf/datasources/master-datasources.xml repository/conf/datasources/master-datasources.xml.orig
-    cat repository/conf/datasources/master-datasources.xml.orig | sed -e "s@USERSTORE_DB_SCHEMA@$userstore_db_schema@g" > repository/conf/datasources/master-datasources.xml
-
-    cp -f repository/conf/datasources/master-datasources.xml repository/conf/datasources/master-datasources.xml.orig
-    cat repository/conf/datasources/master-datasources.xml.orig | sed -e "s@USERSTORE_DB_USER@$userstore_db_user@g" > repository/conf/datasources/master-datasources.xml
-
-    cp -f repository/conf/datasources/master-datasources.xml repository/conf/datasources/master-datasources.xml.orig
-    cat repository/conf/datasources/master-datasources.xml.orig | sed -e "s@USERSTORE_DB_PASS@$userstore_db_pass@g" > repository/conf/datasources/master-datasources.xml
-
-    popd # sm_path
+    echo "In repository/conf/datasources/master-datasources.xml"
+    sed -i "s@USERSTORE_DB_HOSTNAME@$userstore_db_hostname@g" repository/conf/datasources/master-datasources.xml
+    sed -i "s@USERSTORE_DB_PORT@$userstore_db_port@g" repository/conf/datasources/master-datasources.xml
+    sed -i "s@USERSTORE_DB_SCHEMA@$userstore_db_schema@g" repository/conf/datasources/master-datasources.xml
+    sed -i "s@USERSTORE_DB_USER@$userstore_db_user@g" repository/conf/datasources/master-datasources.xml
+    sed -i "s@USERSTORE_DB_PASS@$userstore_db_pass@g" repository/conf/datasources/master-datasources.xml
 
+    popd
 
     # Database Configuration
     # -----------------------------------------------
     echo "Create and configure MySql Databases" >> $LOG 
-
     echo "Creating userstore database"
 
     pushd $resource_path
-    cp -f mysql.sql mysql.sql.orig
-    cat mysql.sql.orig | sed -e "s@USERSTORE_DB_SCHEMA@$userstore_db_schema@g" > mysql.sql
+    sed -i "s@USERSTORE_DB_SCHEMA@$userstore_db_schema@g" mysql.sql
 
-    popd # resource_path
+    popd
 
     mysql -u$userstore_db_user -p$userstore_db_pass < $resource_path/mysql.sql
-    
-    #Copy https://svn.wso2.org/repos/wso2/scratch/hosting/build/tropos/resources/append_zone_file.sh into /opt/scripts folder
-    if [[ ! -d $stratos_path/scripts ]]; then
-        mkdir -p $stratos_path/scripts
-    fi
-    cp -f ./scripts/add_entry_zone_file.sh $stratos_path/scripts/add_entry_zone_file.sh
-    cp -f ./scripts/remove_entry_zone_file.sh $stratos_path/scripts/remove_entry_zone_file.sh
+    echo "End configuring the SM"
+}
 
 
-    echo "End configuring the SM"
+# ------------------------------------------------
+# Setup CEP
+# ------------------------------------------------
+function cep_setup() {
+    echo "Setup CEP" >> $LOG
+    echo "Configuring the Complex Event Processor"
+
+    cp -f $cep_extension_jar $stratos_extract_path/repository/components/lib/
+    cep_xml_path=$stratos_extract_path/repository/deployment/server
+
+    test -d "$cep_xml_path/eventbuilders" || mkdir -p "$cep_xml_path/eventbuilders" && cp -f $cep_artifacts_path/eventbuilders/*.xml $cep_xml_path/eventbuilders/
+    test -d "$cep_xml_path/inputeventadaptors" || mkdir -p "$cep_xml_path/inputeventadaptors" && cp -f $cep_artifacts_path/inputeventadaptors/*.xml $cep_xml_path/inputeventadaptors/
+    test -d "$cep_xml_path/outputeventadaptors" || mkdir -p "$cep_xml_path/outputeventadaptors" && cp -f $cep_artifacts_path/outputeventadaptors/*.xml $cep_xml_path/outputeventadaptors/
+    test -d "$cep_xml_path/executionplans" || mkdir -p "$cep_xml_path/executionplans" && cp -f $cep_artifacts_path/executionplans/*.xml $cep_xml_path/executionplans/
+    test -d "$cep_xml_path/eventformatters" || mkdir -p "$cep_xml_path/eventformatters" && cp -f $cep_artifacts_path/eventformatters/*.xml $cep_xml_path/eventformatters/
+    test -d "$cep_xml_path/streamdefinitions" || mkdir -p "$cep_xml_path/streamdefinitions" && cp -f $cep_artifacts_path/streamdefinitions/*.xml $cep_xml_path/streamdefinitions/
+
+    pushd $stratos_extract_path
+
+    echo "In outputeventadaptors"
+    sed -i "s@CEP_HOME@$stratos_extract_path@g" repository/deployment/server/outputeventadaptors/JMSOutputAdaptor.xml
+
+    echo "In repository/conf/siddhi/siddhi.extension"
+    test -d "repository/conf/siddhi" || mkdir -p "repository/conf/siddhi" && touch repository/conf/siddhi/siddhi.extension
+    cp -f repository/conf/siddhi/siddhi.extension repository/conf/siddhi/siddhi.extension.orig
+    echo "org.apache.stratos.cep.extension.GradientFinderWindowProcessor" >> repository/conf/siddhi/siddhi.extension.orig
+    echo "org.apache.stratos.cep.extension.SecondDerivativeFinderWindowProcessor" >> repository/conf/siddhi/siddhi.extension.orig
+    echo "org.apache.stratos.cep.extension.FaultHandlingWindowProcessor" >> repository/conf/siddhi/siddhi.extension.orig
+    mv -f repository/conf/siddhi/siddhi.extension.orig repository/conf/siddhi/siddhi.extension
+
+    echo "End configuring the Complex Event Processor"
+    popd
 }
 
-if [[ $sm = "true" ]]; then
+
+general_setup
+if [[ $profile = "cc" ]]; then
+    cc_setup
+elif [[ $profile = "as" ]]; then
+    as_setup
+elif [[ $profile = "sm" ]]; then
+    sm_setup
+else
+    cc_setup
+    as_setup
     sm_setup
+    cep_setup   
 fi
 
- 
 # ------------------------------------------------
 # Mapping domain/host names 
 # ------------------------------------------------
 
 cp -f /etc/hosts hosts.tmp
 
-
-echo "$mb_ip $mb_hostname	# message broker hostname"	>> hosts.tmp
-
-if [[ $sm = "true" || $as = "true" ]]; then
+echo "$host_ip $sm_hostname	# stratos domain"	>> hosts.tmp
+ 
+if [[ $profile = "sm" || $profile = "as" ]]; then
     echo "$sm_ip $sm_hostname	# stratos domain"	>> hosts.tmp
     echo "$cc_ip $cc_hostname	# cloud controller hostname"	>> hosts.tmp
 fi
 
-if [[ $sm = "true" ]]; then
+if [[ $profile = "sm" ]]; then
     echo "$as_ip $as_hostname	# auto scalar hostname"	>> hosts.tmp
 fi
 
@@ -630,11 +612,9 @@ chown $host_user:$host_user $stratos_path -R
 
 echo "Apache Stratos setup has successfully completed"
 
-if [[ $auto_start_servers != "true" ]]; then
-    read -p "Do you want to start the servers [y/n]? " answer
-    if [[ $answer != y ]] ; then
-        exit 1
-    fi
+read -p "Do you want to start the servers [y/n]? " answer
+if [[ $answer != y ]] ; then
+   exit 1
 fi
 
 echo "Starting the servers" >> $LOG
@@ -645,10 +625,10 @@ chown -R $host_user.$host_user $log_path
 chmod -R 777 $log_path
 
 export setup_dir=$PWD
-su - $host_user -c "source $setup_dir/conf/stratos-setup.conf;$setup_dir/stratos-start-servers.sh -p\"$product_list\" >> $LOG"
+su - $host_user -c "source $setup_path/conf/stratos-setup.conf;$setup_path/stratos-start-servers.sh -p\"$profile\" >> $LOG"
 
 echo "Servers started. Please look at $LOG file for server startup details"
-if [[ $sm == "true" ]]; then
+if [[ $profile == "default" || $profile == "sm" ]]; then
     echo "**************************************************************"
     echo "Management Console : https://$stratos_domain:$sm_https_port/console"
     echo "**************************************************************"

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/b1caebf6/tools/stratos-installer/stratos-start-servers.sh
----------------------------------------------------------------------
diff --git a/tools/stratos-installer/stratos-start-servers.sh b/tools/stratos-installer/stratos-start-servers.sh
index 435f695..f3d03c7 100755
--- a/tools/stratos-installer/stratos-start-servers.sh
+++ b/tools/stratos-installer/stratos-start-servers.sh
@@ -29,18 +29,22 @@ product_list=$1
 export LOG=$log_path/stratos.log
 SLEEP=40
 
+profile="default"
+
 if [[ -f ./conf/stratos-setup.conf ]]; then
     source "./conf/stratos-setup.conf"
+    echo "source it"
 fi
 
+
 function help {
     echo ""
     echo "Give one or more of the servers to start on this machine. The available servers are"
-    echo "mb, cc, as, sm, cep, all. 'all' means you need to start all servers."
+    echo "cc, as, sm, default. 'default' means you need to start all servers."
     echo "usage:"
-    echo "stratos-start-servers.sh -p\"<product list>\""
+    echo "stratos-start-servers.sh -p\"<profile>\""
     echo "eg."
-    echo "stratos-start-servers.sh -p\"cc sm\""
+    echo "stratos-start-servers.sh -p\"cc\""
     echo ""
 }
 
@@ -48,65 +52,45 @@ while getopts p: opts
 do
   case $opts in
     p)
-        product_list=${OPTARG}
-        echo $product_list
+        profile_list=${OPTARG}
         ;;
-    *)
+    \?)
         help
         exit 1
         ;;
   esac
 done
-arr=$(echo $product_list | tr ";" "\n")
+
+
+arr=$(echo $profile_list | tr " " "\n")
 
 for x in $arr
 do
-    if [[ $x = "mb" ]]; then
-        mb="true"
-    fi
-    if [[ $x = "cep" ]]; then
-        cep="true"
-    fi
     if [[ $x = "cc" ]]; then
-        cc="true"
-    fi
-    if [[ $x = "as" ]]; then
-        as="true"
-    fi
-    if [[ $x = "sm" ]]; then
-        sm="true"
-    fi
-    if [[ $x = "all" ]]; then
-	mb="true"
-        cc="true"
-        as="true"
-        sm="true"
-        cep="true"
+        profile="cc"
+    elif [[ $x = "as" ]]; then
+        profile="as"
+    elif [[ $x = "sm" ]]; then
+        profile="sm"
+    else
+        echo "Inavlid profile : 'default' profile will be selected."
+        profile="default"
     fi
 done
-product_list=`echo $product_list | sed 's/^ *//g' | sed 's/ *$//g'`
-if [[ -z $product_list || $product_list = "" ]]; then
-    help
-    exit 1
-fi
-
-if [[ $mb = "true" ]]; then
-    echo ${mb_path}
 
+if [[ $profile = "default" ]]; then
     echo "Starting ActiveMQ server ..." >> $LOG
-    ${mb_path}/bin/activemq start
-    
+    $activemq_path/bin/activemq start
     echo "ActiveMQ server started" >> $LOG
     sleep $SLEEP
     sleep $SLEEP
 fi
 
-echo ${stratos_dist_path}
-
-    echo "Starting Stratos server ..." >> $LOG
-    ${stratos_dist_path}/bin/stratos.sh start
-    echo "Stratos server started" >> $LOG
-    sleep $SLEEP
-    sleep $SLEEP
+echo "Starting Stratos server ..." >> $LOG
+echo "$stratos_extract_path/bin/stratos.sh -Dprofile=$profile start"
+$stratos_extract_path/bin/stratos.sh -Dprofile=$profile start
+echo "Stratos server started" >> $LOG
+sleep $SLEEP
+sleep $SLEEP
 
 

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/b1caebf6/tools/stratos-installer/stratos-vcloud.sh
----------------------------------------------------------------------
diff --git a/tools/stratos-installer/stratos-vcloud.sh b/tools/stratos-installer/stratos-vcloud.sh
index 51bee05..9bc7fa8 100755
--- a/tools/stratos-installer/stratos-vcloud.sh
+++ b/tools/stratos-installer/stratos-vcloud.sh
@@ -35,35 +35,18 @@ if [[ ! -d $log_path ]]; then
     mkdir -p $log_path
 fi
 
-pushd $cc_path
+pushd $stratos_extract_path
 
 echo "Set vCloud provider specific info in repository/conf/cloud-controller.xml" >> $LOG
 
-cp -f repository/conf/cloud-controller.xml repository/conf/cloud-controller.xml.orig
-cat repository/conf/cloud-controller.xml.orig | sed -e "s@VCLOUD_PROVIDER_START@@g" > repository/conf/cloud-controller.xml
-
-cp -f repository/conf/cloud-controller.xml repository/conf/cloud-controller.xml.orig
-cat repository/conf/cloud-controller.xml.orig | sed -e "s/VCLOUD_IDENTITY/$vcloud_identity/g" > repository/conf/cloud-controller.xml
-
-cp -f repository/conf/cloud-controller.xml repository/conf/cloud-controller.xml.orig
-cat repository/conf/cloud-controller.xml.orig | sed -e "s/VCLOUD_CREDENTIAL/$vcloud_credential/g" > repository/conf/cloud-controller.xml
-
-cp -f repository/conf/cloud-controller.xml repository/conf/cloud-controller.xml.orig
-cat repository/conf/cloud-controller.xml.orig | sed -e "s@VCLOUD_ENDPOINT@$vcloud_jclouds_endpoint@g" > repository/conf/cloud-controller.xml
-
-cp -f repository/conf/cloud-controller.xml repository/conf/cloud-controller.xml.orig
-cat repository/conf/cloud-controller.xml.orig | sed -e "s@VCLOUD_PROVIDER_END@@g" > repository/conf/cloud-controller.xml
-
-cp -f repository/conf/cloud-controller.xml repository/conf/cloud-controller.xml.orig
-cat repository/conf/cloud-controller.xml.orig | sed -e "s@EC2_PROVIDER_START@!--@g" > repository/conf/cloud-controller.xml
-
-cp -f repository/conf/cloud-controller.xml repository/conf/cloud-controller.xml.orig
-cat repository/conf/cloud-controller.xml.orig | sed -e "s@EC2_PROVIDER_END@--@g" > repository/conf/cloud-controller.xml
-
-cp -f repository/conf/cloud-controller.xml repository/conf/cloud-controller.xml.orig
-cat repository/conf/cloud-controller.xml.orig | sed -e "s@OPENSTACK_PROVIDER_START@!--@g" > repository/conf/cloud-controller.xml
-
-cp -f repository/conf/cloud-controller.xml repository/conf/cloud-controller.xml.orig
-cat repository/conf/cloud-controller.xml.orig | sed -e "s@OPENSTACK_PROVIDER_END@--@g" > repository/conf/cloud-controller.xml
+sed -i "s@VCLOUD_PROVIDER_START@@g" repository/conf/cloud-controller.xml
+sed -i "s/VCLOUD_IDENTITY/$vcloud_identity/g" repository/conf/cloud-controller.xml
+sed -i "s/VCLOUD_CREDENTIAL/$vcloud_credential/g" repository/conf/cloud-controller.xml
+sed -i "s@VCLOUD_ENDPOINT@$vcloud_jclouds_endpoint@g" repository/conf/cloud-controller.xml
+sed -i "s@VCLOUD_PROVIDER_END@@g" repository/conf/cloud-controller.xml
+sed -i "s@EC2_PROVIDER_START@!--@g" repository/conf/cloud-controller.xml
+sed -i "s@EC2_PROVIDER_END@--@g" repository/conf/cloud-controller.xml
+sed -i "s@OPENSTACK_PROVIDER_START@!--@g" repository/conf/cloud-controller.xml
+sed -i "s@OPENSTACK_PROVIDER_END@--@g" repository/conf/cloud-controller.xml
 
 popd