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 2013/06/29 09:19:08 UTC

[2/2] git commit: committing tools and scripts which help to create cartridges (PHP, MYSQL, TOMCAT)

committing tools and scripts which help to create cartridges (PHP, MYSQL, TOMCAT)


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

Branch: refs/heads/master
Commit: 04acd7eba0fed1518ae1faebd7412a2b3845b480
Parents: dc8b360
Author: Lakmal Warusawithana <la...@wso2.com>
Authored: Sat Jun 29 12:42:39 2013 +0530
Committer: Lakmal Warusawithana <la...@wso2.com>
Committed: Sat Jun 29 12:42:39 2013 +0530

----------------------------------------------------------------------
 tools/cartridge_create/README                   |  50 +++
 tools/cartridge_create/configure_software       | 363 +++++++++++++++++++
 tools/cartridge_create/create_kvm_image.sh      |   3 +
 tools/cartridge_create/image_action.sh          | 144 ++++++++
 .../init_scripts/default/default                |  22 ++
 .../init_scripts/default/default.ctrg           |  30 ++
 .../init_scripts/default/get-launch-params.rb   |  35 ++
 .../init_scripts/default/wso2-openstack-init.sh |  54 +++
 .../init_scripts/default/wso2.pem               |  16 +
 .../init_scripts/hello/ec2/get-launch-params.rb |  34 ++
 .../hello/ec2/wso2-cartridge-init.sh            | 232 ++++++++++++
 tools/cartridge_create/init_scripts/hello/hello |  23 ++
 .../init_scripts/hello/hello.ctrg               |  21 ++
 .../hello/openstack/get-launch-params.rb        |  35 ++
 .../hello/openstack/wso2-cartridge-init.sh      | 227 ++++++++++++
 .../init_scripts/mysql/ec2/get-launch-params.rb |  35 ++
 .../mysql/ec2/wso2-cartridge-init.sh            | 149 ++++++++
 .../init_scripts/mysql/get-launch-params.rb     |  35 ++
 tools/cartridge_create/init_scripts/mysql/mysql |  25 ++
 .../init_scripts/mysql/mysql.ctrg               |  37 ++
 .../mysql/openstack/get-launch-params.rb        |  35 ++
 .../mysql/openstack/wso2-cartridge-init.sh      | 141 +++++++
 .../mysql/vcloud/wso2-cartridge-init.sh         | 149 ++++++++
 .../init_scripts/mysql/wso2.pem                 |  16 +
 .../php/cartridge_data_publisher_1.0.2.zip      | Bin 0 -> 2832200 bytes
 tools/cartridge_create/init_scripts/php/default |  42 +++
 .../init_scripts/php/default-ssl                | 173 +++++++++
 .../init_scripts/php/ec2/get-launch-params.rb   |  34 ++
 .../init_scripts/php/ec2/wso2-cartridge-init.sh | 255 +++++++++++++
 .../init_scripts/php/get-launch-params.rb       |  35 ++
 .../php/openstack/get-launch-params.rb          |  35 ++
 .../php/openstack/wso2-cartridge-init.sh        | 246 +++++++++++++
 tools/cartridge_create/init_scripts/php/php     |  28 ++
 .../cartridge_create/init_scripts/php/php.ctrg  |  44 +++
 .../init_scripts/php/thrift-0.8.0.tar.gz        | Bin 0 -> 2379006 bytes
 .../cartridge_create/init_scripts/php/wso2.pem  |  16 +
 tools/cartridge_create/init_scripts/php/x.sh    |  30 ++
 tools/cartridge_create/init_scripts/php/y.sh    |  12 +
 .../init_scripts/tomcat7/get-launch-params.rb   |  35 ++
 .../init_scripts/tomcat7/payload/README         |  21 ++
 .../init_scripts/tomcat7/payload/launch-params  |   1 +
 .../init_scripts/tomcat7/wso2-openstack-init.sh | 165 +++++++++
 .../init_scripts/tomcat7/wso2.pem               |  16 +
 tools/cartridge_create/stratos-image            |  79 ++++
 tools/cartridge_create/stratos-image-local      | 290 +++++++++++++++
 tools/cartridge_create/uploadimg.sh             |  11 +
 46 files changed, 3479 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/04acd7eb/tools/cartridge_create/README
----------------------------------------------------------------------
diff --git a/tools/cartridge_create/README b/tools/cartridge_create/README
new file mode 100644
index 0000000..883fe48
--- /dev/null
+++ b/tools/cartridge_create/README
@@ -0,0 +1,50 @@
+This folder contain utilities to create customized images from the already running openstack instances.
+The main utility is a CLI tool called stratos-image.
+Pre-requisites:
+
+You need the private or public(floating)ip of the openstack instance from which you need to create the image. Also you need a username
+for that instance and a private key to access that instance. Copy the private key to init_scripts/<template> (e.g., init_scripts/php) folder.
+
+You need a file with the following information regarding the Openstack environment and copy that file into the current folder.
+When uploading the image you need the variables in the file exported to the environment. 
+Normally when you install the Openstack you get this file generated. Please refer to your Openstack installation documents 
+on how to get the information in this file.
+
+----------------------------------------------------------
+NOVA_API_HOST=192.168.16.20
+GLANCE_API_HOST=192.168.16.20
+KEYSTONE_API_HOST=192.168.16.20
+
+NOVA_REGION="nova"
+
+export NOVA_USERNAME=demo
+export NOVA_PROJECT_ID=demo
+export NOVA_PASSWORD=openstack
+export NOVA_API_KEY=openstack
+export NOVA_REGION_NAME=$NOVA_REGION
+export NOVA_URL="http://$NOVA_API_HOST:5000/v2.0/"
+export NOVA_VERSION="1.1"
+
+export OS_USERNAME=demo
+export OS_PASSWORD=openstack
+export OS_TENANT_ID=7434d33c18e04e60a6751922773fbe2d
+export OS_AUTH_URL="http://$KEYSTONE_API_HOST:5000/v2.0/"
+export OS_AUTH_STRATEGY="keystone"
+
+export EC2_URL="http://$NOVA_API_HOST:8773/services/Cloud"
+export EC2_ACCESS_KEY="8b742fee68c6464198517242828adb82"
+export EC2_SECRET_KEY="279a7f28c8a54d5db8e27524f648a7d3"
+export S3_URL="http://$GLANCE_API_HOST:3333"
+
+----------------------------------------------------------
+
+For help on how to execute stratos-image execute.
+./stratos-image help
+
+Following is an example of create and upload the image for php cartridge
+
+./stratos-image create 192.168.16.129 php ubuntu wso2.pem
+
+nova image-create <vm instance id> php-cloudimg-amd64
+
+

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/04acd7eb/tools/cartridge_create/configure_software
----------------------------------------------------------------------
diff --git a/tools/cartridge_create/configure_software b/tools/cartridge_create/configure_software
new file mode 100755
index 0000000..b77ff08
--- /dev/null
+++ b/tools/cartridge_create/configure_software
@@ -0,0 +1,363 @@
+#!/bin/bash
+
+ROOTFS=$1
+TEMPLATE=$2
+
+#
+# Locale settings (en_GB for Redcoats, en_US for Yanks):
+#
+LANG="en_US.UTF-8" 
+LANGUAGE="en_US.UTF-8" 
+LC_ALL="en_US.UTF-8" 
+LC_CTYPE="C"
+
+#
+# Ubuntu mirror to use:
+#
+###DEBMIRROR="http://archive.ubuntu.com/ubuntu/"
+#DEBMIRROR="http://us.archive.ubuntu.com/ubuntu/"
+DEBMIRROR="http://lk.archive.ubuntu.com/ubuntu/"
+
+
+mysql() {
+
+	# MySQL still prompts.  Bug.
+	#DEBCONF_FRONTEND='noninteractive' 
+	
+	chroot $ROOTFS apt-get update
+	# Next, all the LAMP packages.  We must first pre-save the password
+	# for MySQL to use:
+	#chroot $ROOTFS echo "mysql-server mysql-server/root_password select ubuntu" | chroot $ROOTFS debconf-set-selections
+	#chroot $ROOTFS echo "mysql-server mysql-server/root_password_again select ubuntu" | chroot $ROOTFS debconf-set-selections
+	
+	chroot $ROOTFS apt-get install -y \
+	nano zip mysql-server git \
+	apache2-mpm-prefork apache2-utils apache2.2-bin apache2.2-common dbconfig-common fontconfig-config libapache2-mod-php5 \
+	libaprutil1-dbd-sqlite3 libaprutil1-ldap libcap2 libfontconfig1 libgd2-xpm libjpeg-turbo8 libjpeg8 libmcrypt4 \
+	libt1-5 libxpm4 php5-cli php5-common php5-gd php5-mcrypt php5-mysql phpmyadmin ssl-cert ttf-dejavu-core ruby
+
+	# Be sure to have a new SSL cert for this new LXC host:
+	rm -f $ROOTFS/etc/ssl/private/ssl-cert-snakeoil.key
+    cp -f ./init_scripts/mysql/cc/ssl-cert-snakeoil.pem $ROOTFS/etc/ssl/certs/
+    cp -f ./init_scripts/mysql/cc/ssl-cert-snakeoil.key $ROOTFS/etc/ssl/private/
+	#chroot $ROOTFS dpkg-reconfigure ssl-cert
+
+	# Enable HTTPS:
+	chroot $ROOTFS a2enmod ssl
+	chroot $ROOTFS a2ensite default-ssl	
+	# Desable HTTP
+	chroot $ROOTFS a2dissite default	
+
+ 	# set mysql to listen to all network
+	chroot $ROOTFS cp /etc/mysql/my.cnf /etc/mysql/my.cnf.org
+	chroot $ROOTFS cat /etc/mysql/my.cnf.org | sed -e 's/127.0.0.1/0.0.0.0/' > $ROOTFS/etc/mysql/my.cnf	
+
+	# See http://blog.bodhizazen.net/linux/lxc-configure-ubuntu-lucid-containers/
+	# This requirement is confirmed on 10.04.1 LTS.  Within LXC, the
+	# upstart "startup" signal is sent, but not "network-interface", etc.
+	pushd $ROOTFS/etc/init/
+	cp -a ufw.conf ufw.conf-dist
+	sed '
+s/start on (starting network-interface/start on startup\n#start on (starting network-interface/
+s/          or starting network-manager/#          or starting network-manager/
+s/          or starting networking)/#          or starting network-manager/
+' < ufw.conf-dist > ufw.conf
+	
+	popd
+
+}
+
+php() {
+
+    cp -f ./init_scripts/php/wso2-openstack-init.sh $ROOTFS/opt/
+    cp -f ./init_scripts/php/get-launch-params.rb $ROOTFS/opt/
+    cp -f ./init_scripts/php/cc/ssl-cert-snakeoil.pem $ROOTFS/etc/ssl/certs/
+    cp -f ./init_scripts/php/cc/ssl-cert-snakeoil.key $ROOTFS/etc/ssl/private/
+    
+	chroot $ROOTFS apt-get update
+	# Next, all the packages. 
+	
+	chroot $ROOTFS apt-get install -y \
+    nano zip build-essential mysql-client apache2 php5 php5-cli libapache2-mod-php5 php5-gd php5-mysql php-db php-pear \
+    php5-curl curl wget php5-ldap php5-adodb mailutils php5-imap php5-ldap \
+    openssl ssl-cert ldap-utils php5-mcrypt mcrypt ufw fail2ban git libboost-all-dev ruby
+
+    # Install the thrift library
+    tar -zxf ./init_scripts/php/thrift-0.8.0.tar.gz -C$ROOTFS/opt
+    chroot $ROOTFS cd /opt/thrift-0.8.0;./configure --libdir=/usr/lib;make;make install
+    tar -zxf ./init_scripts/php/cartridge_data_publisher_1.0.0.tar.gz -C$ROOTFS/opt
+    chroot $ROOTFS cd /opt/cartridge_data_publisher_1.0.0;make
+
+	# install gitpython 
+	# chroot $ROOTFS easy_install GitPython
+
+
+	# configure apache log write to syslog TODO : Need generic solution
+	chroot $ROOTFS cp /etc/apache2/apache2.conf /etc/apache2/apache2.conf.org
+    chroot $ROOTFS cat /etc/apache2/apache2.conf.org | sed -e 's/^ErrorLog.*/ErrorLog syslog:local2/' > $ROOTFS/etc/apache2/apache2.conf
+
+	# configure rsyslog TODO : Need generic solution
+	chroot $ROOTFS cp /etc/rsyslog.conf /etc/rsyslog.conf.org
+    chroot $ROOTFS cat /etc/rsyslog.conf.org | sed -e 's/^#$ModLoad\simtcp.*/$ModLoad imtcp/' |  sed -e 's/^\#\$ModLoad\simtcp.*/\$ModLoad imtcp/' | sed -e 's/^\#\$InputTCPServerRun\s514.*/\$InputTCPServerRun 514\nlocal2\.\*        \@\@localhost\:32000/' > $ROOTFS/etc/rsyslog.conf
+
+
+# adding simplesaml alias to apache
+chroot $ROOTFS cp /etc/apache2/sites-available/default /etc/apache2/sites-available/default-org
+chroot $ROOTFS cp /etc/apache2/sites-available/default-ssl /etc/apache2/sites-available/default-ssl-org
+chroot $ROOTFS cat /etc/apache2/sites-available/default-org | sed -e 's@DocumentRoot \/var\/www@DocumentRoot \/var\/www\/public\n\tAlias \/simplesaml \/var\/www\/simplesamlphp\/www@' > $ROOTFS/etc/apache2/sites-available/default
+chroot $ROOTFS cat /etc/apache2/sites-available/default-ssl-org | sed -e 's@DocumentRoot \/var\/www@DocumentRoot \/var\/www\/public\n\tAlias \/simplesaml \/var\/www\/simplesamlphp\/www@' > $ROOTFS/etc/apache2/sites-available/default-ssl
+	# Enable HTTPS:
+	chroot $ROOTFS a2enmod ssl
+	chroot $ROOTFS a2ensite default-ssl	
+
+
+	# See http://blog.bodhizazen.net/linux/lxc-configure-ubuntu-lucid-containers/
+	# This requirement is confirmed on 10.04.1 LTS.  Within LXC, the
+	# upstart "startup" signal is sent, but not "network-interface", etc.
+	pushd $ROOTFS/etc/init/
+	cp -a ufw.conf ufw.conf-dist
+	sed '
+s/start on (starting network-interface/start on startup\n#start on (starting network-interface/
+s/          or starting network-manager/#          or starting network-manager/
+s/          or starting networking)/#          or starting network-manager/
+' < ufw.conf-dist > ufw.conf
+	popd
+	
+    pushd $ROOTFS/etc
+    echo "#!/bin/bash -e
+mkdir -p /etc/agent/conf
+chmod 755 /opt/wso2-openstack-init.sh
+/opt/wso2-openstack-init.sh > /var/log/wso2-openstack-init.log
+exit 0
+    " > rc.local
+    popd
+
+}
+
+lamp() {
+
+    cp -f ./init_scripts/lamp/wso2-openstack-init.sh $ROOTFS/opt/
+    cp -f ./init_scripts/lamp/get-launch-params.rb $ROOTFS/opt/
+    cp -f ./init_scripts/lamp/server $ROOTFS/opt/
+    cp -f ./init_scripts/lamp/svn_client.sh $ROOTFS/opt/
+    cp -f ./init_scripts/lamp/svn_client_y.sh $ROOTFS/opt/
+    cp -f ./init_scripts/lamp/deployer.sh $ROOTFS/opt/
+
+    # Copy software
+    arr=$(echo $SOFTWARE | tr ":" "\n")
+    for x in $arr
+    do
+       cp -rf $x $ROOTFS/opt/
+    done
+
+
+	# MySQL still prompts.  Bug.
+	#DEBCONF_FRONTEND='noninteractive' 
+	
+	chroot $ROOTFS apt-get update
+	# Next, all the LAMP packages.  We must first pre-save the password
+	# for MySQL to use:
+	chroot $ROOTFS echo "mysql-server mysql-server/root_password select ubuntu" | chroot $ROOTFS debconf-set-selections
+	chroot $ROOTFS echo "mysql-server mysql-server/root_password_again select ubuntu" | chroot $ROOTFS debconf-set-selections
+	
+	chroot $ROOTFS apt-get install -y \
+	 nano zip mysql-server mysql-client \
+	 apache2 php5 php5-cli libapache2-mod-php5 php5-gd php5-mysql php-db php-pear php5-curl curl wget php5-ldap php5-adodb mailutils \
+	 php5-imap php5-ldap \
+	 openssl ssl-cert ldap-utils \
+	 php5-mcrypt mcrypt ufw fail2ban ruby subversion
+
+	# Be sure to have a new SSL cert for this new LXC host:
+	#rm -f $ROOTFS/etc/ssl/private/ssl-cert-snakeoil.key
+	#chroot $ROOTFS dpkg-reconfigure ssl-cert
+
+	# Enable HTTPS:
+	#chroot $ROOTFS a2enmod ssl
+	#chroot $ROOTFS a2ensite default-ssl	
+
+	# Turn on MySQL replication logs by default.  (Necessary for 
+	# incremental backups, even if you're not doing replication.)
+	pushd $ROOTFS/etc/mysql/conf.d
+	echo "[mysqld]
+log-bin=mysqld-bin
+server-id = 1
+
+# For an SSH Tunneled slave:
+# See also: /etc/rc.local for the SSH Tunnel that makes this work.
+#[mysqld]
+#master-host     = 127.0.0.1
+#master-user     = root
+#master-password = ubuntu
+#master-port     = 13306
+#server-id       = 2
+	" >> replication.cnf
+	popd
+
+pushd $ROOTFS/etc
+    echo "#!/bin/bash -e
+/opt/wso2-openstack-init.sh > /var/log/wso2-openstack-init.log
+exit 0
+    " > rc.local
+    popd
+
+	# Next, fix a couple of Debian gotchas:
+
+	# Comment out these two lines.  (Don't expire,
+	# and use the 1G default file size.
+	pushd $ROOTFS/etc/mysql
+	cp -a my.cnf my.cnf-dist
+	sed '
+s/expire_logs_days/#expire_logs_days/
+s/max_binlog_size/#max_binlog_size/
+' < my.cnf-dist > my.cnf
+	popd
+	
+	# See http://blog.bodhizazen.net/linux/lxc-configure-ubuntu-lucid-containers/
+	# This requirement is confirmed on 10.04.1 LTS.  Within LXC, the
+	# upstart "startup" signal is sent, but not "network-interface", etc.
+	pushd $ROOTFS/etc/init/
+	cp -a ufw.conf ufw.conf-dist
+	sed '
+s/start on (starting network-interface/start on startup\n#start on (starting network-interface/
+s/          or starting network-manager/#          or starting network-manager/
+s/          or starting networking)/#          or starting network-manager/
+' < ufw.conf-dist > ufw.conf
+	
+	cp -a mysql.conf mysql.conf-dist
+	sed --posix -e '
+s/start on (net-device-up/start on startup\n#start on (net-device-up/
+s/          and local-filesystems/#          and local-filesystems/
+s/\t  and runlevel \[2345\])/#\t  and runlevel \[2345\])/
+' < mysql.conf-dist > mysql.conf
+	popd
+	
+}
+
+wso2_carbon_server() {
+
+    cp -f ./init_scripts/carbon/wso2-openstack-init.sh $ROOTFS/opt/
+    cp -f ./init_scripts/carbon/get-launch-params.rb $ROOTFS/opt/
+    # Copy software
+    arr=$(echo $SOFTWARE | tr ":" "\n")
+    for x in $arr
+    do
+       cp -rf $x $ROOTFS/opt/
+    done
+
+	#chroot $ROOTFS apt-get update
+	
+	 chroot $ROOTFS apt-get install -y \
+	 nano zip \
+	 wget \
+	 openssl ssl-cert ldap-utils ruby git
+  
+     # TODO install puppet agent
+
+	# Be sure to have a new SSL cert for this new LXC host:
+	#rm -f $ROOTFS/etc/ssl/private/ssl-cert-snakeoil.key
+	#chroot $ROOTFS dpkg-reconfigure ssl-cert
+
+pushd $ROOTFS/etc
+    echo "#!/bin/bash -e
+/opt/wso2-openstack-init.sh > /var/log/wso2-openstack-init.log
+exit 0
+    " > rc.local
+    popd
+
+}
+
+jetty() {
+
+    cp -f ./init_scripts/jetty/wso2-openstack-init.sh $ROOTFS/opt/
+    cp -f ./init_scripts/jetty/get-launch-params.rb $ROOTFS/opt/
+    cp -f ./init_scripts/jetty/server $ROOTFS/opt/
+    cp -f ./init_scripts/jetty/svn_client.sh $ROOTFS/opt/
+    cp -f ./init_scripts/jetty/svn_client_y.sh $ROOTFS/opt/
+    cp -f ./init_scripts/jetty/deployer.sh $ROOTFS/opt/
+    # Copy software
+    arr=$(echo $SOFTWARE | tr ":" "\n")
+    for x in $arr
+    do
+       cp -rf $x $ROOTFS/opt/
+    done
+
+	#chroot $ROOTFS apt-get update
+	
+	chroot $ROOTFS apt-get install -y \
+	 nano zip \
+	 wget \
+	 openssl ssl-cert ldap-utils ruby subversion
+   
+pushd $ROOTFS/etc
+    echo "#!/bin/bash -e
+/opt/wso2-openstack-init.sh > /var/log/wso2-openstack-init.log
+exit 0
+    " > rc.local
+    popd
+
+}
+
+
+tomcat7() {
+
+    #chroot $ROOTFS echo "nameserver 8.8.8.8" >> $ROOTFS/etc/resolvconf/resolv.conf.d/base
+    echo "Please fix the resolve conf file"
+    read
+    #chroot $ROOTFS mkdir -p /run/resolveconf
+    #chroot $ROORFS touch /run/resolveconf/resolv.conf
+    #chroot echo "nameserver 8.8.8.8" > /run/resolveconf/resolv.conf
+    
+    echo "------------------------------------------"
+    chroot $ROOTFS cat /etc/resolv.conf
+    echo "------------------------------------------"
+
+
+    mount -o bind /dev $ROOTFS/dev
+
+
+    mount -t proc none $ROOTFS/proc
+
+
+    cp -f ./init_scripts/tomcat7/wso2-openstack-init.sh $ROOTFS/opt/
+    cp -f ./init_scripts/tomcat7/get-launch-params.rb $ROOTFS/opt/
+    
+    
+	chroot $ROOTFS apt-get update
+	# Next, all the packages. 
+	
+    chroot $ROOTFS apt-get install -y \
+    nano zip git\
+    ruby curl wget tomcat7
+     
+	# See http://blog.bodhizazen.net/linux/lxc-configure-ubuntu-lucid-containers/
+	# This requirement is confirmed on 10.04.1 LTS.  Within LXC, the
+	# upstart "startup" signal is sent, but not "network-interface", etc.
+	pushd $ROOTFS/etc/init/
+	cp -a ufw.conf ufw.conf-dist
+	sed '
+s/start on (starting network-interface/start on startup\n#start on (starting network-interface/
+s/          or starting network-manager/#          or starting network-manager/
+s/          or starting networking)/#          or starting network-manager/
+' < ufw.conf-dist > ufw.conf
+	popd
+	
+    pushd $ROOTFS/etc
+    echo "#!/bin/bash -e
+mkdir -p /etc/agent/conf
+chmod 755 /opt/wso2-openstack-init.sh
+/opt/wso2-openstack-init.sh > /var/log/wso2-openstack-init.log
+exit 0
+    " > rc.local
+    popd
+
+    umount $ROOTFS/dev
+    umount $ROOTFS/proc
+}
+
+
+# Don't prompt when running apt-get:
+export DEBCONF_FRONTEND='noninteractive' 
+
+# Run the config function with given $TEMPLATE name (if it exists):
+$TEMPLATE 
+

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/04acd7eb/tools/cartridge_create/create_kvm_image.sh
----------------------------------------------------------------------
diff --git a/tools/cartridge_create/create_kvm_image.sh b/tools/cartridge_create/create_kvm_image.sh
new file mode 100755
index 0000000..ecee9ce
--- /dev/null
+++ b/tools/cartridge_create/create_kvm_image.sh
@@ -0,0 +1,3 @@
+#!/bin/bash
+./stratos-image create 192.168.16.131 mysql ubuntu wso2.pem
+#./stratos-image upload 192.168.16.131 precise-server-mysql-cloudimg-amd64

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/04acd7eb/tools/cartridge_create/image_action.sh
----------------------------------------------------------------------
diff --git a/tools/cartridge_create/image_action.sh b/tools/cartridge_create/image_action.sh
new file mode 100755
index 0000000..ed743c5
--- /dev/null
+++ b/tools/cartridge_create/image_action.sh
@@ -0,0 +1,144 @@
+#!/bin/bash
+# Die on any error:
+set -e
+
+work_dir=""
+action=""
+image_template=""
+image_root=""
+software=""
+image_type=""
+loopdevice="/dev/loop1"
+nbddevice="/dev/nbd3"
+nbdmount="/dev/nbd3p1"
+
+function image_validate {
+    if [ -z $action ]; then
+        echo "usage: image_action.sh action=<mount|create|unmount> <options>"
+        exit 1
+    fi
+
+    if [[ !($action == "mount") && !($action == "create") && !($action == "unmount") ]]; then
+        echo "usage: image_action.sh action=<mount|create|unmount> <options>"
+        exit 1
+    fi
+
+    if [[ (-n $action) && ($action == "create") && ( -z $image_template || -z $image_root ) ]]; then
+        echo "usage: image_action.sh action=create template=<template> image-root=<image_root>"
+        exit 1
+    fi
+
+    if [[ (-n $action) && ($action == "unmount") && (-z $image_template || -z $image_root) ]]; then
+        echo "usage: image_action.sh action=unmount image-id=<image_template> image-root=<image_root>"
+        exit 1
+    fi
+    
+    if [[ (-n $action) && ($action == "mount") && (-z $image_template || -z $image_root || -z $image_image) ]]; then
+        echo "usage: image_action.sh action=mount image-template=<image_template> image-root=<image_root> image-image=<image_image>"
+        exit 1
+    fi
+    
+}
+
+for var in $@; do
+    set -- `echo $var | tr '=' ' '`
+    key=$1
+    value=$2
+
+    if [ $key = "action" ]; then
+        action="$value"
+        echo "action:" $action
+    fi
+
+    if [ $key = "image-root" ]; then
+        image_root="$value"
+        echo "image root:" $image_root
+    fi
+    
+    if [ $key = "image-template" ]; then
+        image_template="$value"
+        echo "template:" $image_template
+    fi
+    
+    if [ $key = "image-image" ]; then
+        image_image="$value"
+        echo "image-image:" $image_image
+    fi
+    
+    if [ $key = "software" ]; then
+        software="$value"
+        echo "software:" $software
+    fi
+    
+    if [ $key = "image-type" ]; then
+        image_type="$value"
+        echo "image_type:" $image_type
+    fi
+
+done
+
+image_validate
+
+work_dir="$image_root/$image_template"
+if [[ (-n $action) && ($action == "unmount") ]]; then
+    echo "# unmount $image_template"
+    if [ -d $work_dir/$image_template ]; then
+        if [ $image_type == "qcow2" ]; then
+            umount $work_dir/$image_template
+            qemu-nbd -d $nbddevice
+            rmmod nbd
+        else
+            echo 'this action unmount image!'
+            umount $work_dir/$image_template/dev
+            umount $work_dir/$image_template/proc
+            umount $work_dir/$image_template/sys
+            umount $work_dir/$image_template
+            if [ -d $work_dir/$image_template/dev ]; then
+                umount -l $work_dir/$image_template
+            fi
+            losetup -d $loopdevice
+        fi
+    fi
+    exit 0
+fi
+
+if [[ (-n $action) && ($action == "mount") ]]; then
+    echo "# mount $image_template "
+    if [ ! -d "$work_dir/$image_template" ]; then
+        mkdir -p $work_dir/$image_template
+    fi
+    #cp -f $image_image $work_dir/
+    if [ $image_type == "qcow2" ]; then
+        modprobe nbd max_part=8
+        qemu-nbd -c $nbddevice $image_image
+        mount $nbdmount $work_dir/$image_template
+    else
+        #loopdevice=`losetup -f`
+        echo "Available loop device is $loopdevice"
+        losetup $loopdevice $image_image
+        #kpartx -av $loopdevice
+        mount $loopdevice $work_dir/$image_template 
+        mount -o bind /dev $work_dir/$image_template/dev
+        mount -o bind /proc $work_dir/$image_template/proc
+        mount -o bind /sys $work_dir/$image_template/sys
+    fi
+    exit 0
+fi
+
+# Where to create newly-created LXC container rootfs filesystems, fstabs, and confs:
+export BASEDIR=$work_dir
+
+# This is a list of semi-colon separated files/directories that will be needed by templates.
+export SOFTWARE="$software"
+export ROOTFS=$work_dir/$image_template
+export TEMPLATE=$image_template
+
+if [ -z "$TEMPLATE" ]; then
+	TEMPLATE="default"
+fi
+
+./configure_software $ROOTFS $TEMPLATE
+echo
+
+exit
+

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/04acd7eb/tools/cartridge_create/init_scripts/default/default
----------------------------------------------------------------------
diff --git a/tools/cartridge_create/init_scripts/default/default b/tools/cartridge_create/init_scripts/default/default
new file mode 100644
index 0000000..3197ea0
--- /dev/null
+++ b/tools/cartridge_create/init_scripts/default/default
@@ -0,0 +1,22 @@
+#!/bin/bash
+INSTANCE=$1
+INSTANCE_USER=$2
+KEY=$3
+SOFTWARE=$4
+
+SCP="scp -i ./$KEY"
+SSH="ssh -i ./$KEY"
+
+$SCP ./wso2-openstack-init.sh $INSTANCE_USER@$INSTANCE:
+$SCP ./default.ctrg $INSTANCE_USER@$INSTANCE:
+$SCP ./get-launch-params.rb $INSTANCE_USER@$INSTANCE:
+
+# Copy additional software
+arr=$(echo $SOFTWARE | tr ":" "\n")
+for x in $arr
+do
+   $SCP $x $INSTANCE_USER@$INSTANCE:
+done
+
+# Execute the cartridge creation process in the remoter server
+$SSH $INSTANCE_USER@$INSTANCE "sudo chmod 755 ./default.ctrg;sudo ./default.ctrg"

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/04acd7eb/tools/cartridge_create/init_scripts/default/default.ctrg
----------------------------------------------------------------------
diff --git a/tools/cartridge_create/init_scripts/default/default.ctrg b/tools/cartridge_create/init_scripts/default/default.ctrg
new file mode 100644
index 0000000..202aace
--- /dev/null
+++ b/tools/cartridge_create/init_scripts/default/default.ctrg
@@ -0,0 +1,30 @@
+#!/bin/bash
+    mv ./wso2-openstack-init.sh /opt/
+    mv ./default.ctrg 
+    mv ./get-launch-params.rb /opt/
+    mv ./*.tar.gz /opt/
+    mv ./*.zip /opt/
+
+	apt-get update
+	# Next, all th packages.
+	
+	# See http://blog.bodhizazen.net/linux/lxc-configure-ubuntu-lucid-containers/
+	# This requirement is confirmed on 10.04.1 LTS.  Within LXC, the
+	# upstart "startup" signal is sent, but not "network-interface", etc.
+	pushd /etc/init/
+	cp -a ufw.conf ufw.conf-dist
+	sed '
+s/start on (starting network-interface/start on startup\n#start on (starting network-interface/
+s/          or starting network-manager/#          or starting network-manager/
+s/          or starting networking)/#          or starting network-manager/
+' < ufw.conf-dist > ufw.conf
+	
+	popd
+    
+    pushd /etc
+    echo "#!/bin/bash -e
+chmod 755 /opt/wso2-openstack-init.sh
+/opt/wso2-openstack-init.sh > /var/log/wso2-openstack-init.log
+exit 0
+    " > rc.local
+    popd

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/04acd7eb/tools/cartridge_create/init_scripts/default/get-launch-params.rb
----------------------------------------------------------------------
diff --git a/tools/cartridge_create/init_scripts/default/get-launch-params.rb b/tools/cartridge_create/init_scripts/default/get-launch-params.rb
new file mode 100644
index 0000000..068e6c6
--- /dev/null
+++ b/tools/cartridge_create/init_scripts/default/get-launch-params.rb
@@ -0,0 +1,35 @@
+#! /usr/bin/ruby
+
+### get-launch-params.rb
+
+# The following script obtains the launch parameters from 
+# the file /tmp/payload/launch-params, then parses out the 
+# parameters for this instance by using the launch index
+# of this particular EC2 instance.
+#
+# Pass the command the -e flag to output the instance 
+# parameters as exports of shell variables. Any other 
+# arguments are ignored.
+
+def get_launch_params(launch_params_file)
+  IO.readlines launch_params_file
+end
+
+export_stmt = ""
+
+launch_params = get_launch_params(
+  "/var/lib/cloud/instance/payload/launch-params")
+
+if launch_params.length > 0
+  instance_params_str = launch_params[0]
+
+  instance_params = instance_params_str.split(',')
+
+  export_stmt = "export " if ARGV.length > 0 && ARGV.include?("-e")
+
+  instance_params.each { |param|
+    puts export_stmt + param
+  }
+
+end
+

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/04acd7eb/tools/cartridge_create/init_scripts/default/wso2-openstack-init.sh
----------------------------------------------------------------------
diff --git a/tools/cartridge_create/init_scripts/default/wso2-openstack-init.sh b/tools/cartridge_create/init_scripts/default/wso2-openstack-init.sh
new file mode 100644
index 0000000..aa1c8a0
--- /dev/null
+++ b/tools/cartridge_create/init_scripts/default/wso2-openstack-init.sh
@@ -0,0 +1,54 @@
+#!/bin/bash
+
+# ----------------------------------------------------------------------------
+#  Copyright 2005-20012 WSO2, Inc. http://www.wso2.org
+#
+#  Licensed 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.
+
+# ----------------------------------------------------------------------------
+export LOG=/var/log/wso2-openstack.log
+instance_path=/var/lib/cloud/instance
+
+if [ ! -d ${instance_path}/payload ]; then
+
+    echo "creating payload dir ... " >> $LOG
+    mkdir ${instance_path}/payload
+    echo "payload dir created ... " >> $LOG
+    cp ${instance_path}/user-data.txt ${instance_path}/payload/user-data.zip
+    echo "payload copied  ... "  >> $LOG
+    unzip -d ${instance_path}/payload ${instance_path}/payload/user-data.zip
+    echo "unzippeddd..." >> $LOG
+
+    for i in `/usr/bin/ruby /opt/get-launch-params.rb`
+    do
+    echo "exporting to bashrc $i ... " >> $LOG
+        echo "export" ${i} >> /home/ubuntu/.bashrc
+    done
+    source /home/ubuntu/.bashrc
+    # Write a cronjob to execute wso2-openstack-init.sh periodically until public ip is assigned
+    #crontab -l > ./mycron
+    #echo "*/${CRON_DURATION} * * * * /opt/wso2-openstack-init.sh > /var/log/wso2-openstack-init.log" >> ./mycron
+    #crontab ./mycron
+    #rm ./mycron
+
+fi
+
+
+
+for i in `/usr/bin/ruby /opt/get-launch-params.rb`
+do
+    export ${i}
+done
+
+echo "Done" >> $LOG
+# ========================== // End of script ===========================================================

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/04acd7eb/tools/cartridge_create/init_scripts/default/wso2.pem
----------------------------------------------------------------------
diff --git a/tools/cartridge_create/init_scripts/default/wso2.pem b/tools/cartridge_create/init_scripts/default/wso2.pem
new file mode 100644
index 0000000..7b2155e
--- /dev/null
+++ b/tools/cartridge_create/init_scripts/default/wso2.pem
@@ -0,0 +1,16 @@
+-----BEGIN RSA PRIVATE KEY-----
+MIICXQIBAAKBgQDUdNzv8oHkA8Zn28iQH2qyiV7ZJlBITqp4iw21ZbuyhFtDw2c0
+7euC/g4zbdLjAO4Wofn03C9LSA8KcWKYz4ubaKd+6xG/ywTW2QDRFdGDUY6Dwvkj
+3vnLlPWqvRBpF8ZclkeIjX6svydRvov3F6BSsbYY3trm9PlMtsZq/jtswwIDAQAB
+AoGAEJTqZYPc5WnyA0shFTaOgk68a2BVJb+WCIB52m2NP7qa0OggVv42wmuHujXZ
+HsSE0Jllw9mni02ddugwlNKmB5+z2yiJoGkuaFhFNwB4xFjjujRwMf7ZtoDpa8Yo
+SS1f94dswB31kT601HcUyCEwRBfD9pYBduysFZ1I3/ozVukCQQDs1Lm+LvmZQgLa
+BaWqU73MShDypiyMHVyKwnDUu/zaHu+9r15z/UHroU2nRIRteNv77nUmHsQVHKOc
+0QpmEsT3AkEA5acVolx+4mSCe4ZXh1R9hHZ+HdRrvC2yBiZhHe3bHbcyBN+oPMF4
+OcUE2JsE2+IIJomC5B/v6vjsf67yCFo/lQJAfm+jKjGR94wSUasqIqDKd0IjgifN
+KJCUU1AzRJ+IAjr56t6xImNWyiE3f9FIkdkwOHO5/zv1mv/LKXFAh/YFSQJBAMKE
+MWjiW366j2K9OWohAGewTcZKZC5xrfZTj7LgAtY6kx1Zq5A6dvDHlgE53HW6EBlE
+JB/BhV9LFFZaAhtdBbkCQQDrx9X5f/Lbe39kx5UMtvYrswpYjbKW+qRoQ38NryYA
+G7rRPsgmrjURSEeH4VUG//7gV8wGze7cl50luI2T8+Kg
+-----END RSA PRIVATE KEY-----
+

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/04acd7eb/tools/cartridge_create/init_scripts/hello/ec2/get-launch-params.rb
----------------------------------------------------------------------
diff --git a/tools/cartridge_create/init_scripts/hello/ec2/get-launch-params.rb b/tools/cartridge_create/init_scripts/hello/ec2/get-launch-params.rb
new file mode 100644
index 0000000..b369b4c
--- /dev/null
+++ b/tools/cartridge_create/init_scripts/hello/ec2/get-launch-params.rb
@@ -0,0 +1,34 @@
+#! /usr/bin/ruby
+
+### get-launch-params.rb
+
+# The following script obtains the launch parameters from 
+# the file /tmp/payload/launch-params, then parses out the 
+# parameters for this instance by using the launch index
+# of this particular EC2 instance.
+#
+# Pass the command the -e flag to output the instance 
+# parameters as exports of shell variables. Any other 
+# arguments are ignored.
+
+def get_launch_params(launch_params_file)
+  IO.readlines launch_params_file
+end
+
+export_stmt = ""
+
+launch_params = get_launch_params(
+  "/opt/payload/launch-params")
+
+if launch_params.length > 0
+  instance_params_str = launch_params[0]
+
+  instance_params = instance_params_str.split(',')
+
+  export_stmt = "export " if ARGV.length > 0 && ARGV.include?("-e")
+
+  instance_params.each { |param|
+    puts export_stmt + param
+  }
+
+end

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/04acd7eb/tools/cartridge_create/init_scripts/hello/ec2/wso2-cartridge-init.sh
----------------------------------------------------------------------
diff --git a/tools/cartridge_create/init_scripts/hello/ec2/wso2-cartridge-init.sh b/tools/cartridge_create/init_scripts/hello/ec2/wso2-cartridge-init.sh
new file mode 100644
index 0000000..70f8a1a
--- /dev/null
+++ b/tools/cartridge_create/init_scripts/hello/ec2/wso2-cartridge-init.sh
@@ -0,0 +1,232 @@
+#!/bin/bash
+
+# ----------------------------------------------------------------------------
+#  Copyright 2005-20012 WSO2, Inc. http://www.wso2.org
+#
+#  Licensed 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.
+
+# ----------------------------------------------------------------------------
+export LOG=/var/log/wso2-cartridge.log
+instance_path=/opt
+PUBLIC_IP=""
+KEY=`uuidgen`
+CRON_DURATION=1
+RETRY_COUNT=30
+SLEEP_DURATION=3
+
+
+if [ ! -d ${instance_path}/payload ]; then
+
+    echo "creating payload dir ... " >> $LOG
+    mkdir ${instance_path}/payload
+    echo "payload dir created ... " >> $LOG
+    wget http://169.254.169.254/latest/user-data -O ${instance_path}/payload/payload.zip    
+    echo "payload copied  ... "  >> $LOG
+    unzip -d ${instance_path}/payload ${instance_path}/payload/payload.zip
+    echo "unzippeddd..." >> $LOG
+
+    for i in `/usr/bin/ruby /opt/get-launch-params.rb`
+    do
+    echo "exporting to bashrc $i ... " >> $LOG
+        echo "export" ${i} >> /home/ubuntu/.bashrc
+    done
+    source /home/ubuntu/.bashrc
+
+fi
+
+
+echo ---------------------------- >> $LOG
+echo "getting public ip from metadata service" >> $LOG
+
+wget http://169.254.169.254/latest/meta-data/public-ipv4
+files="`cat public-ipv4`"
+if [[ -z ${files} ]]; then
+    echo "getting public ip" >> $LOG
+    for i in {1..30}
+    do
+      rm -f ./public-ipv4
+      wget http://169.254.169.254/latest/meta-data/public-ipv4
+      files="`cat public-ipv4`"
+      if [ -z $files ]; then
+          echo "Public ip is not yet assigned. Wait and continue for $i the time ..." >> $LOG
+          sleep $SLEEP_DURATION
+      else
+          echo "Public ip assigned" >> $LOG
+          break
+      fi
+    done
+
+    if [ -z $files ]; then
+      echo "Public ip is not yet assigned. So exit" >> $LOG
+      exit 0
+    fi
+    for x in $files
+    do
+        PUBLIC_IP="$x"
+    done
+
+
+else 
+   PUBLIC_IP="$files"
+fi
+
+
+for i in `/usr/bin/ruby /opt/get-launch-params.rb`
+do
+    export ${i}
+done
+
+echo "Logging sys variables .. PUBLIC_IP:${PUBLIC_IP}, HOST_NAME:${HOST_NAME}, KEY:${KEY}, PORTS=${PORTS}, BAM:${BAM_IP}, GITREPO:${GIT_REPO}" >> $LOG
+
+mkdir -p  /etc/agent/conf
+
+echo "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:agen=\"http://service.agent.cartridge.carbon.wso2.org\">
+  <soapenv:Header/>
+  <soapenv:Body>
+     <agen:register>
+        <registrant> 
+           <alarmingLowerRate>${ALARMING_LOWER_RATE}</alarmingLowerRate>
+           <alarmingUpperRate>${ALARMING_UPPER_RATE}</alarmingUpperRate>
+           <hostName>${HOST_NAME}</hostName>
+           <key>${KEY}</key>
+          <maxInstanceCount>${MAX}</maxInstanceCount>
+      <maxRequestsPerSecond>${MAX_REQUESTS_PER_SEC}</maxRequestsPerSecond>
+          <minInstanceCount>${MIN}</minInstanceCount> " > /etc/agent/conf/request.xml
+
+IFS='|' read -ra PT <<< "${PORTS}"
+for i in "${PT[@]}"; do
+IFS=':' read -ra PP <<< "$i"
+echo "          <portMappings>
+                        <primaryPort>${PP[1]}</primaryPort>
+                        <proxyPort>${PP[2]}</proxyPort>
+                        <type>${PP[0]}</type>
+                </portMappings>">> /etc/agent/conf/request.xml
+done
+
+echo "          <remoteHost>${PUBLIC_IP}</remoteHost>
+           <service>${SERVICE}</service>
+       <remoteHost>${PUBLIC_IP}</remoteHost>
+           <roundsToAverage>${ROUNDS_TO_AVERAGE}</roundsToAverage>
+           <scaleDownFactor>${SCALE_DOWN_FACTOR}</scaleDownFactor>
+           <tenantRange>${TENANT_RANGE}</tenantRange>
+        </registrant>
+     </agen:register>
+  </soapenv:Body>
+</soapenv:Envelope>
+" >> /etc/agent/conf/request.xml
+
+echo "Creating repoinfo request  " >> $LOG
+echo "TENANT_ID and SERVICE ${TENANT_ID} and ${SERVICE} " >> $LOG
+set -- "${HOST_NAME}" 
+IFS="."; declare -a Array=($*)
+ALIAS="${Array[0]}"
+echo "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsd=\"http://org.apache.axis2/xsd\">
+   <soapenv:Header/>
+   <soapenv:Body>
+      <xsd:getRepositoryCredentials>
+         <xsd:tenantId>${TENANT_ID}</xsd:tenantId>
+         <xsd:cartridgeType>${SERVICE}</xsd:cartridgeType>
+         <xsd:alias>${ALIAS}</xsd:alias>
+      </xsd:getRepositoryCredentials>
+   </soapenv:Body>
+</soapenv:Envelope>" > /opt/repoinforequest.xml
+
+echo "Repoinfo request created " >> $LOG
+
+echo "Private Key....Copying to .ssh  " >> $LOG
+
+cp ${instance_path}/payload/id_rsa /root/.ssh/id_rsa
+chmod 0600 /root/.ssh/id_rsa
+echo "StrictHostKeyChecking no" >> /root/.ssh/config
+
+
+cp -f ${instance_path}/payload/ssl-cert-snakeoil.pem /etc/ssl/certs/ssl-cert-snakeoil.pem
+cp -f ${instance_path}/payload/ssl-cert-snakeoil.key /etc/ssl/private/ssl-cert-snakeoil.key
+
+/etc/init.d/apache2 restart
+
+echo "Sending register request to Cartridge agent service" >> $LOG
+
+curl -X POST -H "Content-Type: text/xml" -H "SOAPAction: urn:register" -d @/etc/agent/conf/request.xml -k --silent --output /dev/null "${CARTRIDGE_AGENT_EPR}"
+
+#echo "Getting repo username password from repoInfoService" >> $LOG
+#curl -X POST -H "Content-Type: text/xml" -d @/etc/agent/conf/request.xml --silent --output /dev/null "${CARTRIDGE_AGENT_EPR}"
+
+echo "Git repo sync" >> $LOG
+
+# If repo is available do a git pull, else clone
+echo "#!/bin/bash
+if [ -d \"${APP_PATH}/.git\" ]; then
+    cd ${APP_PATH}
+    
+    curl -X POST -H \"Content-Type: text/xml\" -H \"SOAPAction: urn:getRepositoryCredentials\" -d @/opt/repoinforequest.xml --silent  \"${REPO_INFO_EPR}\" --insecure > /tmp/git.xml
+   sed '1,5d' /tmp/git.xml > /tmp/git1.xml
+   sed '2d' /tmp/git1.xml > /tmp/git.xml
+   username=\`xml_grep 'ax211:userName' /tmp/git.xml --text_only\`
+   password=\`xml_grep 'ax211:password' /tmp/git.xml --text_only\`
+   repo=\`xml_grep 'ax211:url' /tmp/git.xml --text_only\`
+   rm /tmp/git1.xml
+   rm /tmp/git.xml
+   url=\`echo \$repo |sed 's/http.*\/\///g' |sed 's/\:.*//g' |sed 's/\/.*//g'\`
+   echo \"machine \${url} login \${username} password \${password}\" > ~/.netrc
+   sudo echo \"machine \${url} login \${username} password \${password}\" > /root/.netrc
+   chmod 600 ~/.netrc
+   sudo chmod 600 /root/.netrc
+   sudo git pull
+   rm ~/.netrc
+   sudo rm /root/.netrc
+
+    sudo chown -R www-data:www-data ${APP_PATH}/www
+    if [ -f \"${APP_PATH}/sql/alter.sql\" ]; then
+        mysql -h ${MYSQL_HOST} -u ${MYSQL_USER} -p${MYSQL_PASSWORD} < ${APP_PATH}/sql/alter.sql
+    fi
+else
+    sudo rm -f ${APP_PATH}/index.html
+   curl -X POST -H \"Content-Type: text/xml\" -H \"SOAPAction: urn:getRepositoryCredentials\" -d @/opt/repoinforequest.xml --silent  \"${REPO_INFO_EPR}\" --insecure > /tmp/git.xml
+   sed '1,5d' /tmp/git.xml > /tmp/git1.xml
+   sed '2d' /tmp/git1.xml > /tmp/git.xml
+   username=\`xml_grep 'ax211:userName' /tmp/git.xml --text_only\`
+   password=\`xml_grep 'ax211:password' /tmp/git.xml --text_only\`
+   repo=\`xml_grep 'ax211:url' /tmp/git.xml --text_only\`
+   rm /tmp/git1.xml
+   rm /tmp/git.xml
+   url=\`echo \$repo |sed 's/http.*\/\///g' |sed 's/\:.*//g' |sed 's/\/.*//g'\`
+   echo \"machine \${url} login \${username} password \${password}\" > ~/.netrc
+   sudo echo \"machine \${url} login \${username} password \${password}\" > /root/.netrc
+   chmod 600 ~/.netrc
+   sudo chmod 600 /root/.netrc
+   sudo git clone \${repo} ${APP_PATH}
+   rm ~/.netrc
+   sudo rm /root/.netrc
+ 
+
+    if [ -f \"${APP_PATH}/sql/init.sql\" ]; then
+        mysql -h ${MYSQL_HOST} -u ${MYSQL_USER} -p${MYSQL_PASSWORD} < ${APP_PATH}/sql/init.sql
+    fi
+    echo \"SetEnv STRATOS_MYSQL_USER ${MYSQL_USER}
+    SetEnv STRATOS_MYSQL_HOST ${MYSQL_HOST}
+    SetEnv STRATOS_MYSQL_PASSWORD ${MYSQL_PASSWORD}
+    \" > /tmp/.htaccess
+    sudo mv /tmp/.htaccess ${APP_PATH}/
+    sudo chown -R www-data:www-data ${APP_PATH}/www
+    
+
+
+fi" > /opt/git.sh
+echo "File created.." >> $LOG
+chmod 755 /opt/git.sh
+echo "running git clone........" >> $LOG
+su - ubuntu /opt/git.sh
+
+
+# ========================== // End of script ===========================================================

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/04acd7eb/tools/cartridge_create/init_scripts/hello/hello
----------------------------------------------------------------------
diff --git a/tools/cartridge_create/init_scripts/hello/hello b/tools/cartridge_create/init_scripts/hello/hello
new file mode 100644
index 0000000..f7c9910
--- /dev/null
+++ b/tools/cartridge_create/init_scripts/hello/hello
@@ -0,0 +1,23 @@
+#!/bin/bash
+INSTANCE=$1
+INSTANCE_USER=$2
+KEY=$3
+SOFTWARE=$4
+
+SCP="scp -i ./$KEY"
+SSH="ssh -i ./$KEY"
+
+$SCP ./openstack/wso2-cartridge-init.sh $INSTANCE_USER@$INSTANCE:
+$SCP ./hello.ctrg $INSTANCE_USER@$INSTANCE:
+$SCP ./openstack/get-launch-params.rb $INSTANCE_USER@$INSTANCE:
+$SCP ./ $INSTANCE_USER@$INSTANCE:
+
+# Copy additional software
+arr=$(echo $SOFTWARE | tr ":" "\n")
+for x in $arr
+do
+   $SCP $x $INSTANCE_USER@$INSTANCE:
+done
+
+# Execute the cartridge creation process in the remoter server
+$SSH $INSTANCE_USER@$INSTANCE "sudo chmod 755 ./hello.ctrg;sudo ./hello.ctrg"

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/04acd7eb/tools/cartridge_create/init_scripts/hello/hello.ctrg
----------------------------------------------------------------------
diff --git a/tools/cartridge_create/init_scripts/hello/hello.ctrg b/tools/cartridge_create/init_scripts/hello/hello.ctrg
new file mode 100644
index 0000000..36ea603
--- /dev/null
+++ b/tools/cartridge_create/init_scripts/hello/hello.ctrg
@@ -0,0 +1,21 @@
+#!/bin/bash
+mv ./wso2-cartridge-init.sh /opt/
+mv ./get-launch-params.rb /opt/
+mv ./*.tar.gz /opt/
+mv ./*.zip /opt/
+
+# In the following section you will install necessary software for your cartridge. Since this is a demo cartridge
+# we will just create a file called hello_world in /home/ubuntu folder
+
+echo "hello world" > hello_world
+
+#apt-get update
+#apt-get install nano
+
+    echo "#!/bin/bash -e
+chmod 755 /opt/wso2-cartridge-init.sh
+/opt/wso2-cartridge-init.sh > /var/log/wso2-cartridge-init.log
+exit 0
+    " > /etc/rc.local
+
+

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/04acd7eb/tools/cartridge_create/init_scripts/hello/openstack/get-launch-params.rb
----------------------------------------------------------------------
diff --git a/tools/cartridge_create/init_scripts/hello/openstack/get-launch-params.rb b/tools/cartridge_create/init_scripts/hello/openstack/get-launch-params.rb
new file mode 100755
index 0000000..068e6c6
--- /dev/null
+++ b/tools/cartridge_create/init_scripts/hello/openstack/get-launch-params.rb
@@ -0,0 +1,35 @@
+#! /usr/bin/ruby
+
+### get-launch-params.rb
+
+# The following script obtains the launch parameters from 
+# the file /tmp/payload/launch-params, then parses out the 
+# parameters for this instance by using the launch index
+# of this particular EC2 instance.
+#
+# Pass the command the -e flag to output the instance 
+# parameters as exports of shell variables. Any other 
+# arguments are ignored.
+
+def get_launch_params(launch_params_file)
+  IO.readlines launch_params_file
+end
+
+export_stmt = ""
+
+launch_params = get_launch_params(
+  "/var/lib/cloud/instance/payload/launch-params")
+
+if launch_params.length > 0
+  instance_params_str = launch_params[0]
+
+  instance_params = instance_params_str.split(',')
+
+  export_stmt = "export " if ARGV.length > 0 && ARGV.include?("-e")
+
+  instance_params.each { |param|
+    puts export_stmt + param
+  }
+
+end
+

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/04acd7eb/tools/cartridge_create/init_scripts/hello/openstack/wso2-cartridge-init.sh
----------------------------------------------------------------------
diff --git a/tools/cartridge_create/init_scripts/hello/openstack/wso2-cartridge-init.sh b/tools/cartridge_create/init_scripts/hello/openstack/wso2-cartridge-init.sh
new file mode 100644
index 0000000..ff06bca
--- /dev/null
+++ b/tools/cartridge_create/init_scripts/hello/openstack/wso2-cartridge-init.sh
@@ -0,0 +1,227 @@
+#!/bin/bash
+
+# ----------------------------------------------------------------------------
+#  Copyright 2005-20012 WSO2, Inc. http://www.wso2.org
+#
+#  Licensed 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.
+
+# ----------------------------------------------------------------------------
+export LOG=/var/log/wso2-cartridge.log
+instance_path=/var/lib/cloud/instance
+PUBLIC_IP=""
+KEY=`uuidgen`
+CRON_DURATION=1
+RETRY_COUNT=30
+SLEEP_DURATION=3
+
+
+if [ ! -d ${instance_path}/payload ]; then
+
+    echo "creating payload dir ... " >> $LOG
+    mkdir ${instance_path}/payload
+    echo "payload dir created ... " >> $LOG
+    cp ${instance_path}/user-data.txt ${instance_path}/payload/user-data.zip
+    echo "payload copied  ... "  >> $LOG
+    unzip -d ${instance_path}/payload ${instance_path}/payload/user-data.zip
+    echo "unzippeddd..." >> $LOG
+
+    for i in `/usr/bin/ruby /opt/get-launch-params.rb`
+    do
+    echo "exporting to bashrc $i ... " >> $LOG
+        echo "export" ${i} >> /home/ubuntu/.bashrc
+    done
+    source /home/ubuntu/.bashrc
+    # Write a cronjob to execute wso2-cartridge-init.sh periodically until public ip is assigned
+    #crontab -l > ./mycron
+    #echo "*/${CRON_DURATION} * * * * /opt/wso2-cartridge-init.sh > /var/log/wso2-cartridge-init.log" >> ./mycron
+    #crontab ./mycron
+    #rm ./mycron
+
+fi
+
+
+echo ---------------------------- >> $LOG
+echo "getting public ip from metadata service" >> $LOG
+
+wget http://169.254.169.254/latest/meta-data/public-ipv4
+files="`cat public-ipv4`"
+if [[ -z ${files} ]]; then
+    echo "getting public ip" >> $LOG
+    for i in {1..30}
+    do
+      rm -f ./public-ipv4
+      wget http://169.254.169.254/latest/meta-data/public-ipv4
+      files="`cat public-ipv4`"
+      if [ -z $files ]; then
+          echo "Public ip is not yet assigned. Wait and continue for $i the time ..." >> $LOG
+          sleep $SLEEP_DURATION
+      else
+          echo "Public ip assigned" >> $LOG
+          #crontab -r
+          break
+      fi
+    done
+
+    if [ -z $files ]; then
+      echo "Public ip is not yet assigned. So exit" >> $LOG
+      exit 0
+    fi
+    for x in $files
+    do
+        PUBLIC_IP="$x"
+    done
+
+
+else 
+   PUBLIC_IP="$files"
+   #crontab -r
+fi
+
+
+for i in `/usr/bin/ruby /opt/get-launch-params.rb`
+do
+    export ${i}
+done
+
+echo "Logging sys variables .. PUBLIC_IP:${PUBLIC_IP}, HOST_NAME:${HOST_NAME}, KEY:${KEY}, PORTS=${PORTS}, BAM:${BAM_IP}, GITREPO:${GIT_REPO}" >> $LOG
+
+mkdir -p  /etc/agent/conf
+
+echo "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:agen=\"http://service.agent.cartridge.carbon.wso2.org\">
+  <soapenv:Header/>
+  <soapenv:Body>
+     <agen:register>
+        <registrant> 
+           <alarmingLowerRate>${ALARMING_LOWER_RATE}</alarmingLowerRate>
+           <alarmingUpperRate>${ALARMING_UPPER_RATE}</alarmingUpperRate>
+           <hostName>${HOST_NAME}</hostName>
+           <key>${KEY}</key>
+          <maxInstanceCount>${MAX}</maxInstanceCount>
+      <maxRequestsPerSecond>${MAX_REQUESTS_PER_SEC}</maxRequestsPerSecond>
+          <minInstanceCount>${MIN}</minInstanceCount> " > /etc/agent/conf/request.xml
+
+IFS='|' read -ra PT <<< "${PORTS}"
+for i in "${PT[@]}"; do
+IFS=':' read -ra PP <<< "$i"
+echo "          <portMappings>
+                        <primaryPort>${PP[1]}</primaryPort>
+                        <proxyPort>${PP[2]}</proxyPort>
+                        <type>${PP[0]}</type>
+                </portMappings>">> /etc/agent/conf/request.xml
+done
+
+echo "          <remoteHost>${PUBLIC_IP}</remoteHost>
+           <service>${SERVICE}</service>
+       <remoteHost>${PUBLIC_IP}</remoteHost>
+           <roundsToAverage>${ROUNDS_TO_AVERAGE}</roundsToAverage>
+           <scaleDownFactor>${SCALE_DOWN_FACTOR}</scaleDownFactor>
+           <tenantRange>${TENANT_RANGE}</tenantRange>
+        </registrant>
+     </agen:register>
+  </soapenv:Body>
+</soapenv:Envelope>
+" >> /etc/agent/conf/request.xml
+
+echo "Creating repoinfo request  " >> $LOG
+echo "TENANT_ID and SERVICE ${TENANT_ID} and ${SERVICE} " >> $LOG
+set -- "${HOST_NAME}" 
+IFS="."; declare -a Array=($*)
+ALIAS="${Array[0]}"
+echo "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsd=\"http://org.apache.axis2/xsd\">
+   <soapenv:Header/>
+   <soapenv:Body>
+      <xsd:getRepositoryCredentials>
+         <xsd:tenantId>${TENANT_ID}</xsd:tenantId>
+         <xsd:cartridgeType>${SERVICE}</xsd:cartridgeType>
+         <xsd:alias>${ALIAS}</xsd:alias>
+      </xsd:getRepositoryCredentials>
+   </soapenv:Body>
+</soapenv:Envelope>" > /opt/repoinforequest.xml
+
+
+
+echo "Sending register request to Cartridge agent service" >> $LOG
+
+curl -X POST -H "Content-Type: text/xml" -H "SOAPAction: urn:register" -d @/etc/agent/conf/request.xml -k --silent --output /dev/null "${CARTRIDGE_AGENT_EPR}"
+
+sleep 5
+
+/etc/init.d/apache2 restart
+
+echo "Git repo sync" >> $LOG
+
+# If repo is available do a git pull, else clone
+echo "#!/bin/bash
+if [ -d \"${APP_PATH}/.git\" ]; then
+    cd ${APP_PATH}
+
+    curl -X POST -H \"Content-Type: text/xml\" -H \"SOAPAction: urn:getRepositoryCredentials\" -d @/opt/repoinforequest.xml --silent  \"${REPO_INFO_EPR}\" --insecure > /tmp/git.xml
+   sed '1,5d' /tmp/git.xml > /tmp/git1.xml
+   sed '2d' /tmp/git1.xml > /tmp/git.xml
+   username=\`xml_grep 'ax211:userName' /tmp/git.xml --text_only\`
+   password=\`xml_grep 'ax211:password' /tmp/git.xml --text_only\`
+   repo=\`xml_grep 'ax211:url' /tmp/git.xml --text_only\`
+   rm /tmp/git1.xml
+   rm /tmp/git.xml
+   url=\`echo \$repo |sed 's/http.*\/\///g' |sed 's/\:.*//g' |sed 's/\/.*//g'\`
+   echo \"machine \${url} login \${username} password \${password}\" > ~/.netrc
+   sudo echo \"machine \${url} login \${username} password \${password}\" > /root/.netrc
+   chmod 600 ~/.netrc
+   sudo chmod 600 /root/.netrc
+   sudo git pull
+   rm ~/.netrc
+   sudo rm /root/.netrc
+
+    sudo chown -R www-data:www-data ${APP_PATH}/www
+    if [ -f \"${APP_PATH}/sql/alter.sql\" ]; then
+        mysql -h ${MYSQL_HOST} -u ${MYSQL_USER} -p${MYSQL_PASSWORD} < ${APP_PATH}/sql/alter.sql
+    fi
+else
+    sudo rm -f ${APP_PATH}/index.html
+   curl -X POST -H \"Content-Type: text/xml\" -H \"SOAPAction: urn:getRepositoryCredentials\" -d @/opt/repoinforequest.xml --silent  \"${REPO_INFO_EPR}\" --insecure > /tmp/git.xml
+   sed '1,5d' /tmp/git.xml > /tmp/git1.xml
+   sed '2d' /tmp/git1.xml > /tmp/git.xml
+   username=\`xml_grep 'ax211:userName' /tmp/git.xml --text_only\`
+   password=\`xml_grep 'ax211:password' /tmp/git.xml --text_only\`
+   repo=\`xml_grep 'ax211:url' /tmp/git.xml --text_only\`
+   rm /tmp/git1.xml
+   rm /tmp/git.xml
+   url=\`echo \$repo |sed 's/http.*\/\///g' |sed 's/\:.*//g' |sed 's/\/.*//g'\`
+   echo \"machine \${url} login \${username} password \${password}\" > ~/.netrc
+   sudo echo \"machine \${url} login \${username} password \${password}\" > /root/.netrc
+   chmod 600 ~/.netrc
+   sudo chmod 600 /root/.netrc
+   sudo git clone \${repo} ${APP_PATH}
+   rm ~/.netrc
+   sudo rm /root/.netrc
+
+    if [ -f \"${APP_PATH}/sql/init.sql\" ]; then
+        mysql -h ${MYSQL_HOST} -u ${MYSQL_USER} -p${MYSQL_PASSWORD} < ${APP_PATH}/sql/init.sql
+    fi
+    echo \"SetEnv STRATOS_MYSQL_USER ${MYSQL_USER}
+    SetEnv STRATOS_MYSQL_HOST ${MYSQL_HOST}
+    SetEnv STRATOS_MYSQL_PASSWORD ${MYSQL_PASSWORD}
+    \" > /tmp/.htaccess
+    sudo mv /tmp/.htaccess ${APP_PATH}/
+    sudo chown -R www-data:www-data ${APP_PATH}/www
+    
+
+
+fi" > /opt/git.sh
+echo "File created.." >> $LOG
+chmod 755 /opt/git.sh
+echo "running git clone........" >> $LOG
+su - ubuntu /opt/git.sh
+
+
+# ========================== // End of script ===========================================================

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/04acd7eb/tools/cartridge_create/init_scripts/mysql/ec2/get-launch-params.rb
----------------------------------------------------------------------
diff --git a/tools/cartridge_create/init_scripts/mysql/ec2/get-launch-params.rb b/tools/cartridge_create/init_scripts/mysql/ec2/get-launch-params.rb
new file mode 100644
index 0000000..8858879
--- /dev/null
+++ b/tools/cartridge_create/init_scripts/mysql/ec2/get-launch-params.rb
@@ -0,0 +1,35 @@
+#! /usr/bin/ruby
+
+### get-launch-params.rb
+
+# The following script obtains the launch parameters from 
+# the file /tmp/payload/launch-params, then parses out the 
+# parameters for this instance by using the launch index
+# of this particular EC2 instance.
+#
+# Pass the command the -e flag to output the instance 
+# parameters as exports of shell variables. Any other 
+# arguments are ignored.
+
+def get_launch_params(launch_params_file)
+  IO.readlines launch_params_file
+end
+
+export_stmt = ""
+
+launch_params = get_launch_params(
+  "/opt/payload/launch-params")
+
+if launch_params.length > 0
+  instance_params_str = launch_params[0]
+
+  instance_params = instance_params_str.split(',')
+
+  export_stmt = "export " if ARGV.length > 0 && ARGV.include?("-e")
+
+  instance_params.each { |param|
+    puts export_stmt + param
+  }
+
+end
+

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/04acd7eb/tools/cartridge_create/init_scripts/mysql/ec2/wso2-cartridge-init.sh
----------------------------------------------------------------------
diff --git a/tools/cartridge_create/init_scripts/mysql/ec2/wso2-cartridge-init.sh b/tools/cartridge_create/init_scripts/mysql/ec2/wso2-cartridge-init.sh
new file mode 100644
index 0000000..7049993
--- /dev/null
+++ b/tools/cartridge_create/init_scripts/mysql/ec2/wso2-cartridge-init.sh
@@ -0,0 +1,149 @@
+#!/bin/bash
+
+# ----------------------------------------------------------------------------
+#  Copyright 2005-20012 WSO2, Inc. http://www.wso2.org
+#
+#  Licensed 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.
+
+# ----------------------------------------------------------------------------
+export LOG=/var/log/wso2-cartridge.log
+instance_path=/opt
+PUBLIC_IP=""
+KEY=`uuidgen`
+CRON_DURATION=1
+SLEEP_DURATION=3
+
+if [ ! -d ${instance_path}/payload ]; then
+
+    echo "creating payload dir ... " >> $LOG
+    mkdir ${instance_path}/payload
+    echo "payload dir created ... " >> $LOG
+    wget http://169.254.169.254/latest/user-data -O ${instance_path}/payload/payload.zip
+    echo "payload copied  ... "  >> $LOG
+    unzip -d ${instance_path}/payload ${instance_path}/payload/payload.zip
+    echo "unzipped..." >> $LOG
+
+    for i in `/usr/bin/ruby /opt/get-launch-params.rb`
+    do
+    echo "exporting to bashrc $i ... " >> $LOG
+        echo "export" ${i} >> /home/ubuntu/.bashrc
+    done
+    source /home/ubuntu/.bashrc
+
+fi
+
+if [ -f public-ipv4 ]; then
+    echo "public-ipv4 already exists. Removing the public-ipv4 file" >> $LOG
+    rm public-ipv4
+fi
+
+echo ---------------------------- >> $LOG
+echo "getting public ip from metadata service" >> $LOG
+
+wget http://169.254.169.254/latest/meta-data/public-ipv4
+files="`cat public-ipv4`"
+if [[ -z ${files} ]]; then
+    echo "getting public ip" >> $LOG
+    for i in {1..30}
+    do
+      rm -f ./public-ipv4
+      wget http://169.254.169.254/latest/meta-data/public-ipv4
+      files="`cat public-ipv4`"
+      if [ -z $files ]; then
+          echo "Public ip is not yet assigned. Wait and continue for $i the time ..." >> $LOG
+          sleep $SLEEP_DURATION
+      else
+          echo "Public ip assigned" >> $LOG
+          #crontab -r
+          break
+      fi
+    done
+
+    if [ -z $files ]; then
+      echo "Public ip is not yet assigned. So exit" >> $LOG
+      exit 0
+    fi
+    for x in $files
+    do
+        PUBLIC_IP="$x"
+    done
+
+
+else 
+   PUBLIC_IP="$files"
+   #crontab -r
+fi
+
+
+for i in `/usr/bin/ruby /opt/get-launch-params.rb`
+do
+    export ${i}
+done
+
+echo "Setting MySQL root password" >> $LOG
+if [[ (-n ${MYSQL_PASSWORD} ) ]]; then
+	mysqladmin -u root password "${MYSQL_PASSWORD}"
+	mysql -uroot -p${MYSQL_PASSWORD} -e "GRANT ALL PRIVILEGES ON *.* TO 'root'@'%'   IDENTIFIED BY '${MYSQL_PASSWORD}' WITH GRANT OPTION;flush privileges;"
+	echo "MySQL root password set" >> $LOG
+fi
+
+cp -f ${instance_path}/payload/ssl-cert-snakeoil.pem /etc/ssl/certs/ssl-cert-snakeoil.pem
+cp -f ${instance_path}/payload/ssl-cert-snakeoil.key /etc/ssl/private/ssl-cert-snakeoil.key
+/etc/init.d/apache2 restart
+
+echo "Logging sys variables .. PUBLIC_IP:${PUBLIC_IP}, HOST_NAME:${HOST_NAME}, KEY:${KEY}, PORTS=${PORTS} , BAM:${BAM_IP}, GITREPO:${GIT_REPO}" >> $LOG
+
+mkdir -p  /etc/agent/conf
+
+echo "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:agen=\"http://service.agent.cartridge.carbon.wso2.org\">
+  <soapenv:Header/>
+  <soapenv:Body>
+     <agen:register>
+        <registrant> 
+           <alarmingLowerRate>${ALARMING_LOWER_RATE}</alarmingLowerRate>
+           <alarmingUpperRate>${ALARMING_UPPER_RATE}</alarmingUpperRate>
+           <hostName>${HOST_NAME}</hostName>
+           <key>${KEY}</key>
+          <maxInstanceCount>${MAX}</maxInstanceCount>
+          <maxRequestsPerSecond>${MAX_REQUESTS_PER_SEC}</maxRequestsPerSecond>
+          <minInstanceCount>${MIN}</minInstanceCount> " > /etc/agent/conf/request.xml
+
+IFS='|' read -ra PT <<< "${PORTS}"
+for i in "${PT[@]}"; do
+IFS=':' read -ra PP <<< "$i"
+echo "          <portMappings>
+                        <primaryPort>${PP[1]}</primaryPort>
+                        <proxyPort>${PP[2]}</proxyPort>
+                        <type>${PP[0]}</type>
+                </portMappings>">> /etc/agent/conf/request.xml
+done
+
+echo "
+           <service>${SERVICE}</service>
+           <remoteHost>${PUBLIC_IP}</remoteHost>
+           <roundsToAverage>${ROUNDS_TO_AVERAGE}</roundsToAverage>
+           <scaleDownFactor>${SCALE_DOWN_FACTOR}</scaleDownFactor>
+           <tenantRange>${TENANT_RANGE}</tenantRange>
+        </registrant>
+     </agen:register>
+  </soapenv:Body>
+</soapenv:Envelope>
+" >> /etc/agent/conf/request.xml
+
+sleep 3
+echo "Sending register request to Cartridge agent service" >> $LOG
+curl -X POST -H "Content-Type: text/xml" -H "SOAPAction: urn:register" -d @/etc/agent/conf/request.xml -k --silent --output /dev/null "${CARTRIDGE_AGENT_EPR}"
+
+
+# ========================== // End of script ===========================================================
+

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/04acd7eb/tools/cartridge_create/init_scripts/mysql/get-launch-params.rb
----------------------------------------------------------------------
diff --git a/tools/cartridge_create/init_scripts/mysql/get-launch-params.rb b/tools/cartridge_create/init_scripts/mysql/get-launch-params.rb
new file mode 100644
index 0000000..068e6c6
--- /dev/null
+++ b/tools/cartridge_create/init_scripts/mysql/get-launch-params.rb
@@ -0,0 +1,35 @@
+#! /usr/bin/ruby
+
+### get-launch-params.rb
+
+# The following script obtains the launch parameters from 
+# the file /tmp/payload/launch-params, then parses out the 
+# parameters for this instance by using the launch index
+# of this particular EC2 instance.
+#
+# Pass the command the -e flag to output the instance 
+# parameters as exports of shell variables. Any other 
+# arguments are ignored.
+
+def get_launch_params(launch_params_file)
+  IO.readlines launch_params_file
+end
+
+export_stmt = ""
+
+launch_params = get_launch_params(
+  "/var/lib/cloud/instance/payload/launch-params")
+
+if launch_params.length > 0
+  instance_params_str = launch_params[0]
+
+  instance_params = instance_params_str.split(',')
+
+  export_stmt = "export " if ARGV.length > 0 && ARGV.include?("-e")
+
+  instance_params.each { |param|
+    puts export_stmt + param
+  }
+
+end
+

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/04acd7eb/tools/cartridge_create/init_scripts/mysql/mysql
----------------------------------------------------------------------
diff --git a/tools/cartridge_create/init_scripts/mysql/mysql b/tools/cartridge_create/init_scripts/mysql/mysql
new file mode 100644
index 0000000..964635f
--- /dev/null
+++ b/tools/cartridge_create/init_scripts/mysql/mysql
@@ -0,0 +1,25 @@
+#!/bin/bash
+INSTANCE=$1
+INSTANCE_USER=$2
+KEY=$3
+SOFTWARE=$4
+
+SCP="scp -i ./$KEY"
+SSH="ssh -i ./$KEY"
+
+$SCP ./wso2-cartridge-init.sh $INSTANCE_USER@$INSTANCE:
+$SCP ./mysql.ctrg $INSTANCE_USER@$INSTANCE:
+$SCP ./get-launch-params.rb $INSTANCE_USER@$INSTANCE:
+$SCP ./cc/ssl-cert-snakeoil.pem $INSTANCE_USER@$INSTANCE:
+$SCP ./cc/ssl-cert-snakeoil.key $INSTANCE_USER@$INSTANCE:
+$SCP ./phpMyAdmin-3.5.6-english.tar.xz $INSTANCE_USER@$INSTANCE:
+
+# Copy additional software
+arr=$(echo $SOFTWARE | tr ":" "\n")
+for x in $arr
+do
+   $SCP $x $INSTANCE_USER@$INSTANCE:
+done
+
+# Execute the cartridge creation process in the remoter server
+$SSH $INSTANCE_USER@$INSTANCE "sudo chmod 755 ./mysql.ctrg;sudo ./mysql.ctrg"

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/04acd7eb/tools/cartridge_create/init_scripts/mysql/mysql.ctrg
----------------------------------------------------------------------
diff --git a/tools/cartridge_create/init_scripts/mysql/mysql.ctrg b/tools/cartridge_create/init_scripts/mysql/mysql.ctrg
new file mode 100644
index 0000000..b86e50f
--- /dev/null
+++ b/tools/cartridge_create/init_scripts/mysql/mysql.ctrg
@@ -0,0 +1,37 @@
+#!/bin/bash
+    mv ./wso2-cartridge-init.sh /opt/
+    mv ./get-launch-params.rb /opt/
+    mv ./ssl-cert-snakeoil.pem /etc/ssl/certs/
+    mv ./ssl-cert-snakeoil.key /etc/ssl/private/
+    mv ./*.tar.gz /opt/
+    mv ./*.zip /opt/
+#    tar -xf phpMyAdmin-3.5.6-english.tar.xz
+	apt-get update
+	# Next, all th packages.
+	
+	apt-get install -y \
+	nano zip mysql-server git \
+	xml-twig-tools phpmyadmin ruby
+#	apache2-mpm-prefork apache2-utils apache2.2-bin apache2.2-common dbconfig-common fontconfig-config libapache2-mod-php5 \
+#	libaprutil1-dbd-sqlite3 libaprutil1-ldap libcap2 libfontconfig1 libgd2-xpm libjpeg-turbo8 libjpeg8 libmcrypt4 \
+#	libt1-5 libxpm4 php5-cli php5-common php5-gd php5-mcrypt php5-mysql ssl-cert ttf-dejavu-core libboost-all-dev ruby
+
+	# Enable HTTPS:
+	a2enmod ssl
+	a2ensite default-ssl	
+	# Desable HTTP
+#	a2dissite default	
+
+ 	# set mysql to listen to all network
+	cp /etc/mysql/my.cnf /etc/mysql/my.cnf.org
+	cat /etc/mysql/my.cnf.org | sed -e 's/127.0.0.1/0.0.0.0/' > $ROOTFS/etc/mysql/my.cnf	
+
+	# See http://blog.bodhizazen.net/linux/lxc-configure-ubuntu-lucid-containers/
+	# This requirement is confirmed on 10.04.1 LTS.  Within LXC, the
+	# upstart "startup" signal is sent, but not "network-interface", etc.
+    echo "#!/bin/bash -e
+mkdir -p /etc/agent/conf
+chmod 755 /opt/wso2-cartridge-init.sh
+/opt/wso2-cartridge-init.sh > /var/log/wso2-cartridge-init.log
+exit 0
+    " > /etc/rc.local

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/04acd7eb/tools/cartridge_create/init_scripts/mysql/openstack/get-launch-params.rb
----------------------------------------------------------------------
diff --git a/tools/cartridge_create/init_scripts/mysql/openstack/get-launch-params.rb b/tools/cartridge_create/init_scripts/mysql/openstack/get-launch-params.rb
new file mode 100644
index 0000000..068e6c6
--- /dev/null
+++ b/tools/cartridge_create/init_scripts/mysql/openstack/get-launch-params.rb
@@ -0,0 +1,35 @@
+#! /usr/bin/ruby
+
+### get-launch-params.rb
+
+# The following script obtains the launch parameters from 
+# the file /tmp/payload/launch-params, then parses out the 
+# parameters for this instance by using the launch index
+# of this particular EC2 instance.
+#
+# Pass the command the -e flag to output the instance 
+# parameters as exports of shell variables. Any other 
+# arguments are ignored.
+
+def get_launch_params(launch_params_file)
+  IO.readlines launch_params_file
+end
+
+export_stmt = ""
+
+launch_params = get_launch_params(
+  "/var/lib/cloud/instance/payload/launch-params")
+
+if launch_params.length > 0
+  instance_params_str = launch_params[0]
+
+  instance_params = instance_params_str.split(',')
+
+  export_stmt = "export " if ARGV.length > 0 && ARGV.include?("-e")
+
+  instance_params.each { |param|
+    puts export_stmt + param
+  }
+
+end
+

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/04acd7eb/tools/cartridge_create/init_scripts/mysql/openstack/wso2-cartridge-init.sh
----------------------------------------------------------------------
diff --git a/tools/cartridge_create/init_scripts/mysql/openstack/wso2-cartridge-init.sh b/tools/cartridge_create/init_scripts/mysql/openstack/wso2-cartridge-init.sh
new file mode 100644
index 0000000..3f8fe9e
--- /dev/null
+++ b/tools/cartridge_create/init_scripts/mysql/openstack/wso2-cartridge-init.sh
@@ -0,0 +1,141 @@
+#!/bin/bash
+
+# ----------------------------------------------------------------------------
+#  Copyright 2005-20012 WSO2, Inc. http://www.wso2.org
+#
+#  Licensed 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.
+
+# ----------------------------------------------------------------------------
+export LOG=/var/log/wso2-cartridge.log
+instance_path=/var/lib/cloud/instance
+PUBLIC_IP=""
+KEY=`uuidgen`
+CRON_DURATION=1
+RETRY_COUNT=30
+SLEEP_DURATION=3
+
+if [ ! -d ${instance_path}/payload ]; then
+
+    echo "creating payload dir ... " >> $LOG
+    mkdir ${instance_path}/payload
+    echo "payload dir created ... " >> $LOG
+    cp ${instance_path}/user-data.txt ${instance_path}/payload/user-data.zip
+    echo "payload copied  ... "  >> $LOG
+    unzip -d ${instance_path}/payload ${instance_path}/payload/user-data.zip
+    echo "unzippeddd..." >> $LOG
+
+    for i in `/usr/bin/ruby /opt/get-launch-params.rb`
+    do
+    echo "exporting to bashrc $i ... " >> $LOG
+        echo "export" ${i} >> /home/ubuntu/.bashrc
+    done
+    source /home/ubuntu/.bashrc
+    # Write a cronjob to execute wso2-cartridge-init.sh periodically until public ip is assigned
+    #crontab -l > ./mycron
+    #echo "*/${CRON_DURATION} * * * * /opt/wso2-cartridge-init.sh > /var/log/wso2-cartridge-init.log" >> ./mycron
+    #crontab ./mycron
+    #rm ./mycron
+
+fi
+
+
+echo ---------------------------- >> $LOG
+echo "getting public ip from metadata service" >> $LOG
+
+wget http://169.254.169.254/latest/meta-data/public-ipv4
+files="`cat public-ipv4`"
+if [[ -z ${files} ]]; then
+    echo "getting public ip" >> $LOG
+    for i in {1..30}
+    do
+      rm -f ./public-ipv4
+      wget http://169.254.169.254/latest/meta-data/public-ipv4
+      files="`cat public-ipv4`"
+      if [ -z $files ]; then
+          echo "Public ip is not yet assigned. Wait and continue for $i the time ..." >> $LOG
+          sleep $SLEEP_DURATION
+      else
+          echo "Public ip assigned" >> $LOG
+          #crontab -r
+          break
+      fi
+    done
+
+    if [ -z $files ]; then
+      echo "Public ip is not yet assigned. So exit" >> $LOG
+      exit 0
+    fi
+    for x in $files
+    do
+        PUBLIC_IP="$x"
+    done
+
+
+else 
+   PUBLIC_IP="$files"
+   #crontab -r
+fi
+
+
+for i in `/usr/bin/ruby /opt/get-launch-params.rb`
+do
+    export ${i}
+done
+
+#MYSQL_PASSWORD
+echo "Logging sys variables .. PUBLIC_IP:${PUBLIC_IP}, HOST_NAME:${HOST_NAME}, KEY:${KEY}, PORTS=${PORTS} , BAM:${BAM_IP}, GITREPO:${GIT_REPO}" >> $LOG
+
+
+mkdir -p  /etc/agent/conf
+
+echo "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:agen=\"http://service.agent.cartridge.carbon.wso2.org\">
+  <soapenv:Header/>
+  <soapenv:Body>
+     <agen:register>
+        <registrant> 
+           <alarmingLowerRate>${ALARMING_LOWER_RATE}</alarmingLowerRate>
+           <alarmingUpperRate>${ALARMING_UPPER_RATE}</alarmingUpperRate>
+           <hostName>${HOST_NAME}</hostName>
+           <key>${KEY}</key>
+          <maxInstanceCount>${MAX}</maxInstanceCount>
+      <maxRequestsPerSecond>${MAX_REQUESTS_PER_SEC}</maxRequestsPerSecond>
+          <minInstanceCount>${MIN}</minInstanceCount> " > /etc/agent/conf/request.xml
+
+IFS='|' read -ra PT <<< "${PORTS}"
+for i in "${PT[@]}"; do
+IFS=':' read -ra PP <<< "$i"
+echo "          <portMappings>
+                        <primaryPort>${PP[1]}</primaryPort>
+                        <proxyPort>${PP[2]}</proxyPort>
+                        <type>${PP[0]}</type>
+                </portMappings>">> /etc/agent/conf/request.xml
+done
+
+echo "          <remoteHost>${PUBLIC_IP}</remoteHost>
+           <service>${SERVICE}</service>
+       <remoteHost>${PUBLIC_IP}</remoteHost>
+           <roundsToAverage>${ROUNDS_TO_AVERAGE}</roundsToAverage>
+           <scaleDownFactor>${SCALE_DOWN_FACTOR}</scaleDownFactor>
+           <tenantRange>${TENANT_RANGE}</tenantRange>
+        </registrant>
+     </agen:register>
+  </soapenv:Body>
+</soapenv:Envelope>
+" >> /etc/agent/conf/request.xml
+
+
+echo "Sending register request to Cartridge agent service" >> $LOG
+
+curl -X POST -H "Content-Type: text/xml" -H "SOAPAction: urn:register" -d @/etc/agent/conf/request.xml --silent --output /dev/null "$CARTRIDGE_AGENT_EPR"
+
+# ========================== // End of script ===========================================================

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/04acd7eb/tools/cartridge_create/init_scripts/mysql/vcloud/wso2-cartridge-init.sh
----------------------------------------------------------------------
diff --git a/tools/cartridge_create/init_scripts/mysql/vcloud/wso2-cartridge-init.sh b/tools/cartridge_create/init_scripts/mysql/vcloud/wso2-cartridge-init.sh
new file mode 100644
index 0000000..4b5c4f9
--- /dev/null
+++ b/tools/cartridge_create/init_scripts/mysql/vcloud/wso2-cartridge-init.sh
@@ -0,0 +1,149 @@
+#!/bin/bash
+
+# ----------------------------------------------------------------------------
+#  Copyright 2005-20012 WSO2, Inc. http://www.wso2.org
+#
+#  Licensed 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.
+
+# ----------------------------------------------------------------------------
+export LOG=/var/log/wso2-cartridge.log
+instance_path=/var/lib/cloud/instance
+PUBLIC_IP=""
+KEY=`uuidgen`
+CRON_DURATION=1
+RETRY_COUNT=30
+SLEEP_DURATION=30
+
+#if [ ! -d ${instance_path}/payload ]; then
+#
+#    echo "creating payload dir ... " >> $LOG
+#    mkdir ${instance_path}/payload
+#    echo "payload dir created ... " >> $LOG
+#    cp ${instance_path}/user-data.txt ${instance_path}/payload/user-data.zip
+#    echo "payload copied  ... "  >> $LOG
+#    unzip -d ${instance_path}/payload ${instance_path}/payload/user-data.zip
+#    echo "unzippeddd..." >> $LOG
+#
+#    for i in `/usr/bin/ruby /opt/get-launch-params.rb`
+#    do
+#    echo "exporting to bashrc $i ... " >> $LOG
+#        echo "export" ${i} >> /home/ubuntu/.bashrc
+#    done
+#    source /home/ubuntu/.bashrc
+    # Write a cronjob to execute wso2-openstack-init.sh periodically until public ip is assigned
+    #crontab -l > ./mycron
+    #echo "*/${CRON_DURATION} * * * * /opt/wso2-openstack-init.sh > /var/log/wso2-openstack-init.log" >> ./mycron
+    #crontab ./mycron
+    #rm ./mycron
+
+#fi
+
+    for i in `/usr/bin/ruby /opt/get-launch-params.rb`
+    do
+    echo "exporting to bashrc $i ... " >> $LOG
+        echo "export" ${i} >> /root/.bashrc
+    done
+    source /root/.bashrc
+
+echo ---------------------------- >> $LOG
+echo "getting private IP" >> $LOG
+
+#wget http://169.254.169.254/latest/meta-data/public-ipv4
+#files="`cat public-ipv4`"
+#if [[ -z ${files} ]]; then
+#    echo "getting public ip" >> $LOG
+#    for i in {1..$RETRY_COUNT}
+#    do
+#      rm -f ./public-ipv4
+#      wget http://169.254.169.254/latest/meta-data/public-ipv4
+#      files="`cat public-ipv4`"
+#      if [ -z $files ]; then
+#          echo "Public ip is not yet assigned. Wait and continue for $i the time ..." >> $LOG
+#          sleep $SLEEP_DURATION
+#      else
+#          echo "Public ip assigned" >> $LOG
+          #crontab -r
+#          break
+#      fi
+#    done
+
+#    if [ -z $files ]; then
+#      echo "Public ip is not yet assigned. So shutdown the instance and exit" >> $LOG
+#      /sbin/poweroff
+#      exit 0
+#    fi
+#    for x in $files
+#    do
+#        PUBLIC_IP="$x"
+#    done
+
+
+#else 
+#   PUBLIC_IP="$files"
+   #crontab -r
+#fi
+PUBLIC_IP=`ifconfig | awk -F':' '/inet addr/&&!/127.0.0.1/{split($2,_," ");print _[1]}'`
+
+for i in `/usr/bin/ruby /opt/get-launch-params.rb`
+do
+    export ${i}
+done
+
+#PORTS=HTTP:8280:80|HTTPS:8243:443
+#MYSQL_HOST
+#MYSQL_USER
+#MYSQL_PASSWORD
+echo "Logging sys variables .. PUBLIC_IP:${PUBLIC_IP}, HOST_NAME:${HOST_NAME}, KEY:${KEY}, PORTS=${PORTS} , BAM:${BAM_IP}, GITREPO:${GIT_REPO}" >> $LOG
+
+
+echo "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:agen=\"http://agent.cartridge.carbon.wso2.org\">
+  <soapenv:Header/>
+  <soapenv:Body>
+     <agen:register>
+        <registrant> 
+           <alarmingLowerRate>${ALARMING_LOWER_RATE}</alarmingLowerRate>
+           <alarmingUpperRate>${ALARMING_UPPER_RATE}</alarmingUpperRate>
+           <hostName>${HOST_NAME}</hostName>
+           <key>${KEY}</key>
+          <maxInstanceCount>${MAX}</maxInstanceCount>
+	  <maxRequestsPerSecond>${MAX_REQUESTS_PER_SEC}</maxRequestsPerSecond>
+          <minInstanceCount>${MIN}</minInstanceCount> " > /etc/agent/conf/request.xml
+
+IFS='|' read -ra PT <<< "${PORTS}"
+for i in "${PT[@]}"; do
+IFS=':' read -ra PP <<< "$i"
+echo "          <portMappings>
+                        <primaryPort>${PP[1]}</primaryPort>
+                        <proxyPort>${PP[2]}</proxyPort>
+                        <type>${PP[0]}</type>
+                </portMappings>">> /etc/agent/conf/request.xml
+done
+
+echo "          <remoteHost>${PUBLIC_IP}</remoteHost>
+           <service>${SERVICE}</service>
+	   <remoteHost>${PUBLIC_IP}</remoteHost>
+           <roundsToAverage>${ROUNDS_TO_AVERAGE}</roundsToAverage>
+           <scaleDownFactor>${SCALE_DOWN_FACTOR}</scaleDownFactor>
+           <tenantRange>${TENANT_RANGE}</tenantRange>
+        </registrant>
+     </agen:register>
+  </soapenv:Body>
+</soapenv:Envelope>
+" >> /etc/agent/conf/request.xml
+
+
+echo "Sending register request to Cartridge agent service" >> $LOG
+
+curl -X POST -H "Content-Type: text/xml" -d @/etc/agent/conf/request.xml --silent --output /dev/null "$CARTRIDGE_AGENT_EPR"
+
+# ========================== // End of script ===========================================================

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/04acd7eb/tools/cartridge_create/init_scripts/mysql/wso2.pem
----------------------------------------------------------------------
diff --git a/tools/cartridge_create/init_scripts/mysql/wso2.pem b/tools/cartridge_create/init_scripts/mysql/wso2.pem
new file mode 100644
index 0000000..abd2985
--- /dev/null
+++ b/tools/cartridge_create/init_scripts/mysql/wso2.pem
@@ -0,0 +1,16 @@
+-----BEGIN RSA PRIVATE KEY-----
+MIICXQIBAAKBgQDUExvnBa8QbdRPsyZFppsuO9pVG4Ve6cuo7cf4oXUiqnt5aYtC
+2h+1NoGwpxTyeqnMTw1UvyrGme3r/gwYBhtEwiSsXFTcPVqyA30wq1Gp+ghnj5NR
+sGEl4dVQYGl/+KbRDQQFmx6K31LAXc+EUrvUjCtXjuH5LrhRGgdIW44EeQIDAQAB
+AoGAMsJYHVVo71+6P1E7ydP0tH4y5cfuhicjTc2L3WCXrrJrV0YBxQB8Ml1XcTas
+dtURKwuIv036KQrSvXdS4bUkdULiDAfkx8I4IRK1TnT0SCHtoO/lOu3NweKI3QeW
+9DX8sdRZ1xOdarmLydJkyk/kLE8v8VbfPaxgxM8KiIMtwtkCQQD2sWf8+/FEOcW7
+11omtKAqIJW+mnARfSMUJspJgvVo+dQbQwdYhgH5z93Y5bH7bUmHZWNsnFYqcPOw
+Ns24QGtjAkEA3BNaqrvba4DEaX1o8Hp8o2NAindAjiKF0WP61l7TNCtgFt8hOiJF
+vTl0MOtPxIOlXrn/pIf0GiQHRykrt7tNcwJBAOd4fL820yIWJz/iiDdrIiGFI5yN
+onv2c9SztPkXBRgz2l6eHSVl0DLLZTjgBYmJ+QUvEARYCM2X4D/GnG63G0sCQEDF
+7YSc3/rnHmgSAkXtNyv7tW5LpRNwc8RqUdSweic7sP9qUuRCXBZSh7EyQPsM6CpW
+QjjRzvW2rvGx220rUqMCQQCiFgDaJvTl7iB9/G/Mzj8xIpABzcwq4AmneR2gEBxf
+38YHLAADdUymlG1hbs2J+yT6Tb5YGFFhDHdOTQ4FOAjl
+-----END RSA PRIVATE KEY-----
+

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/04acd7eb/tools/cartridge_create/init_scripts/php/cartridge_data_publisher_1.0.2.zip
----------------------------------------------------------------------
diff --git a/tools/cartridge_create/init_scripts/php/cartridge_data_publisher_1.0.2.zip b/tools/cartridge_create/init_scripts/php/cartridge_data_publisher_1.0.2.zip
new file mode 100644
index 0000000..08d8b1d
Binary files /dev/null and b/tools/cartridge_create/init_scripts/php/cartridge_data_publisher_1.0.2.zip differ

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/04acd7eb/tools/cartridge_create/init_scripts/php/default
----------------------------------------------------------------------
diff --git a/tools/cartridge_create/init_scripts/php/default b/tools/cartridge_create/init_scripts/php/default
new file mode 100644
index 0000000..6ae5f0f
--- /dev/null
+++ b/tools/cartridge_create/init_scripts/php/default
@@ -0,0 +1,42 @@
+<VirtualHost *:80>
+	ServerAdmin webmaster@localhost
+
+	DocumentRoot /var/www/www
+	Alias /simplesaml /var/www/simplesamlphp/www
+	<Directory />
+		Options FollowSymLinks
+		AllowOverride All
+	</Directory>
+	<Directory /var/www/>
+		Options Indexes FollowSymLinks MultiViews
+		AllowOverride All
+		Order allow,deny
+		allow from all
+	</Directory>
+
+	ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
+	<Directory "/usr/lib/cgi-bin">
+		AllowOverride None
+		Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
+		Order allow,deny
+		Allow from all
+	</Directory>
+
+	ErrorLog ${APACHE_LOG_DIR}/error.log
+
+	# Possible values include: debug, info, notice, warn, error, crit,
+	# alert, emerg.
+	LogLevel warn
+
+	CustomLog ${APACHE_LOG_DIR}/access.log combined
+
+    Alias /doc/ "/usr/share/doc/"
+    <Directory "/usr/share/doc/">
+        Options Indexes MultiViews FollowSymLinks
+        AllowOverride None
+        Order deny,allow
+        Deny from all
+        Allow from 127.0.0.0/255.0.0.0 ::1/128
+    </Directory>
+
+</VirtualHost>