Permalink
Browse files

adding app director scripts

  • Loading branch information...
1 parent 2b372fc commit 384c4abcdb2371506f10fc6f45defa16c1e9202d @alexmacouchbase committed Aug 3, 2012
Showing with 167 additions and 0 deletions.
  1. +65 −0 cb-configure.sh
  2. +102 −0 cb-install.sh
View
@@ -0,0 +1,65 @@
+#!/bin/sh
+
+
+export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/vmware/bin:/opt/vmware/bin:/root/bin:$PATH
+
+echo "Port ${ssh_port}" >> /etc/ssh/sshd_config
+/etc/init.d/sshd restart
+
+if [ ${node_array_index} -eq 0 ]
+then
+echo "I am node ${node_array_index} - running through configuration"
+ sleep 60
+ if [ "${console_password}" = "" ]
+ then
+ password="couchbase123"
+ else
+ password="${console_password}"
+ fi
+
+ # bucket_name
+ # bucket_type
+ # replica_count
+ # couchbase_port
+
+ cli="/opt/couchbase/bin/couchbase-cli"
+ memory_bytes=`cat /proc/meminfo |grep -i memtotal |awk '{print $2;}'`
+ memory_mb=`echo "scale=4; ${memory_bytes}/1024" | bc`
+ memory_allocation=`echo "scale=4; ${memory_mb}*.79" | bc|cut -d . -f1`
+ local_ip="`ifconfig|grep -A 1 eth0|grep inet|cut -d ':' -f2|cut -d ' ' -f1`"
+ echo "Memory bytes: ${memory_bytes}"
+ echo "Memory MB: ${memory_mb}"
+ echo "Memory Allocation: ${memory_allocation}"
+ echo "Local IP: ${local_ip}"
+
+ echo "Setting cluster ramsize to: ${memory_allocation}"
+ ${cli} cluster-init -u Administrator -p ${password} -c localhost:8091 --cluster-init-username=Administrator --cluster-init-password=${password} --cluster-init-port=8091 --cluster-init-ramsize=${memory_allocation}
+
+ echo "Creating bucket: ${bucket}"
+ ${cli} bucket-create -u Administrator -p ${password} -c localhost:8091 --bucket=${bucket_name} --bucket-type=${bucket_type} --bucket-ramsize=${memory_allocation} --bucket-replica=${replica_count}
+
+
+ echo "Adding nodes to cluster..."
+ for ip in ${cluster_ips[@]}
+ do
+ if [ "$ip" != "${local_ip}" ]
+ then
+ echo "Adding ${ip} to cluster list"
+ ${cli} server-add -u Administrator -p ${password} -c localhost:8091 --server-add=${ip}:8091
+ else
+ echo "Skpping add of ${ip} to cluster"
+ fi
+ done
+
+ echo "Server list:"
+ ${cli} server-list -u Administrator -p ${password} -c localhost:8091
+
+ echo "Rebalancing cluster..."
+ ${cli} rebalance -u Administrator -p ${password} -c localhost:8091
+
+ echo "Changing cluster to listen on port ${couchbase_port}..."
+ ${cli} cluster-init -u Administrator -p ${password} -c localhost:8091 --cluster-init-port=${couchbase_port}
+
+else
+ echo "Skipping configure since I am node: ${node_array_index}"
+fi
View
@@ -0,0 +1,102 @@
+#!/bin/sh
+
+date
+export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/vmware/bin:/opt/vmware/bin:/root/bin:$PATH
+
+cb_package_url="http://packages.couchbase.com/releases/1.8.1/couchbase-server-enterprise_x86_64_1.8.1.rpm"
+cb_package="couchbase-server-enterprise_x86_64_1.8.1.rpm"
+if [ "${ssh_password}" = "" ]
+then
+ password="couchbase123"
+else
+ password="${ssh_password}"
+fi
+arch=".x86_64"
+user="cb"
+
+
+echo "Checking for packages"
+rpm -qa|grep -i curl
+if [ $? -ne 0 ]
+then
+ echo "Package curl not installed - installing...."
+ yum -y install curl${arch}
+ if [ $? -ne 0 ]
+ then
+ echo "Package curl not installed and install of curl${arch} failed"
+ exit 1
+ fi
+fi
+
+rpm -qa|grep -i openssl
+if [ $? -ne 0 ]
+then
+ echo "Package openssql not installed - installing...."
+ yum -y install openssl${arch}
+ if [ $? -ne 0 ]
+ then
+ echo "Package openssl not installed and install of openssl${arch} failed"
+ exit 1
+ fi
+fi
+
+rpm -qa|grep -i shadow-utils
+if [ $? -ne 0 ]
+then
+ echo "Package shadow-utils not installed - installing...."
+ yum -y install shadow-utils${arch}
+ if [ $? -ne 0 ]
+ then
+ echo "Package shadow-utils not installed and install of shadow-utils${arch} failed"
+ exit 1
+ fi
+fi
+
+
+yum -y install bc${arch}
+if [$? -ne 0 ]
+then
+ echo "Package bc install failed"
+ exit 1
+fi
+
+echo "Downloading Couchbase package..."
+curl -On ${cb_package_url}
+if [ $? -ne 0 ]
+then
+ echo "Error downloading: ${cb_package_url}"
+ exit 1
+fi
+
+rpm -Uvh ${cb_package}
+if [ $? -ne 0 ]
+then
+ echo "RPM install of ${cb_package} failed"
+ exit 1
+fi
+
+echo "Setting up password hash with openssl..."
+user_pass="`openssl passwd -crypt ${password}`"
+if [ $? -ne 0 ]
+then
+ echo "Password hashing for ${user} with openssl failed"
+ exit 1
+fi
+
+echo "Creating User with..."
+useradd ${user} --password ${user_pass}
+if [ $? -ne 0 ]
+then
+ echo "Could not add user ${user}"
+ exit 1
+fi
+
+echo "Adding User to sudoers..."
+echo "${user} ALL=(ALL) ALL" >> /etc/sudoers
+if [ $? -ne 0 ]
+then
+ echo "Could not add user ${user} to sudoers list"
+ exit 1
+fi
+
+date

0 comments on commit 384c4ab

Please sign in to comment.