You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by la...@apache.org on 2015/05/12 11:54:42 UTC

[2/2] stratos git commit: s/init-script/init-scripts

s/init-script/init-scripts


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

Branch: refs/heads/master
Commit: 0fa71440d70da37789479d4f44996c8b6f1766e9
Parents: ee03531
Author: Lahiru Sandaruwan <la...@apache.org>
Authored: Tue May 12 15:24:29 2015 +0530
Committer: Lahiru Sandaruwan <la...@apache.org>
Committed: Tue May 12 15:24:29 2015 +0530

----------------------------------------------------------------------
 tools/init-script/README.md       |   4 -
 tools/init-script/centos/init.sh  | 147 -----------------------------
 tools/init-script/config-gce.sh   | 101 --------------------
 tools/init-script/config.sh       | 104 ---------------------
 tools/init-script/init-gce.sh     | 146 -----------------------------
 tools/init-script/init-vcloud.sh  |  80 ----------------
 tools/init-script/init.sh         | 165 ---------------------------------
 tools/init-scripts/README.md      |   4 +
 tools/init-scripts/centos/init.sh | 147 +++++++++++++++++++++++++++++
 tools/init-scripts/config-gce.sh  | 101 ++++++++++++++++++++
 tools/init-scripts/config.sh      | 104 +++++++++++++++++++++
 tools/init-scripts/init-gce.sh    | 146 +++++++++++++++++++++++++++++
 tools/init-scripts/init-vcloud.sh |  80 ++++++++++++++++
 tools/init-scripts/init.sh        | 165 +++++++++++++++++++++++++++++++++
 14 files changed, 747 insertions(+), 747 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/0fa71440/tools/init-script/README.md
----------------------------------------------------------------------
diff --git a/tools/init-script/README.md b/tools/init-script/README.md
deleted file mode 100644
index 34e503e..0000000
--- a/tools/init-script/README.md
+++ /dev/null
@@ -1,4 +0,0 @@
-Stratos Cartridge Init Scripts
-==============================
-
-This folder will host the init scripts of cartridge instances. Purpose of these scripts are to kick off the startup actions such as downloading user-data(payload), run puppet agent etc.

http://git-wip-us.apache.org/repos/asf/stratos/blob/0fa71440/tools/init-script/centos/init.sh
----------------------------------------------------------------------
diff --git a/tools/init-script/centos/init.sh b/tools/init-script/centos/init.sh
deleted file mode 100644
index bc2aa4b..0000000
--- a/tools/init-script/centos/init.sh
+++ /dev/null
@@ -1,147 +0,0 @@
-#!/bin/bash
-# --------------------------------------------------------------
-#
-# 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.
-#
-# --------------------------------------------------------------
-
-MKDIR=`which mkdir`
-UNZIP=`which unzip`
-ECHO=`which echo`
-FIND=`which find`
-GREP=`which grep`
-RM=`which rm`
-XARGS=`which xargs`
-SED=`which sed`
-CUT=`which cut`
-AWK=`which awk`
-IFCONFIG=`which ifconfig`
-HOSTNAME=`which hostname`
-SLEEP=`which sleep`
-TR=`which tr`
-HEAD=`which head`
-WGET=`which wget`
-PUPPETD=`which puppet`
-AGENT="agent"
-PUPPETAGENT="${PUPPETD} ${AGENT}"
-
-COMMAND="${PUPPETAGENT} -vt"
-IP=`${IFCONFIG} eth0 | ${GREP} -e "inet addr" | ${AWK} '{print $2}' | ${CUT} -d ':' -f 2`
-LOG=/tmp/puppet-init.log
-
-HOSTSFILE=/etc/hosts
-HOSTNAMEFILE=/etc/hostname
-PUPPETCONF=/etc/puppet/puppet.conf
-
-read_master() {
-	${COMMAND}
-}
-
-is_public_ip_assigned() {
-
-while true
-do
-   wget http://169.254.169.254/latest/meta-data/public-ipv4
-   if [ ! -f public-ipv4 ]
-    	then
-      	echo "Public ipv4 file not found. Sleep and retry" >> $LOG
-      	sleep 2;
-      	continue;
-    	else
-      	echo "public-ipv4 file is available. Read value" >> $LOG
-      	# Here means file is available. Read the file
-      	read -r ip<public-ipv4;
-      	echo "value is **[$ip]** " >> $LOG
-
-      	if [ -z "$ip" ]
-        	then
-          	echo "File is empty. Retry...." >> $LOG
-          	sleep 2
-          	rm public-ipv4
-          	continue
-         	else
-           	echo "public ip is assigned. value is [$ip]. Remove file" >> $LOG
-           	rm public-ipv4
-           	break
-         	fi
-    	fi
-done
-}
-
-DATE=`date +%d%m%y%S`
-RANDOMNUMBER="`${TR} -c -d 0-9 < /dev/urandom | ${HEAD} -c 4`${DATE}"
-
-if [ ! -d /tmp/payload ]; then
-
-	## Check whether the public ip is assigned
-	is_public_ip_assigned
-
-	echo "Public ip have assigned. Continue.." >> $LOG
-
-	## Clean old poop
-	${ECHO} "Removing all existing certificates .."
-	#${FIND} /var/lib/puppet -type f -print0 | ${XARGS} -0r ${RM}
-
-	${MKDIR} -p /tmp/payload
-	${WGET} http://169.254.169.254/latest/user-data -O /tmp/payload/launch-params
-
-	cd /tmp/payload
-	SERVICE_NAME=`sed 's/,/\n/g' launch-params | grep SERVICE_NAME | cut -d "=" -f 2`
-	DEPLOYMENT=`sed 's/,/\n/g' launch-params | grep DEPLOYMENT | cut -d "=" -f 2`
-	INSTANCE_HOSTNAME=`sed 's/,/\n/g' launch-params | grep HOSTNAME | cut -d "=" -f 2`
-	PUPPET_IP=`sed 's/,/\n/g' launch-params | grep PUPPET_IP | cut -d "=" -f 2`
-	PUPPET_HOSTNAME=`sed 's/,/\n/g' launch-params | grep PUPPET_HOSTNAME | cut -d "=" -f 2`
-	PUPPET_ENV=`sed 's/,/\n/g' launch-params | grep PUPPET_ENV | cut -d "=" -f 2`
-        PUPPET_DNS_AVAILABLE=`sed 's/,/\n/g' launch-params | grep PUPPET_DNS_AVAILABLE | cut -d "=" -f 2`
-	NODEID="${RANDOMNUMBER}.${DEPLOYMENT}.${SERVICE_NAME}"
-
-
-
-	#essential to have PUPPET_HOSTNAME at the end in order to auto-sign the certs
-	DOMAIN="${PUPPET_HOSTNAME}"
-	${ECHO} -e "\nNode Id ${NODEID}\n"
-	${ECHO} -e "\nDomain ${DOMAIN}\n"
-	sed -i "s/server=.*/server=${PUPPET_HOSTNAME}/g"  ${PUPPETCONF}
-	/etc/init.d/puppet restart    
-	ARGS=("-n${NODEID}" "-d${DOMAIN}" "-s${PUPPET_IP}")
-	HOST="${NODEID}.${DOMAIN}"
-	${HOSTNAME} ${HOST}
-	${ECHO} "${HOST}" > ${HOSTNAMEFILE}
-        if [ true != $PUPPET_DNS_AVAILABLE ] ; then
-                ${ECHO} "${PUPPET_IP}  ${PUPPET_HOSTNAME}" >> ${HOSTSFILE}
-        fi
-
-	${ECHO} "127.0.0.1 ${HOST}" >> ${HOSTSFILE}
-	echo ${HOST}  > /proc/sys/kernel/hostname
-
-	PUPPET=`which puppet`
-        PUPPETAGENT="${PUPPET} agent"
-        RUNPUPPET="${PUPPETAGENT} -vt"
-
-        ${SLEEP} 5
-
-        ${PUPPETAGENT} --enable
-
-        ${RUNPUPPET} --server=${PUPPET_HOSTNAME}
-
-        ${PUPPETAGENT} --disable
-    	${ECHO} -e "Initialization completed successfully."
-
-fi
-
-# END
-

http://git-wip-us.apache.org/repos/asf/stratos/blob/0fa71440/tools/init-script/config-gce.sh
----------------------------------------------------------------------
diff --git a/tools/init-script/config-gce.sh b/tools/init-script/config-gce.sh
deleted file mode 100644
index 0c1cbc7..0000000
--- a/tools/init-script/config-gce.sh
+++ /dev/null
@@ -1,101 +0,0 @@
-#!/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.
-#
-# --------------------------------------------------------------
-shopt -s nocasematch
-ECHO=`which echo`
-RM=`which rm`
-READ=`which read`
-TR=`which tr`
-HEAD=`which head`
-WGET=`which wget`
-MKDIR=`which mkdir`
-GREP=`which grep`
-SED=`which sed`
-CP=`which cp`
-MV=`which mv`
-CURL=`which curl`
-
-HOSTSFILE=/etc/hosts
-DATE=`date +%d%m%y%S`
-RANDOMNUMBER="`${TR} -c -d 0-9 < /dev/urandom | ${HEAD} -c 4`${DATE}"
-
-function valid_ip()
-{
-    local  ip=$1
-    local  stat=1
-
-    if [[ $ip =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
-        OIFS=$IFS
-        IFS='.'
-        ip=($ip)
-        IFS=$OIFS
-        [[ ${ip[0]} -le 255 && ${ip[1]} -le 255 \
-            && ${ip[2]} -le 255 && ${ip[3]} -le 255 ]]
-        stat=$?
-    fi
-    return $stat
-}
-
-read -p "This script will install and configure puppet agent, do you want to continue [y/n]" answer
-if [[ $answer = y ]] ; then
-
-	${CP} -f ${HOSTSFILE} /etc/hosts.tmp
-	${MKDIR} -p /tmp/payload
-	${CURL} "http://metadata.google.internal/computeMetadata/v1/instance/attributes/stratos_usermetadata" \
-		-H "Metadata-Flavor: Google" > /tmp/payload/launch-params
-
-	read -p "Please provide stratos service-name:" SERVICE_NAME
-	if [[ -z $SERVICE_NAME ]]; then
-	echo "service is empty!. Base image will be created."
-        SERVICE_NAME=default
-	fi
-
-	read -p "Please provide puppet master IP:" PUPPET_IP
-	if ! valid_ip $PUPPET_IP ; then
-	echo "invalid IP address format!"
-	exit -1
-	fi
-
-	read -p "Please provide puppet master hostname [puppet.stratos.org]:" DOMAIN
-	DOMAIN=${DOMAIN:-puppet.stratos.org}
-	#essential to have PUPPET_HOSTNAME at the end in order to auto-sign the certs
-
-	#read -p "Please provide stratos deployment:" DEPLOYMENT
-	#DEPLOYMENT=${DEPLOYMENT:-default}
-	DEPLOYMENT="default"
-
-	NODEID="${RANDOMNUMBER}.${DEPLOYMENT}.${SERVICE_NAME}"
-	
-	${ECHO} -e "\nNode Id ${NODEID}\n"
-	${ECHO} -e "\nDomain ${DOMAIN}\n"
-    
-	ARGS=("-n${NODEID}" "-d${DOMAIN}" "-s${PUPPET_IP}")
-	${ECHO} "\nRunning puppet installation with arguments: ${ARGS[@]}"
-	/root/bin/puppetinstall/puppetinstall "${ARGS[@]}"
-        ${RM} /mnt/apache-stratos-cartridge-agent-4.0.0/wso2carbon.lck
-	${GREP} -q '/root/bin/init.sh > /tmp/puppet_log' /etc/rc.local || ${SED} -i 's/exit 0$/\/root\/bin\/init.sh \> \/tmp\/puppet_log\nexit 0/' /etc/rc.local
-	${RM} -rf /tmp/*
-	${RM} -rf /var/lib/puppet/ssl/*
-	${MV} -f /etc/hosts.tmp ${HOSTSFILE}
-
-fi
-
-# END

http://git-wip-us.apache.org/repos/asf/stratos/blob/0fa71440/tools/init-script/config.sh
----------------------------------------------------------------------
diff --git a/tools/init-script/config.sh b/tools/init-script/config.sh
deleted file mode 100755
index 4ac4707..0000000
--- a/tools/init-script/config.sh
+++ /dev/null
@@ -1,104 +0,0 @@
-#!/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.
-#
-# --------------------------------------------------------------
-shopt -s nocasematch
-ECHO=`which echo`
-RM=`which rm`
-READ=`which read`
-TR=`which tr`
-HEAD=`which head`
-WGET=`which wget`
-MKDIR=`which mkdir`
-GREP=`which grep`
-SED=`which sed`
-CP=`which cp`
-MV=`which mv`
-
-HOSTSFILE=/etc/hosts
-LOCKFILE=/mnt/apache-stratos-cartridge-agent-4.0.0/wso2carbon.lck
-DATE=`date +%d%m%y%S`
-RANDOMNUMBER="`${TR} -c -d 0-9 < /dev/urandom | ${HEAD} -c 4`${DATE}"
-
-function valid_ip()
-{
-    local  ip=$1
-    local  stat=1
-
-    if [[ $ip =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
-        OIFS=$IFS
-        IFS='.'
-        ip=($ip)
-        IFS=$OIFS
-        [[ ${ip[0]} -le 255 && ${ip[1]} -le 255 \
-            && ${ip[2]} -le 255 && ${ip[3]} -le 255 ]]
-        stat=$?
-    fi
-    return $stat
-}
-
-read -p "This script will install and configure puppet agent, do you want to continue [y/n]" answer
-if [[ $answer = y ]] ; then
-
-	${CP} -f ${HOSTSFILE} /etc/hosts.tmp
-	${MKDIR} -p /tmp/payload
-	${WGET} http://169.254.169.254/latest/user-data -O /tmp/payload/launch-params
-
-	read -p "Please provide stratos service-name:" SERVICE_NAME
-	if [[ -z $SERVICE_NAME ]]; then
-	echo "service is empty!. Base image will be created."
-        SERVICE_NAME=default
-	fi
-
-	read -p "Please provide puppet master IP:" PUPPET_IP
-	if ! valid_ip $PUPPET_IP ; then
-	echo "invalid IP address format!"
-	exit -1
-	fi
-
-	read -p "Please provide puppet master hostname [puppet.stratos.org]:" DOMAIN
-	DOMAIN=${DOMAIN:-puppet.stratos.org}
-	#essential to have PUPPET_HOSTNAME at the end in order to auto-sign the certs
-
-	#read -p "Please provide stratos deployment:" DEPLOYMENT
-	#DEPLOYMENT=${DEPLOYMENT:-default}
-	DEPLOYMENT="default"
-
-	NODEID="${RANDOMNUMBER}.${DEPLOYMENT}.${SERVICE_NAME}"
-	
-	${ECHO} -e "\nNode Id ${NODEID}\n"
-	${ECHO} -e "\nDomain ${DOMAIN}\n"
-    
-	ARGS=("-n${NODEID}" "-d${DOMAIN}" "-s${PUPPET_IP}")
-	${ECHO} "\nRunning puppet installation with arguments: ${ARGS[@]}"
-	/root/bin/puppetinstall/puppetinstall "${ARGS[@]}"
-	#check for java agent lock file
-	if [ -e ${LOCKFILE} ]; then
-	${RM} ${LOCKFILE}
-	fi
-
-	${GREP} -q '/root/bin/init.sh > /tmp/puppet_log' /etc/rc.local || ${SED} -i 's/exit 0$/\/root\/bin\/init.sh \> \/tmp\/puppet_log\nexit 0/' /etc/rc.local
-	${RM} -rf /tmp/*
-	${RM} -rf /var/lib/puppet/ssl/*
-	${MV} -f /etc/hosts.tmp ${HOSTSFILE}
-
-fi
-
-# END

http://git-wip-us.apache.org/repos/asf/stratos/blob/0fa71440/tools/init-script/init-gce.sh
----------------------------------------------------------------------
diff --git a/tools/init-script/init-gce.sh b/tools/init-script/init-gce.sh
deleted file mode 100644
index 0ca816f..0000000
--- a/tools/init-script/init-gce.sh
+++ /dev/null
@@ -1,146 +0,0 @@
-#!/bin/bash
-# --------------------------------------------------------------
-#
-# 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.
-#
-# --------------------------------------------------------------
-
-MKDIR=`which mkdir`
-UNZIP=`which unzip`
-ECHO=`which echo`
-FIND=`which find`
-GREP=`which grep`
-RM=`which rm`
-XARGS=`which xargs`
-SED=`which sed`
-CUT=`which cut`
-AWK=`which awk`
-IFCONFIG=`which ifconfig`
-HOSTNAME=`which hostname`
-SLEEP=`which sleep`
-TR=`which tr`
-HEAD=`which head`
-WGET=`which wget`
-PUPPETD=`which puppet`
-AGENT="agent"
-PUPPETAGENT="${PUPPETD} ${AGENT}"
-CURL=`which curl`
-
-COMMAND="${PUPPETAGENT} -vt"
-IP=`${IFCONFIG} eth0 | ${GREP} -e "inet addr" | ${AWK} '{print $2}' | ${CUT} -d ':' -f 2`
-LOG=/tmp/puppet-init.log
-
-HOSTSFILE=/etc/hosts
-HOSTNAMEFILE=/etc/hostname
-PUPPETCONF=/etc/puppet/puppet.conf
-
-read_master() {
-	${COMMAND}
-}
-
-
-is_public_ip_assigned() {
-
-while true
-do
-   # Reading the internal ip assigned
-   ${CURL} "http://metadata.google.internal/computeMetadata/v1/instance/network-interfaces/0/ip" \
-	-H "Metadata-Flavor: Google" > public-ipv4
-   if [ ! -f public-ipv4 ]
-    	then
-      	echo "Public ipv4 file not found. Sleep and retry" >> $LOG
-      	sleep 2;
-      	continue;
-    	else
-      	echo "public-ipv4 file is available. Read value" >> $LOG
-      	# Here means file is available. Read the file
-      	read -r ip<public-ipv4;
-      	echo "value is **[$ip]** " >> $LOG
-
-      	if [ -z "$ip" ]
-        	then
-          	echo "File is empty. Retry...." >> $LOG
-          	sleep 2
-          	rm public-ipv4
-          	continue
-         	else
-           	echo "public ip is assigned. value is [$ip]. Remove file" >> $LOG
-           	rm public-ipv4
-           	break
-         	fi
-    	fi
-done
-}
-
-
-DATE=`date +%d%m%y%S`
-RANDOMNUMBER="`${TR} -c -d 0-9 < /dev/urandom | ${HEAD} -c 4`${DATE}"
-
-if [ ! -d /tmp/payload ]; then
-
-	## Check whether the public ip is assigned
-	is_public_ip_assigned
-
-	echo "Public ip have assigned. Continue.." >> $LOG
-
-	## Clean old poop
-	${ECHO} "Removing all existing certificates .."
-	#${FIND} /var/lib/puppet -type f -print0 | ${XARGS} -0r ${RM}
-
-	${MKDIR} -p /tmp/payload
-	${CURL} "http://metadata.google.internal/computeMetadata/v1/instance/attributes/stratos_usermetadata" \
-		-H "Metadata-Flavor: Google" > /tmp/payload/launch-params
-
-	cd /tmp/payload
-	SERVICE_NAME=`sed 's/,/\n/g' launch-params | grep SERVICE_NAME | cut -d "=" -f 2`
-	DEPLOYMENT=`sed 's/,/\n/g' launch-params | grep DEPLOYMENT | cut -d "=" -f 2`
-	INSTANCE_HOSTNAME=`sed 's/,/\n/g' launch-params | grep HOSTNAME | cut -d "=" -f 2`
-	PUPPET_IP=`sed 's/,/\n/g' launch-params | grep PUPPET_IP | cut -d "=" -f 2`
-	PUPPET_HOSTNAME=`sed 's/,/\n/g' launch-params | grep PUPPET_HOSTNAME | cut -d "=" -f 2`
-	PUPPET_ENV=`sed 's/,/\n/g' launch-params | grep PUPPET_ENV | cut -d "=" -f 2`
-	NODEID="${RANDOMNUMBER}.${DEPLOYMENT}.${SERVICE_NAME}"
-	#essential to have PUPPET_HOSTNAME at the end in order to auto-sign the certs
-	DOMAIN="${PUPPET_HOSTNAME}"
-	${ECHO} -e "\nNode Id ${NODEID}\n"
-	${ECHO} -e "\nDomain ${DOMAIN}\n"
-	sed -i "s/server=.*/server=${PUPPET_HOSTNAME}/g"  ${PUPPETCONF}
-	/etc/init.d/puppet restart    
-	ARGS=("-n${NODEID}" "-d${DOMAIN}" "-s${PUPPET_IP}")
-	HOST="${NODEID}.${DOMAIN}"
-	${HOSTNAME} ${HOST}
-	${ECHO} "${HOST}" > ${HOSTNAMEFILE}
-	${ECHO} "${PUPPET_IP}  ${PUPPET_HOSTNAME}" >> ${HOSTSFILE} 
-	${ECHO} "127.0.0.1 ${HOST}" >> ${HOSTSFILE}
-	/etc/init.d/hostname start
-
-	PUPPET=`which puppet`
-        PUPPETAGENT="${PUPPET} agent"
-        RUNPUPPET="${PUPPETAGENT} -vt"
-
-        ${SLEEP} 5
-
-        ${PUPPETAGENT} --enable
-
-        ${RUNPUPPET}
-
-        ${PUPPETAGENT} --disable
-    	${ECHO} -e "Initialization completed successfully."
-
-fi
-
-# END
-

http://git-wip-us.apache.org/repos/asf/stratos/blob/0fa71440/tools/init-script/init-vcloud.sh
----------------------------------------------------------------------
diff --git a/tools/init-script/init-vcloud.sh b/tools/init-script/init-vcloud.sh
deleted file mode 100755
index 168137a..0000000
--- a/tools/init-script/init-vcloud.sh
+++ /dev/null
@@ -1,80 +0,0 @@
-#!/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.
-#
-# --------------------------------------------------------------
-
-MKDIR=`which mkdir`
-UNZIP=`which unzip`
-ECHO=`which echo`
-FIND=`which find`
-GREP=`which grep`
-RM=`which rm`
-XARGS=`which xargs`
-SED=`which sed`
-CUT=`which cut`
-AWK=`which awk`
-IFCONFIG=`which ifconfig`
-HOSTNAME=`which hostname`
-SLEEP=`which sleep`
-TR=`which tr`
-HEAD=`which head`
-WGET=`which wget`
-PUPPETD=`which puppet`
-AGENT="agent"
-PUPPETAGENT="${PUPPETD} ${AGENT}"
-
-COMMAND="${PUPPETAGENT} -vt"
-IP=`${IFCONFIG} eth0 | ${GREP} -e "inet addr" | ${AWK} '{print $2}' | ${CUT} -d ':' -f 2`
-LOG=/tmp/puppet-init.log
-
-HOSTSFILE=/etc/hosts
-HOSTNAMEFILE=/etc/hostname
-PUPPETCONF=/etc/puppet/puppet.conf
-
-read_master() {
-	${COMMAND}
-}
-
-DATE=`date +%d%m%y%S`
-RANDOMNUMBER="`${TR} -c -d 0-9 < /dev/urandom | ${HEAD} -c 4`${DATE}"
-
-if [ -d /tmp/payload ]; then
-
-	cd /tmp/payload
-	SERVICE_NAME=`sed 's/,/\n/g' launch-params | grep SERVICE_NAME | cut -d "=" -f 2`
-	DEPLOYMENT=`sed 's/,/\n/g' launch-params | grep DEPLOYMENT | cut -d "=" -f 2`
-	INSTANCE_HOSTNAME=`sed 's/,/\n/g' launch-params | grep HOSTNAME | cut -d "=" -f 2`
-	PUPPET_IP=`sed 's/,/\n/g' launch-params | grep PUPPET_IP | cut -d "=" -f 2`
-	PUPPET_HOSTNAME=`sed 's/,/\n/g' launch-params | grep PUPPET_HOSTNAME | cut -d "=" -f 2`
-	PUPPET_ENV=`sed 's/,/\n/g' launch-params | grep PUPPET_ENV | cut -d "=" -f 2`
-	NODEID="${RANDOMNUMBER}.${DEPLOYMENT}.${SERVICE_NAME}"
-	#essential to have PUPPET_HOSTNAME at the end in order to auto-sign the certs
-	DOMAIN="${PUPPET_HOSTNAME}"
-	${ECHO} -e "\nNode Id ${NODEID}\n"
-	${ECHO} -e "\nDomain ${DOMAIN}\n"
-    
-    ARGS=("-n${NODEID}" "-d${DOMAIN}" "-s${PUPPET_IP}")
-    ${ECHO} "\nRunning puppet installation with arguments: ${ARGS[@]}"
-    exec /root/bin/puppetinstall/puppetinstall "${ARGS[@]}"
-
-fi
-
-# END
-

http://git-wip-us.apache.org/repos/asf/stratos/blob/0fa71440/tools/init-script/init.sh
----------------------------------------------------------------------
diff --git a/tools/init-script/init.sh b/tools/init-script/init.sh
deleted file mode 100755
index 6841808..0000000
--- a/tools/init-script/init.sh
+++ /dev/null
@@ -1,165 +0,0 @@
-#!/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.
-#
-# --------------------------------------------------------------
-
-MKDIR=`which mkdir`
-UNZIP=`which unzip`
-ECHO=`which echo`
-FIND=`which find`
-GREP=`which grep`
-RM=`which rm`
-XARGS=`which xargs`
-SED=`which sed`
-CUT=`which cut`
-AWK=`which awk`
-IFCONFIG=`which ifconfig`
-HOSTNAME=`which hostname`
-SLEEP=`which sleep`
-TR=`which tr`
-HEAD=`which head`
-WGET=`which wget`
-PUPPETD=`which puppet`
-AGENT="agent"
-PUPPETAGENT="${PUPPETD} ${AGENT}"
-OS=$(lsb_release -si)
-PUPPET_DNS_AVAILABLE=false
-
-COMMAND="${PUPPETAGENT} -vt"
-IP=`${IFCONFIG} eth0 | ${GREP} -e "inet addr" | ${AWK} '{print $2}' | ${CUT} -d ':' -f 2`
-LOG=/tmp/puppet-init.log
-
-HOSTSFILE=/etc/hosts
-HOSTNAMEFILE=/etc/hostname
-PUPPETCONF=/etc/puppet/puppet.conf
-
-read_master() {
-	${COMMAND}
-}
-
-
-is_public_ip_assigned() {
-
-while true
-do
-   wget http://169.254.169.254/latest/meta-data/public-ipv4
-   if [ ! -f public-ipv4 ]
-    	then
-      	echo "Public ipv4 file not found. Sleep and retry" >> $LOG
-      	sleep 2;
-      	continue;
-    	else
-      	echo "public-ipv4 file is available. Read value" >> $LOG
-      	# Here means file is available. Read the file
-      	read -r ip<public-ipv4;
-      	echo "value is **[$ip]** " >> $LOG
-
-      	if [ -z "$ip" ]
-        	then
-          	echo "File is empty. Retry...." >> $LOG
-          	sleep 2
-          	rm public-ipv4
-          	continue
-         	else
-           	echo "public ip is assigned. value is [$ip]. Remove file" >> $LOG
-           	rm public-ipv4
-           	break
-         	fi
-    	fi
-done
-}
-
-
-DATE=`date +%d%m%y%S`
-RANDOMNUMBER="`${TR} -c -d 0-9 < /dev/urandom | ${HEAD} -c 4`${DATE}"
-
-if [ ! -d /tmp/payload ]; then
-
-	## Check whether the public ip is assigned
-	is_public_ip_assigned
-
-	echo "Public ip have assigned. Continue.." >> $LOG
-
-	## Clean old poop
-	${ECHO} "Removing all existing certificates .."
-	#${FIND} /var/lib/puppet -type f -print0 | ${XARGS} -0r ${RM}
-
-	${MKDIR} -p /tmp/payload
-	${WGET} http://169.254.169.254/latest/user-data -O /tmp/payload/launch-params
-
-	cd /tmp/payload
-	SERVICE_NAME=`sed 's/,/\n/g' launch-params | grep SERVICE_NAME | cut -d "=" -f 2`
-	DEPLOYMENT=`sed 's/,/\n/g' launch-params | grep DEPLOYMENT | cut -d "=" -f 2`
-	INSTANCE_HOSTNAME=`sed 's/,/\n/g' launch-params | grep HOSTNAME | cut -d "=" -f 2`
-	PUPPET_IP=`sed 's/,/\n/g' launch-params | grep PUPPET_IP | cut -d "=" -f 2`
-	PUPPET_HOSTNAME=`sed 's/,/\n/g' launch-params | grep PUPPET_HOSTNAME | cut -d "=" -f 2`
-	PUPPET_ENV=`sed 's/,/\n/g' launch-params | grep PUPPET_ENV | cut -d "=" -f 2`
-	PUPPET_DNS_AVAILABLE=`sed 's/,/\n/g' launch-params | grep PUPPET_DNS_AVAILABLE | cut -d "=" -f 2`
-	
-	#If this property is not set, then set it as false
-	if [  -z $PUPPET_DNS_AVAILABLE ];then
-		PUPPET_DNS_AVAILABLE=false
-	fi
-	NODEID="${RANDOMNUMBER}.${DEPLOYMENT}.${SERVICE_NAME}"
-	#essential to have PUPPET_HOSTNAME at the end in order to auto-sign the certs
-	DOMAIN="${PUPPET_HOSTNAME}"
-	${ECHO} -e "\nNode Id ${NODEID}\n"
-	${ECHO} -e "\nDomain ${DOMAIN}\n"
-	sed -i "s/server=.*/server=${PUPPET_HOSTNAME}/g"  ${PUPPETCONF}
-	/etc/init.d/puppet restart    
-	ARGS=("-n${NODEID}" "-d${DOMAIN}" "-s${PUPPET_IP}")
-	HOST="${NODEID}.${DOMAIN}"
-	${HOSTNAME} ${HOST}
-	${ECHO} "${HOST}" > ${HOSTNAMEFILE}
-	if [ true != $PUPPET_DNS_AVAILABLE ] ; then
-		${ECHO} "${PUPPET_IP}  ${PUPPET_HOSTNAME}" >> ${HOSTSFILE} 
-	fi
-	${ECHO} "127.0.0.1 ${HOST}" >> ${HOSTSFILE}
-
-	if [ "$OS" = "CentOS" ]; then
-		#CentOS hostname change
-		${ECHO} "CentOS : Changing host name in /etc/sysconfig/network"
-		CENTOSHOSTNAME="/etc/sysconfig/network"
-		${ECHO} "NETWORKING=yes" > ${CENTOSHOSTNAME}
-		${ECHO} "HOSTNAME=${HOST}" >> ${CENTOSHOSTNAME}
-		${ECHO} "Network restarting..."
-		/etc/init.d/network restart
-		${SLEEP} 4	
-	else
-		#Ubuntu hostname change
-		/etc/init.d/hostname start
-	fi
-
-	PUPPET=`which puppet`
-        PUPPETAGENT="${PUPPET} agent"
-        RUNPUPPET="${PUPPETAGENT} -vt"
-
-        ${SLEEP} 5
-
-        ${PUPPETAGENT} --enable
-
-        ${RUNPUPPET}
-
-        ${PUPPETAGENT} --disable
-    	${ECHO} -e "Initialization completed successfully."
-
-fi
-
-# END

http://git-wip-us.apache.org/repos/asf/stratos/blob/0fa71440/tools/init-scripts/README.md
----------------------------------------------------------------------
diff --git a/tools/init-scripts/README.md b/tools/init-scripts/README.md
new file mode 100644
index 0000000..34e503e
--- /dev/null
+++ b/tools/init-scripts/README.md
@@ -0,0 +1,4 @@
+Stratos Cartridge Init Scripts
+==============================
+
+This folder will host the init scripts of cartridge instances. Purpose of these scripts are to kick off the startup actions such as downloading user-data(payload), run puppet agent etc.

http://git-wip-us.apache.org/repos/asf/stratos/blob/0fa71440/tools/init-scripts/centos/init.sh
----------------------------------------------------------------------
diff --git a/tools/init-scripts/centos/init.sh b/tools/init-scripts/centos/init.sh
new file mode 100644
index 0000000..bc2aa4b
--- /dev/null
+++ b/tools/init-scripts/centos/init.sh
@@ -0,0 +1,147 @@
+#!/bin/bash
+# --------------------------------------------------------------
+#
+# 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.
+#
+# --------------------------------------------------------------
+
+MKDIR=`which mkdir`
+UNZIP=`which unzip`
+ECHO=`which echo`
+FIND=`which find`
+GREP=`which grep`
+RM=`which rm`
+XARGS=`which xargs`
+SED=`which sed`
+CUT=`which cut`
+AWK=`which awk`
+IFCONFIG=`which ifconfig`
+HOSTNAME=`which hostname`
+SLEEP=`which sleep`
+TR=`which tr`
+HEAD=`which head`
+WGET=`which wget`
+PUPPETD=`which puppet`
+AGENT="agent"
+PUPPETAGENT="${PUPPETD} ${AGENT}"
+
+COMMAND="${PUPPETAGENT} -vt"
+IP=`${IFCONFIG} eth0 | ${GREP} -e "inet addr" | ${AWK} '{print $2}' | ${CUT} -d ':' -f 2`
+LOG=/tmp/puppet-init.log
+
+HOSTSFILE=/etc/hosts
+HOSTNAMEFILE=/etc/hostname
+PUPPETCONF=/etc/puppet/puppet.conf
+
+read_master() {
+	${COMMAND}
+}
+
+is_public_ip_assigned() {
+
+while true
+do
+   wget http://169.254.169.254/latest/meta-data/public-ipv4
+   if [ ! -f public-ipv4 ]
+    	then
+      	echo "Public ipv4 file not found. Sleep and retry" >> $LOG
+      	sleep 2;
+      	continue;
+    	else
+      	echo "public-ipv4 file is available. Read value" >> $LOG
+      	# Here means file is available. Read the file
+      	read -r ip<public-ipv4;
+      	echo "value is **[$ip]** " >> $LOG
+
+      	if [ -z "$ip" ]
+        	then
+          	echo "File is empty. Retry...." >> $LOG
+          	sleep 2
+          	rm public-ipv4
+          	continue
+         	else
+           	echo "public ip is assigned. value is [$ip]. Remove file" >> $LOG
+           	rm public-ipv4
+           	break
+         	fi
+    	fi
+done
+}
+
+DATE=`date +%d%m%y%S`
+RANDOMNUMBER="`${TR} -c -d 0-9 < /dev/urandom | ${HEAD} -c 4`${DATE}"
+
+if [ ! -d /tmp/payload ]; then
+
+	## Check whether the public ip is assigned
+	is_public_ip_assigned
+
+	echo "Public ip have assigned. Continue.." >> $LOG
+
+	## Clean old poop
+	${ECHO} "Removing all existing certificates .."
+	#${FIND} /var/lib/puppet -type f -print0 | ${XARGS} -0r ${RM}
+
+	${MKDIR} -p /tmp/payload
+	${WGET} http://169.254.169.254/latest/user-data -O /tmp/payload/launch-params
+
+	cd /tmp/payload
+	SERVICE_NAME=`sed 's/,/\n/g' launch-params | grep SERVICE_NAME | cut -d "=" -f 2`
+	DEPLOYMENT=`sed 's/,/\n/g' launch-params | grep DEPLOYMENT | cut -d "=" -f 2`
+	INSTANCE_HOSTNAME=`sed 's/,/\n/g' launch-params | grep HOSTNAME | cut -d "=" -f 2`
+	PUPPET_IP=`sed 's/,/\n/g' launch-params | grep PUPPET_IP | cut -d "=" -f 2`
+	PUPPET_HOSTNAME=`sed 's/,/\n/g' launch-params | grep PUPPET_HOSTNAME | cut -d "=" -f 2`
+	PUPPET_ENV=`sed 's/,/\n/g' launch-params | grep PUPPET_ENV | cut -d "=" -f 2`
+        PUPPET_DNS_AVAILABLE=`sed 's/,/\n/g' launch-params | grep PUPPET_DNS_AVAILABLE | cut -d "=" -f 2`
+	NODEID="${RANDOMNUMBER}.${DEPLOYMENT}.${SERVICE_NAME}"
+
+
+
+	#essential to have PUPPET_HOSTNAME at the end in order to auto-sign the certs
+	DOMAIN="${PUPPET_HOSTNAME}"
+	${ECHO} -e "\nNode Id ${NODEID}\n"
+	${ECHO} -e "\nDomain ${DOMAIN}\n"
+	sed -i "s/server=.*/server=${PUPPET_HOSTNAME}/g"  ${PUPPETCONF}
+	/etc/init.d/puppet restart    
+	ARGS=("-n${NODEID}" "-d${DOMAIN}" "-s${PUPPET_IP}")
+	HOST="${NODEID}.${DOMAIN}"
+	${HOSTNAME} ${HOST}
+	${ECHO} "${HOST}" > ${HOSTNAMEFILE}
+        if [ true != $PUPPET_DNS_AVAILABLE ] ; then
+                ${ECHO} "${PUPPET_IP}  ${PUPPET_HOSTNAME}" >> ${HOSTSFILE}
+        fi
+
+	${ECHO} "127.0.0.1 ${HOST}" >> ${HOSTSFILE}
+	echo ${HOST}  > /proc/sys/kernel/hostname
+
+	PUPPET=`which puppet`
+        PUPPETAGENT="${PUPPET} agent"
+        RUNPUPPET="${PUPPETAGENT} -vt"
+
+        ${SLEEP} 5
+
+        ${PUPPETAGENT} --enable
+
+        ${RUNPUPPET} --server=${PUPPET_HOSTNAME}
+
+        ${PUPPETAGENT} --disable
+    	${ECHO} -e "Initialization completed successfully."
+
+fi
+
+# END
+

http://git-wip-us.apache.org/repos/asf/stratos/blob/0fa71440/tools/init-scripts/config-gce.sh
----------------------------------------------------------------------
diff --git a/tools/init-scripts/config-gce.sh b/tools/init-scripts/config-gce.sh
new file mode 100644
index 0000000..0c1cbc7
--- /dev/null
+++ b/tools/init-scripts/config-gce.sh
@@ -0,0 +1,101 @@
+#!/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.
+#
+# --------------------------------------------------------------
+shopt -s nocasematch
+ECHO=`which echo`
+RM=`which rm`
+READ=`which read`
+TR=`which tr`
+HEAD=`which head`
+WGET=`which wget`
+MKDIR=`which mkdir`
+GREP=`which grep`
+SED=`which sed`
+CP=`which cp`
+MV=`which mv`
+CURL=`which curl`
+
+HOSTSFILE=/etc/hosts
+DATE=`date +%d%m%y%S`
+RANDOMNUMBER="`${TR} -c -d 0-9 < /dev/urandom | ${HEAD} -c 4`${DATE}"
+
+function valid_ip()
+{
+    local  ip=$1
+    local  stat=1
+
+    if [[ $ip =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
+        OIFS=$IFS
+        IFS='.'
+        ip=($ip)
+        IFS=$OIFS
+        [[ ${ip[0]} -le 255 && ${ip[1]} -le 255 \
+            && ${ip[2]} -le 255 && ${ip[3]} -le 255 ]]
+        stat=$?
+    fi
+    return $stat
+}
+
+read -p "This script will install and configure puppet agent, do you want to continue [y/n]" answer
+if [[ $answer = y ]] ; then
+
+	${CP} -f ${HOSTSFILE} /etc/hosts.tmp
+	${MKDIR} -p /tmp/payload
+	${CURL} "http://metadata.google.internal/computeMetadata/v1/instance/attributes/stratos_usermetadata" \
+		-H "Metadata-Flavor: Google" > /tmp/payload/launch-params
+
+	read -p "Please provide stratos service-name:" SERVICE_NAME
+	if [[ -z $SERVICE_NAME ]]; then
+	echo "service is empty!. Base image will be created."
+        SERVICE_NAME=default
+	fi
+
+	read -p "Please provide puppet master IP:" PUPPET_IP
+	if ! valid_ip $PUPPET_IP ; then
+	echo "invalid IP address format!"
+	exit -1
+	fi
+
+	read -p "Please provide puppet master hostname [puppet.stratos.org]:" DOMAIN
+	DOMAIN=${DOMAIN:-puppet.stratos.org}
+	#essential to have PUPPET_HOSTNAME at the end in order to auto-sign the certs
+
+	#read -p "Please provide stratos deployment:" DEPLOYMENT
+	#DEPLOYMENT=${DEPLOYMENT:-default}
+	DEPLOYMENT="default"
+
+	NODEID="${RANDOMNUMBER}.${DEPLOYMENT}.${SERVICE_NAME}"
+	
+	${ECHO} -e "\nNode Id ${NODEID}\n"
+	${ECHO} -e "\nDomain ${DOMAIN}\n"
+    
+	ARGS=("-n${NODEID}" "-d${DOMAIN}" "-s${PUPPET_IP}")
+	${ECHO} "\nRunning puppet installation with arguments: ${ARGS[@]}"
+	/root/bin/puppetinstall/puppetinstall "${ARGS[@]}"
+        ${RM} /mnt/apache-stratos-cartridge-agent-4.0.0/wso2carbon.lck
+	${GREP} -q '/root/bin/init.sh > /tmp/puppet_log' /etc/rc.local || ${SED} -i 's/exit 0$/\/root\/bin\/init.sh \> \/tmp\/puppet_log\nexit 0/' /etc/rc.local
+	${RM} -rf /tmp/*
+	${RM} -rf /var/lib/puppet/ssl/*
+	${MV} -f /etc/hosts.tmp ${HOSTSFILE}
+
+fi
+
+# END

http://git-wip-us.apache.org/repos/asf/stratos/blob/0fa71440/tools/init-scripts/config.sh
----------------------------------------------------------------------
diff --git a/tools/init-scripts/config.sh b/tools/init-scripts/config.sh
new file mode 100755
index 0000000..4ac4707
--- /dev/null
+++ b/tools/init-scripts/config.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.
+#
+# --------------------------------------------------------------
+shopt -s nocasematch
+ECHO=`which echo`
+RM=`which rm`
+READ=`which read`
+TR=`which tr`
+HEAD=`which head`
+WGET=`which wget`
+MKDIR=`which mkdir`
+GREP=`which grep`
+SED=`which sed`
+CP=`which cp`
+MV=`which mv`
+
+HOSTSFILE=/etc/hosts
+LOCKFILE=/mnt/apache-stratos-cartridge-agent-4.0.0/wso2carbon.lck
+DATE=`date +%d%m%y%S`
+RANDOMNUMBER="`${TR} -c -d 0-9 < /dev/urandom | ${HEAD} -c 4`${DATE}"
+
+function valid_ip()
+{
+    local  ip=$1
+    local  stat=1
+
+    if [[ $ip =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
+        OIFS=$IFS
+        IFS='.'
+        ip=($ip)
+        IFS=$OIFS
+        [[ ${ip[0]} -le 255 && ${ip[1]} -le 255 \
+            && ${ip[2]} -le 255 && ${ip[3]} -le 255 ]]
+        stat=$?
+    fi
+    return $stat
+}
+
+read -p "This script will install and configure puppet agent, do you want to continue [y/n]" answer
+if [[ $answer = y ]] ; then
+
+	${CP} -f ${HOSTSFILE} /etc/hosts.tmp
+	${MKDIR} -p /tmp/payload
+	${WGET} http://169.254.169.254/latest/user-data -O /tmp/payload/launch-params
+
+	read -p "Please provide stratos service-name:" SERVICE_NAME
+	if [[ -z $SERVICE_NAME ]]; then
+	echo "service is empty!. Base image will be created."
+        SERVICE_NAME=default
+	fi
+
+	read -p "Please provide puppet master IP:" PUPPET_IP
+	if ! valid_ip $PUPPET_IP ; then
+	echo "invalid IP address format!"
+	exit -1
+	fi
+
+	read -p "Please provide puppet master hostname [puppet.stratos.org]:" DOMAIN
+	DOMAIN=${DOMAIN:-puppet.stratos.org}
+	#essential to have PUPPET_HOSTNAME at the end in order to auto-sign the certs
+
+	#read -p "Please provide stratos deployment:" DEPLOYMENT
+	#DEPLOYMENT=${DEPLOYMENT:-default}
+	DEPLOYMENT="default"
+
+	NODEID="${RANDOMNUMBER}.${DEPLOYMENT}.${SERVICE_NAME}"
+	
+	${ECHO} -e "\nNode Id ${NODEID}\n"
+	${ECHO} -e "\nDomain ${DOMAIN}\n"
+    
+	ARGS=("-n${NODEID}" "-d${DOMAIN}" "-s${PUPPET_IP}")
+	${ECHO} "\nRunning puppet installation with arguments: ${ARGS[@]}"
+	/root/bin/puppetinstall/puppetinstall "${ARGS[@]}"
+	#check for java agent lock file
+	if [ -e ${LOCKFILE} ]; then
+	${RM} ${LOCKFILE}
+	fi
+
+	${GREP} -q '/root/bin/init.sh > /tmp/puppet_log' /etc/rc.local || ${SED} -i 's/exit 0$/\/root\/bin\/init.sh \> \/tmp\/puppet_log\nexit 0/' /etc/rc.local
+	${RM} -rf /tmp/*
+	${RM} -rf /var/lib/puppet/ssl/*
+	${MV} -f /etc/hosts.tmp ${HOSTSFILE}
+
+fi
+
+# END

http://git-wip-us.apache.org/repos/asf/stratos/blob/0fa71440/tools/init-scripts/init-gce.sh
----------------------------------------------------------------------
diff --git a/tools/init-scripts/init-gce.sh b/tools/init-scripts/init-gce.sh
new file mode 100644
index 0000000..0ca816f
--- /dev/null
+++ b/tools/init-scripts/init-gce.sh
@@ -0,0 +1,146 @@
+#!/bin/bash
+# --------------------------------------------------------------
+#
+# 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.
+#
+# --------------------------------------------------------------
+
+MKDIR=`which mkdir`
+UNZIP=`which unzip`
+ECHO=`which echo`
+FIND=`which find`
+GREP=`which grep`
+RM=`which rm`
+XARGS=`which xargs`
+SED=`which sed`
+CUT=`which cut`
+AWK=`which awk`
+IFCONFIG=`which ifconfig`
+HOSTNAME=`which hostname`
+SLEEP=`which sleep`
+TR=`which tr`
+HEAD=`which head`
+WGET=`which wget`
+PUPPETD=`which puppet`
+AGENT="agent"
+PUPPETAGENT="${PUPPETD} ${AGENT}"
+CURL=`which curl`
+
+COMMAND="${PUPPETAGENT} -vt"
+IP=`${IFCONFIG} eth0 | ${GREP} -e "inet addr" | ${AWK} '{print $2}' | ${CUT} -d ':' -f 2`
+LOG=/tmp/puppet-init.log
+
+HOSTSFILE=/etc/hosts
+HOSTNAMEFILE=/etc/hostname
+PUPPETCONF=/etc/puppet/puppet.conf
+
+read_master() {
+	${COMMAND}
+}
+
+
+is_public_ip_assigned() {
+
+while true
+do
+   # Reading the internal ip assigned
+   ${CURL} "http://metadata.google.internal/computeMetadata/v1/instance/network-interfaces/0/ip" \
+	-H "Metadata-Flavor: Google" > public-ipv4
+   if [ ! -f public-ipv4 ]
+    	then
+      	echo "Public ipv4 file not found. Sleep and retry" >> $LOG
+      	sleep 2;
+      	continue;
+    	else
+      	echo "public-ipv4 file is available. Read value" >> $LOG
+      	# Here means file is available. Read the file
+      	read -r ip<public-ipv4;
+      	echo "value is **[$ip]** " >> $LOG
+
+      	if [ -z "$ip" ]
+        	then
+          	echo "File is empty. Retry...." >> $LOG
+          	sleep 2
+          	rm public-ipv4
+          	continue
+         	else
+           	echo "public ip is assigned. value is [$ip]. Remove file" >> $LOG
+           	rm public-ipv4
+           	break
+         	fi
+    	fi
+done
+}
+
+
+DATE=`date +%d%m%y%S`
+RANDOMNUMBER="`${TR} -c -d 0-9 < /dev/urandom | ${HEAD} -c 4`${DATE}"
+
+if [ ! -d /tmp/payload ]; then
+
+	## Check whether the public ip is assigned
+	is_public_ip_assigned
+
+	echo "Public ip have assigned. Continue.." >> $LOG
+
+	## Clean old poop
+	${ECHO} "Removing all existing certificates .."
+	#${FIND} /var/lib/puppet -type f -print0 | ${XARGS} -0r ${RM}
+
+	${MKDIR} -p /tmp/payload
+	${CURL} "http://metadata.google.internal/computeMetadata/v1/instance/attributes/stratos_usermetadata" \
+		-H "Metadata-Flavor: Google" > /tmp/payload/launch-params
+
+	cd /tmp/payload
+	SERVICE_NAME=`sed 's/,/\n/g' launch-params | grep SERVICE_NAME | cut -d "=" -f 2`
+	DEPLOYMENT=`sed 's/,/\n/g' launch-params | grep DEPLOYMENT | cut -d "=" -f 2`
+	INSTANCE_HOSTNAME=`sed 's/,/\n/g' launch-params | grep HOSTNAME | cut -d "=" -f 2`
+	PUPPET_IP=`sed 's/,/\n/g' launch-params | grep PUPPET_IP | cut -d "=" -f 2`
+	PUPPET_HOSTNAME=`sed 's/,/\n/g' launch-params | grep PUPPET_HOSTNAME | cut -d "=" -f 2`
+	PUPPET_ENV=`sed 's/,/\n/g' launch-params | grep PUPPET_ENV | cut -d "=" -f 2`
+	NODEID="${RANDOMNUMBER}.${DEPLOYMENT}.${SERVICE_NAME}"
+	#essential to have PUPPET_HOSTNAME at the end in order to auto-sign the certs
+	DOMAIN="${PUPPET_HOSTNAME}"
+	${ECHO} -e "\nNode Id ${NODEID}\n"
+	${ECHO} -e "\nDomain ${DOMAIN}\n"
+	sed -i "s/server=.*/server=${PUPPET_HOSTNAME}/g"  ${PUPPETCONF}
+	/etc/init.d/puppet restart    
+	ARGS=("-n${NODEID}" "-d${DOMAIN}" "-s${PUPPET_IP}")
+	HOST="${NODEID}.${DOMAIN}"
+	${HOSTNAME} ${HOST}
+	${ECHO} "${HOST}" > ${HOSTNAMEFILE}
+	${ECHO} "${PUPPET_IP}  ${PUPPET_HOSTNAME}" >> ${HOSTSFILE} 
+	${ECHO} "127.0.0.1 ${HOST}" >> ${HOSTSFILE}
+	/etc/init.d/hostname start
+
+	PUPPET=`which puppet`
+        PUPPETAGENT="${PUPPET} agent"
+        RUNPUPPET="${PUPPETAGENT} -vt"
+
+        ${SLEEP} 5
+
+        ${PUPPETAGENT} --enable
+
+        ${RUNPUPPET}
+
+        ${PUPPETAGENT} --disable
+    	${ECHO} -e "Initialization completed successfully."
+
+fi
+
+# END
+

http://git-wip-us.apache.org/repos/asf/stratos/blob/0fa71440/tools/init-scripts/init-vcloud.sh
----------------------------------------------------------------------
diff --git a/tools/init-scripts/init-vcloud.sh b/tools/init-scripts/init-vcloud.sh
new file mode 100755
index 0000000..168137a
--- /dev/null
+++ b/tools/init-scripts/init-vcloud.sh
@@ -0,0 +1,80 @@
+#!/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.
+#
+# --------------------------------------------------------------
+
+MKDIR=`which mkdir`
+UNZIP=`which unzip`
+ECHO=`which echo`
+FIND=`which find`
+GREP=`which grep`
+RM=`which rm`
+XARGS=`which xargs`
+SED=`which sed`
+CUT=`which cut`
+AWK=`which awk`
+IFCONFIG=`which ifconfig`
+HOSTNAME=`which hostname`
+SLEEP=`which sleep`
+TR=`which tr`
+HEAD=`which head`
+WGET=`which wget`
+PUPPETD=`which puppet`
+AGENT="agent"
+PUPPETAGENT="${PUPPETD} ${AGENT}"
+
+COMMAND="${PUPPETAGENT} -vt"
+IP=`${IFCONFIG} eth0 | ${GREP} -e "inet addr" | ${AWK} '{print $2}' | ${CUT} -d ':' -f 2`
+LOG=/tmp/puppet-init.log
+
+HOSTSFILE=/etc/hosts
+HOSTNAMEFILE=/etc/hostname
+PUPPETCONF=/etc/puppet/puppet.conf
+
+read_master() {
+	${COMMAND}
+}
+
+DATE=`date +%d%m%y%S`
+RANDOMNUMBER="`${TR} -c -d 0-9 < /dev/urandom | ${HEAD} -c 4`${DATE}"
+
+if [ -d /tmp/payload ]; then
+
+	cd /tmp/payload
+	SERVICE_NAME=`sed 's/,/\n/g' launch-params | grep SERVICE_NAME | cut -d "=" -f 2`
+	DEPLOYMENT=`sed 's/,/\n/g' launch-params | grep DEPLOYMENT | cut -d "=" -f 2`
+	INSTANCE_HOSTNAME=`sed 's/,/\n/g' launch-params | grep HOSTNAME | cut -d "=" -f 2`
+	PUPPET_IP=`sed 's/,/\n/g' launch-params | grep PUPPET_IP | cut -d "=" -f 2`
+	PUPPET_HOSTNAME=`sed 's/,/\n/g' launch-params | grep PUPPET_HOSTNAME | cut -d "=" -f 2`
+	PUPPET_ENV=`sed 's/,/\n/g' launch-params | grep PUPPET_ENV | cut -d "=" -f 2`
+	NODEID="${RANDOMNUMBER}.${DEPLOYMENT}.${SERVICE_NAME}"
+	#essential to have PUPPET_HOSTNAME at the end in order to auto-sign the certs
+	DOMAIN="${PUPPET_HOSTNAME}"
+	${ECHO} -e "\nNode Id ${NODEID}\n"
+	${ECHO} -e "\nDomain ${DOMAIN}\n"
+    
+    ARGS=("-n${NODEID}" "-d${DOMAIN}" "-s${PUPPET_IP}")
+    ${ECHO} "\nRunning puppet installation with arguments: ${ARGS[@]}"
+    exec /root/bin/puppetinstall/puppetinstall "${ARGS[@]}"
+
+fi
+
+# END
+

http://git-wip-us.apache.org/repos/asf/stratos/blob/0fa71440/tools/init-scripts/init.sh
----------------------------------------------------------------------
diff --git a/tools/init-scripts/init.sh b/tools/init-scripts/init.sh
new file mode 100755
index 0000000..6841808
--- /dev/null
+++ b/tools/init-scripts/init.sh
@@ -0,0 +1,165 @@
+#!/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.
+#
+# --------------------------------------------------------------
+
+MKDIR=`which mkdir`
+UNZIP=`which unzip`
+ECHO=`which echo`
+FIND=`which find`
+GREP=`which grep`
+RM=`which rm`
+XARGS=`which xargs`
+SED=`which sed`
+CUT=`which cut`
+AWK=`which awk`
+IFCONFIG=`which ifconfig`
+HOSTNAME=`which hostname`
+SLEEP=`which sleep`
+TR=`which tr`
+HEAD=`which head`
+WGET=`which wget`
+PUPPETD=`which puppet`
+AGENT="agent"
+PUPPETAGENT="${PUPPETD} ${AGENT}"
+OS=$(lsb_release -si)
+PUPPET_DNS_AVAILABLE=false
+
+COMMAND="${PUPPETAGENT} -vt"
+IP=`${IFCONFIG} eth0 | ${GREP} -e "inet addr" | ${AWK} '{print $2}' | ${CUT} -d ':' -f 2`
+LOG=/tmp/puppet-init.log
+
+HOSTSFILE=/etc/hosts
+HOSTNAMEFILE=/etc/hostname
+PUPPETCONF=/etc/puppet/puppet.conf
+
+read_master() {
+	${COMMAND}
+}
+
+
+is_public_ip_assigned() {
+
+while true
+do
+   wget http://169.254.169.254/latest/meta-data/public-ipv4
+   if [ ! -f public-ipv4 ]
+    	then
+      	echo "Public ipv4 file not found. Sleep and retry" >> $LOG
+      	sleep 2;
+      	continue;
+    	else
+      	echo "public-ipv4 file is available. Read value" >> $LOG
+      	# Here means file is available. Read the file
+      	read -r ip<public-ipv4;
+      	echo "value is **[$ip]** " >> $LOG
+
+      	if [ -z "$ip" ]
+        	then
+          	echo "File is empty. Retry...." >> $LOG
+          	sleep 2
+          	rm public-ipv4
+          	continue
+         	else
+           	echo "public ip is assigned. value is [$ip]. Remove file" >> $LOG
+           	rm public-ipv4
+           	break
+         	fi
+    	fi
+done
+}
+
+
+DATE=`date +%d%m%y%S`
+RANDOMNUMBER="`${TR} -c -d 0-9 < /dev/urandom | ${HEAD} -c 4`${DATE}"
+
+if [ ! -d /tmp/payload ]; then
+
+	## Check whether the public ip is assigned
+	is_public_ip_assigned
+
+	echo "Public ip have assigned. Continue.." >> $LOG
+
+	## Clean old poop
+	${ECHO} "Removing all existing certificates .."
+	#${FIND} /var/lib/puppet -type f -print0 | ${XARGS} -0r ${RM}
+
+	${MKDIR} -p /tmp/payload
+	${WGET} http://169.254.169.254/latest/user-data -O /tmp/payload/launch-params
+
+	cd /tmp/payload
+	SERVICE_NAME=`sed 's/,/\n/g' launch-params | grep SERVICE_NAME | cut -d "=" -f 2`
+	DEPLOYMENT=`sed 's/,/\n/g' launch-params | grep DEPLOYMENT | cut -d "=" -f 2`
+	INSTANCE_HOSTNAME=`sed 's/,/\n/g' launch-params | grep HOSTNAME | cut -d "=" -f 2`
+	PUPPET_IP=`sed 's/,/\n/g' launch-params | grep PUPPET_IP | cut -d "=" -f 2`
+	PUPPET_HOSTNAME=`sed 's/,/\n/g' launch-params | grep PUPPET_HOSTNAME | cut -d "=" -f 2`
+	PUPPET_ENV=`sed 's/,/\n/g' launch-params | grep PUPPET_ENV | cut -d "=" -f 2`
+	PUPPET_DNS_AVAILABLE=`sed 's/,/\n/g' launch-params | grep PUPPET_DNS_AVAILABLE | cut -d "=" -f 2`
+	
+	#If this property is not set, then set it as false
+	if [  -z $PUPPET_DNS_AVAILABLE ];then
+		PUPPET_DNS_AVAILABLE=false
+	fi
+	NODEID="${RANDOMNUMBER}.${DEPLOYMENT}.${SERVICE_NAME}"
+	#essential to have PUPPET_HOSTNAME at the end in order to auto-sign the certs
+	DOMAIN="${PUPPET_HOSTNAME}"
+	${ECHO} -e "\nNode Id ${NODEID}\n"
+	${ECHO} -e "\nDomain ${DOMAIN}\n"
+	sed -i "s/server=.*/server=${PUPPET_HOSTNAME}/g"  ${PUPPETCONF}
+	/etc/init.d/puppet restart    
+	ARGS=("-n${NODEID}" "-d${DOMAIN}" "-s${PUPPET_IP}")
+	HOST="${NODEID}.${DOMAIN}"
+	${HOSTNAME} ${HOST}
+	${ECHO} "${HOST}" > ${HOSTNAMEFILE}
+	if [ true != $PUPPET_DNS_AVAILABLE ] ; then
+		${ECHO} "${PUPPET_IP}  ${PUPPET_HOSTNAME}" >> ${HOSTSFILE} 
+	fi
+	${ECHO} "127.0.0.1 ${HOST}" >> ${HOSTSFILE}
+
+	if [ "$OS" = "CentOS" ]; then
+		#CentOS hostname change
+		${ECHO} "CentOS : Changing host name in /etc/sysconfig/network"
+		CENTOSHOSTNAME="/etc/sysconfig/network"
+		${ECHO} "NETWORKING=yes" > ${CENTOSHOSTNAME}
+		${ECHO} "HOSTNAME=${HOST}" >> ${CENTOSHOSTNAME}
+		${ECHO} "Network restarting..."
+		/etc/init.d/network restart
+		${SLEEP} 4	
+	else
+		#Ubuntu hostname change
+		/etc/init.d/hostname start
+	fi
+
+	PUPPET=`which puppet`
+        PUPPETAGENT="${PUPPET} agent"
+        RUNPUPPET="${PUPPETAGENT} -vt"
+
+        ${SLEEP} 5
+
+        ${PUPPETAGENT} --enable
+
+        ${RUNPUPPET}
+
+        ${PUPPETAGENT} --disable
+    	${ECHO} -e "Initialization completed successfully."
+
+fi
+
+# END