make install script to catch up more typo error

Change-Id: I4a45befe6c7f2d3205d70380b08d3881194f15a6
This commit is contained in:
xiaodongwang 2014-04-10 14:40:41 -07:00
parent 80f11cbf98
commit 99364d98f0
8 changed files with 248 additions and 167 deletions

View File

@ -6,15 +6,7 @@ sudo mkdir -p /root/backup/chef
sudo rpm -q chef-server
if [[ "$?" != "0" ]]; then
if [[ ! -e /tmp/chef-server-11.0.8-1.el6.${IMAGE_ARCH}.rpm ]]; then
sudo rpm -Uvh $CHEF_SRV
else
sudo rpm -Uvh /tmp/chef-server-11.0.8-1.el6.${IMAGE_ARCH}.rpm
fi
if [[ "$?" != "0" ]]; then
echo "failed to rpm install $CHEF_SRV"
exit 1
fi
download $CHEF_SRV chef-server install
else
echo "chef-server has already installed"
fi
@ -33,17 +25,29 @@ if [[ "$?" != "0" ]]; then
exit 1
fi
sudo mkdir -p /var/chef/cookbooks/
sudo cp -r $ADAPTERS_HOME/chef/cookbooks/* /var/chef/cookbooks/
if [ $? -ne 0 ]; then
echo "failed to copy cookbooks to /var/chef/cookbooks/"
exit 1
fi
sudo mkdir -p /var/chef/databags/
sudo cp -r $ADAPTERS_HOME/chef/databags/* /var/chef/databags/
if [ $? -ne 0 ]; then
echo "failed to copy databags to /var/chef/databags/"
exit 1
fi
sudo mkdir -p /var/chef/roles/
sudo cp -r $ADAPTERS_HOME/chef/roles/* /var/chef/roles/
if [ $? -ne 0 ]; then
echo "failed to copy roles to /var/chef/roles/"
exit 1
fi
# configure chef client and knife
rpm -q chef
if [[ "$?" != "0" ]]; then
download http://opscode-omnibus-packages.s3.amazonaws.com/el/${IMAGE_VERSION_MAJOR}/${IMAGE_ARCH}/chef-11.8.0-1.el6.${IMAGE_ARCH}.rpm
rpm -ivh /tmp/chef-11.8.0-1.el6.${IMAGE_ARCH}.rpm
if [[ "$?" != "0" ]]; then
echo "chef install failed"
exit 1
else
echo "chef is installed"
fi
download $CHEF_CLIENT chef-client install
else
echo "chef has already installed"
fi

View File

@ -32,7 +32,7 @@ sudo sed -i '/SELINUX/s/enforcing/disabled/' /etc/selinux/config
# update cobbler settings
sudo cp -rn /etc/cobbler/settings /root/backup/cobbler/
sudo rm -f /etc/cobbler/settings
sudo cp -rf $ADAPTER_HOME/cobbler/conf/settings /etc/cobbler/settings
sudo cp -rf $ADAPTERS_HOME/cobbler/conf/settings /etc/cobbler/settings
sudo sed -i "s/next_server:[ \t]*\$next_server/next_server: $NEXTSERVER/g" /etc/cobbler/settings
sudo sed -i "s/server:[ \t]*\$ipaddr/server: $ipaddr/g" /etc/cobbler/settings
sudo sed -i "s/default_name_servers:[ \t]*\['\$ipaddr'\]/default_name_servers: \['$ipaddr'\]/g" /etc/cobbler/settings
@ -45,26 +45,26 @@ sudo chmod 644 /etc/cobbler/settings
# update dhcp.template
sudo cp -rn /etc/cobbler/dhcp.template /root/backup/cobbler/
sudo rm -f /etc/cobbler/dhcp.template
sudo cp -rf $ADAPTER_HOME/cobbler/conf/dhcp.template /etc/cobbler/dhcp.template
sudo cp -rf $ADAPTERS_HOME/cobbler/conf/dhcp.template /etc/cobbler/dhcp.template
subnet=$(ipcalc $SUBNET -n |cut -f 2 -d '=')
sudo sed -i "s/subnet \$subnet netmask \$netmask/subnet $subnet netmask $netmask/g" /etc/cobbler/dhcp.template
sudo sed -i "s/option routers \$gateway/option routers $OPTION_ROUTER/g" /etc/cobbler/dhcp.template
sudo sed -i "s/option subnet-mask \$netmask/option subnet-mask $netmask/g" /etc/cobbler/dhcp.template
sudo sed -i "s/option domain-name-servers \$ipaddr/option domain-name-servers $ipaddr/g" /etc/cobbler/dhcp.template
sudo sed -i "s/range dynamic-bootp \$ip_range/range dynamic-bootp $IP_RANGE/g" /etc/cobbler/dhcp.template
sudo sed -i "s/range dynamic-bootp \$ip_range/range dynamic-bootp $IP_START $IP_END/g" /etc/cobbler/dhcp.template
sudo sed -i "s/local-address \$ipaddr/local-address $ipaddr/g" /etc/cobbler/dhcp.template
sudo chmod 644 /etc/cobbler/dhcp.template
# update tftpd.template
sudo cp -rn /etc/cobbler/tftpd.template /root/backup/cobbler/
sudo rm -f /etc/cobbler/tftpd.template
sudo cp -rf $ADAPTER_HOME/cobbler/conf/tftpd.template /etc/cobbler/tftpd.template
sudo cp -rf $ADAPTERS_HOME/cobbler/conf/tftpd.template /etc/cobbler/tftpd.template
sudo chmod 644 /etc/cobbler/tftpd.template
# update named.template
sudo cp -rn /etc/cobbler/named.template /root/backup/cobbler/
sudo rm -f /etc/cobbler/named.template
sudo cp -rf $ADAPTER_HOME/cobbler/conf/named.template /etc/cobbler/named.template
sudo cp -rf $ADAPTERS_HOME/cobbler/conf/named.template /etc/cobbler/named.template
sudo sed -i "s/listen-on port 53 { \$ipaddr; }/listen-on port 53 \{ $ipaddr; \}/g" /etc/cobbler/named.template
subnet_escaped=$(echo $SUBNET | sed -e 's/[\/&]/\\&/g')
sudo sed -i "s/allow-query { 127.0.0.0\/8; \$subnet; }/allow-query \{ 127.0.0.0\/8; $subnet_escaped; \}/g" /etc/cobbler/named.template
@ -73,14 +73,14 @@ sudo chmod 644 /etc/cobbler/named.template
# update zone.template
sudo cp -rn /etc/cobbler/zone.template /root/backup/cobbler/
sudo rm -f /etc/cobbler/zone.template
sudo cp -rf $ADAPTER_HOME/cobbler/conf/zone.template /etc/cobbler/zone.template
sudo cp -rf $ADAPTERS_HOME/cobbler/conf/zone.template /etc/cobbler/zone.template
sudo sed -i "s/\$hostname IN A \$ipaddr/$HOSTNAME IN A $ipaddr/g" /etc/cobbler/zone.template
sudo chmod 644 /etc/cobbler/zone.template
# update modules.conf
sudo cp -rn /etc/cobbler/modules.conf /root/backup/cobbler/
sudo rm -f /etc/cobbler/modules.conf
sudo cp -rf $ADAPTER_HOME/cobbler/conf/modules.conf /etc/cobbler/modules.conf
sudo cp -rf $ADAPTERS_HOME/cobbler/conf/modules.conf /etc/cobbler/modules.conf
sudo chmod 644 /etc/cobbler/modules.conf
echo "setting up cobbler web password: default user is cobbler"
@ -94,18 +94,19 @@ sudo cp -rn /var/lib/cobbler/snippets /root/backup/cobbler/
sudo cp -rn /var/lib/cobbler/kickstarts/ /root/backup/cobbler/
sudo cp -rn /var/lib/cobbler/triggers /root/backup/cobbler/
sudo rm -rf /var/lib/cobbler/snippets/*
sudo cp -rf $ADAPTER_HOME/cobbler/snippets/* /var/lib/cobbler/snippets/
sudo cp -rf $ADAPTER_HOME/cobbler/triggers/* /var/lib/cobbler/triggers/
sudo cp -rf $ADAPTERS_HOME/cobbler/snippets/* /var/lib/cobbler/snippets/
sudo cp -rf $HOME/.ssh/id_rsa.pub /var/lib/cobbler/snippets/
sudo cp -rf $ADAPTERS_HOME/cobbler/triggers/* /var/lib/cobbler/triggers/
sudo chmod 777 /var/lib/cobbler/snippets
sudo chmod -R 666 /var/lib/cobbler/snippets/*
sudo chmod -R 755 /var/lib/cobbler/triggers
sudo sed -i "s/# \$compass_ip \$compass_hostname/$ipaddr $HOSTNAME/g" /var/lib/cobbler/snippets/hosts
sudo rm -f /var/lib/cobbler/kickstarts/default.ks
sudo cp -rf $ADAPTER_HOME/cobbler/kickstarts/default.ks /var/lib/cobbler/kickstarts/
sudo cp -rf $ADAPTERS_HOME/cobbler/kickstarts/default.ks /var/lib/cobbler/kickstarts/
sudo chmod 666 /var/lib/cobbler/kickstarts/default.ks
sudo mkdir /var/www/cblr_ks
sudo chmod 755 /var/www/cblr_ks
sudo cp -rf $ADAPTER_HOME/cobbler/conf/cobbler.conf /etc/httpd/conf.d/
sudo cp -rf $ADAPTERS_HOME/cobbler/conf/cobbler.conf /etc/httpd/conf.d/
chmod 644 /etc/httpd/conf.d/cobbler.conf
sudo cp -rn /etc/xinetd.d /root/backup/
@ -205,8 +206,7 @@ ppa_repo_packages="ntp-4.2.6p5-1.el6.${IMAGE_TYPE,,}.$IMAGE_ARCH.rpm
ntpdate-4.2.6p5-1.el6.${IMAGE_TYPE,,}.${IMAGE_ARCH}.rpm"
for f in $ppa_repo_packages
do
download ftp://rpmfind.net/linux/${IMAGE_TYPE,,}/${IMAGE_VERSION_MAJOR}/os/${IMAGE_ARCH}/Packages/$f $f
sudo cp /tmp/$f /var/lib/cobbler/repo_mirror/ppa_repo/
download ftp://rpmfind.net/linux/${IMAGE_TYPE,,}/${IMAGE_VERSION_MAJOR}/os/${IMAGE_ARCH}/Packages/$f $f copy /var/lib/cobbler/repo_mirror/ppa_repo/
done
ppa_repo_rsyslog_packages="json-c-0.10-2.el6.$IMAGE_ARCH.rpm
@ -216,13 +216,11 @@ ppa_repo_rsyslog_packages="json-c-0.10-2.el6.$IMAGE_ARCH.rpm
rsyslog-7.6.3-1.el6.$IMAGE_ARCH.rpm"
for f in $ppa_repo_rsyslog_packages
do
download http://rpms.adiscon.com/v7-stable/epel-6/${IMAGE_ARCH}/RPMS/$f $f
sudo cp /tmp/$f /var/lib/cobbler/repo_mirror/ppa_repo/
download http://rpms.adiscon.com/v7-stable/epel-6/${IMAGE_ARCH}/RPMS/$f $f copy /var/lib/cobbler/repo_mirror/ppa_repo/
done
# download chef client for ppa repo
download http://opscode-omnibus-packages.s3.amazonaws.com/el/${IMAGE_VERSION_MAJOR}/${IMAGE_ARCH}/chef-11.8.0-1.el6.${IMAGE_ARCH}.rpm
sudo cp /tmp/chef-11.8.0-1.el6.${IMAGE_ARCH}.rpm /var/lib/cobbler/repo_mirror/ppa_repo/
download $CHEF_CLIENT `basename $CHEF_CLIENT` copy /var/lib/cobbler/repo_mirror/ppa_repo/
cd ..
sudo createrepo ppa_repo
if [[ "$?" != "0" ]]; then
@ -236,8 +234,7 @@ sudo cobbler reposync
# import cobbler distro
sudo mkdir -p /var/lib/cobbler/iso
download "$IMAGE_SOURCE" ${IMAGE_NAME}-${IMAGE_ARCH}.iso
sudo cp /tmp/${IMAGE_NAME}-${IMAGE_ARCH}.iso /var/lib/cobbler/iso/
download "$IMAGE_SOURCE" ${IMAGE_NAME}-${IMAGE_ARCH}.iso copy /var/lib/cobbler/iso/
sudo mkdir -p /mnt/${IMAGE_NAME}-${IMAGE_ARCH}
if [ $(mount | grep -c "/mnt/${IMAGE_NAME}-${IMAGE_ARCH} ") -eq 0 ]; then
sudo mount -o loop /var/lib/cobbler/iso/${IMAGE_NAME}-${IMAGE_ARCH}.iso /mnt/${IMAGE_NAME}-${IMAGE_ARCH}

View File

@ -46,13 +46,6 @@ sudo sed -i "s/\$compass_ip/$ipaddr/g" /etc/compass/global_config
sudo sed -i "s/\$compass_hostname/$HOSTNAME/g" /etc/compass/global_config
# add cookbooks, databags and roles
sudo mkdir -p /var/chef/cookbooks/
sudo mkdir -p /var/chef/databags/
sudo mkdir -p /var/chef/roles/
sudo cp -r $ADAPTER_HOME/chef/cookbooks/* /var/chef/cookbooks/
sudo cp -r $ADAPTER_HOME/chef/databags/* /var/chef/databags/
sudo cp -r $ADAPTER_HOME/chef/roles/* /var/chef/roles/
sudo chmod +x /opt/compass/bin/addcookbooks.py
sudo chmod +x /opt/compass/bin/adddatabags.py
sudo chmod +x /opt/compass/bin/addroles.py

View File

@ -1,16 +1,22 @@
#!/bin/bash
echo 'Installing Required packages for Compass...'
sudo yum update -y
if [ "$tempest" == "true" ]; then
sudo yum install -y virt-install libvirt qemu-kvm libxml2-devel libxslt-devel python-devel sshpass openssl-devel
fi
sudo yum install -y rsyslog logrotate ntp iproute openssh-clients python git wget python-setuptools python-netaddr python-flask python-flask-sqlalchemy python-amqplib amqp python-paramiko python-mock mod_wsgi httpd squid dhcp bind rsync yum-utils xinetd tftp-server gcc net-snmp-utils net-snmp net-snmp-python python-daemon unzip openssl openssl098e ca-certificates redis python-redis
sudo yum install -y rsyslog logrotate ntp iproute openssh-clients python python-devel git wget python-setuptools python-netaddr python-flask python-flask-sqlalchemy python-amqplib amqp python-paramiko python-mock mod_wsgi httpd squid dhcp bind rsync yum-utils xinetd tftp-server gcc net-snmp-utils net-snmp net-snmp-python python-daemon unzip openssl openssl098e ca-certificates redis python-redis
if [[ "$?" != "0" ]]; then
echo "failed to install yum dependency"
exit 1
fi
sudo easy_install pip==1.5.1
# https need the system time is correct.
sudo service ntpd stop
ntpdate 0.centos.pool.ntp.org
sudo service ntpd start
sudo easy_install --upgrade pip==1.5.1
if [[ "$?" != "0" ]]; then
echo "failed to install easy install"
exit 1

View File

@ -17,7 +17,8 @@ export SUBNET=${SUBNET:-}
# DHCP option router address(Default is your management interface IP address )"
export OPTION_ROUTER=${OPTION_ROUTER:-}
# The IP range for DHCP clients (Default: local subnet start from 100 to 254)
export IP_RANGE=${IP_RANGE:-}
export IP_START=${IP_START:-}
export IP_END=${IP_END:-}
# TFTP server's IP address(Default: Management Interface/eth0 IP)
export NEXTSERVER=${NEXTSERVER:-}
@ -42,14 +43,16 @@ export JS_MVC=${JS_MVC:-"javascriptmvc-3.2.4"}
# set the chef packages download path
export CHEF_SRV=${CHEF_SRV:-"http://opscode-omnibus-packages.s3.amazonaws.com/el/${IMAGE_VERSION_MAJOR}/${IMAGE_ARCH}/chef-server-11.0.8-1.el6.${IMAGE_ARCH}.rpm"}
export CHEF_CLIENT=${CHEF_CLIENT:="http://opscode-omnibus-packages.s3.amazonaws.com/el/${IMAGE_VERSION_MAJOR}/${IMAGE_ARCH}/chef-11.8.0-1.el6.${IMAGE_ARCH}.rpm"}
# Set Chef password for Chef web UI
export CHEF_PASSWD=${CHEF_PASSWD:-"root1234"}
# Set Compass-web and Compass-adpater variables
export WEB_HOME=${WEB_HOME:='/tmp/web'}
export ADAPTER_HOME=${ADAPTER_HOME:-'/tmp/adapter'}
export ADAPTERS_HOME=${ADAPTERS_HOME:-'/tmp/adapter'}
export WEB_SOURCE=${WEB_SOURCE:-}
export ADAPTER_SOURCE=${ADAPTER_SOURCE:-}
export ADAPTERS_SOURCE=${ADAPTERS_SOURCE:-}
export WEB_GERRIT_URL=${WEB_GERRIT_URL:-}
export ADAPTERS_GERRIT_URL=${ADAPTERS_GERRIT_URL:-}
export SCRIPT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
export COMPASSDIR=${SCRIPT_DIR}/..

View File

@ -15,20 +15,23 @@ export NIC=installation
# DHCP config
# SUBNET variable specifies the subnet for DHCP server. Example: 192.168.0.0/16
export netmask=$(ifconfig $NIC |grep Mask | cut -f 4 -d ':')
export ipaddr=`ifconfig $NIC | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}'`
export ipnet=$(ip address| grep "global $NIC" |cut -f 6 -d ' ')
export SUBNET=$(ipcalc $ipnet -n |cut -f 2 -d '=')/$(ipcalc $ipnet -p |cut -f 2 -d '=')
export SUBNET=$(ipcalc $ipaddr $netmask -n |cut -f 2 -d '=')/$(ipcalc $ipaddr $netmask -p |cut -f 2 -d '=')
# DHCP option router address(Default is your management interface IP address )"
export OPTION_ROUTER=`ifconfig $NIC | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}'`
# The IP range for DHCP clients (Default: local subnet start from 100 to 254)
export ip_start=`echo $ipaddr |cut -d. -f'1 2 3'`.128
export ip_end=`echo $ipaddr |cut -d. -f'1 2 3'`.254
export IP_RANGE="$ip_start $ip_end"
export IP_START=`echo $ipaddr |cut -d. -f'1 2 3'`.128
export IP_END=`echo $ipaddr |cut -d. -f'1 2 3'`.254
# TFTP server's IP address(Default: Management Interface/eth0 IP)
export NEXTSERVER=`ifconfig $NIC | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}'`
# the domains covered by nameserver
export NAMESERVER_DOMAINS=ods.com
# the repo url
export WEB_SOURCE='http://git.openstack.org/stackforge'/compass-web
export ADAPTERS_SOURCE='http://git.openstack.org/stackforge/compass-adapters'
export WEB_GERRIT_URL='https://review.openstack.org/stackforge/compass-web'
export ADAPTERS_GERRIT_URL='https://review.openstack.org/stackforge/compass-adapters'
# set the default cobbler user "cobbler" password, if not set, the default will be cobbler/cobbler
export CBLR_USER=cobbler
export CBLR_PASSWD=cobbler
@ -54,10 +57,8 @@ export CHEF_SRV=http://opscode-omnibus-packages.s3.amazonaws.com/el/6/x86_64/che
export CHEF_PASSWD=root1234
# Set Compass-web and Compass-adpater variables
export WEB_HOME=${WEB_HOME:='/tmp/web'}
export ADAPTER_HOME=${ADAPTER_HOME:-'/tmp/adapter'}
export WEB_SOURCE=${WEB_SOURCE:-'compass-web'}
export ADAPTER_SOURCE=${ADAPTER_SOURCE:-'compass-adapters'}
export WEB_HOME=${WEB_HOME:-'/tmp/web'}
export ADAPTERS_HOME=${ADAPTERS_HOME:-'/tmp/adapter'}
export SCRIPT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
export COMPASSDIR=${SCRIPT_DIR}/..

View File

@ -63,6 +63,14 @@ while [ $1 ]; do
shift
done
# convert ip address to int
ipaddr_convert()
{
ipaddr=$1
IFS=. read -r a b c d <<< "$ipaddr"
printf '%d\n' "$((a * 256 ** 3 + b * 256 ** 2 + c * 256 + d))"
}
# Load variables
source $DIR/install.conf
loadvars()
@ -79,13 +87,6 @@ loadvars()
export $(echo $1)="$2"
break
else
if [ "$1" == "NIC" ]; then
sudo ip addr |grep $input >& /dev/null
if [ $? -ne 0 ]; then
echo "There is not any IP address assigned to the NIC '$input' yet, please assign an IP address first."
exit 1
fi
fi
echo "You have entered $input"
export $(echo $1)="$input"
break
@ -95,21 +96,87 @@ loadvars()
}
loadvars NIC "eth0"
sudo ifconfig $NIC
if [ $? -ne 0 ]; then
echo "There is no nic '$NIC' yet"
exit 1
fi
sudo ifconfig $NIC | grep 'inet addr:' >& /dev/null
if [ $? -ne 0 ]; then
echo "There is not any IP address assigned to the NIC '$NIC' yet, please assign an IP address first."
exit 1
fi
export netmask=$(ifconfig $NIC |grep Mask | cut -f 4 -d ':')
export ipaddr=$(ifconfig $NIC | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}')
export range=$(echo "$(echo "$ipaddr"|cut -f 1 -d '.').$(echo "$ipaddr"|cut -f 2 -d '.').$(echo "$ipaddr"|cut -f 3 -d '.').100 $(echo "$ipaddr"|cut -f 1 -d '.').$(echo "$ipaddr"|cut -f 2 -d '.').$(echo "$ipaddr"|cut -f 3 -d '.').250")
export ipnet=$(ip address| grep "global $NIC" |cut -f 6 -d ' ')
loadvars SUBNET $(ipcalc $ipnet -n |cut -f 2 -d '=')/$(ipcalc $ipnet -p |cut -f 2 -d '=')
export netaddr=$(ipcalc $ipaddr $netmask -n |cut -f 2 -d '=')
export netprefix=$(ipcalc $ipaddr $netmask -p |cut -f 2 -d '=')
loadvars SUBNET ${netaddr}/${netprefix}
ipcalc $SUBNET -c
if [ $? -ne 0 ]; then
echo "subnet $SUBNET format should be x.x.x.x/x"
exit 1
fi
export netaddr=$(ipcalc $SUBNET -n |cut -f 2 -d '=')
export netprefix=$(ipcalc $SUBNET -p |cut -f 2 -d '=')
export netmask=$(ipcalc $SUBNET -m |cut -f 2 -d '=')
export expected_subnet=${netaddr}/${netprefix}
if [[ "$SUBNET" != "$expected_subnet" ]]; then
echo "expected subnet should be $expected_subnet"
exit 1
fi
loadvars OPTION_ROUTER $(route -n | grep '^0.0.0.0' | xargs | cut -d ' ' -f 2)
loadvars IP_RANGE "$range"
ipcalc $OPTION_ROUTER -c
if [ $? -ne 0 ]; then
echo "router $OPTION_ROUTER format should be x.x.x.x"
exit 1
fi
export ip_start=$(echo "$ipaddr"|cut -f 1,2,3 -d '.')."100"
export ip_end=$(echo "$ipaddr"|cut -f 1,2,3 -d '.')."250"
loadvars IP_START "$ip_start"
ipcalc $IP_START -c
if [ $? -ne 0 ]; then
echo "ip start $IP_START format should be x.x.x.x"
exit 1
fi
ip_start_net=$(ipcalc $IP_START $netmask -n |cut -f 2 -d '=')
if [[ "$ip_start_net" != "$netaddr" ]]; then
echo "ip start $IP_START is not in $SUBNET"
exit 1
fi
loadvars IP_END "$ip_end"
ipcalc $IP_END -c
if [ $? -ne 0 ]; then
echo "ip end $IP_END format should be x.x.x.x"
exit 1
fi
ip_end_net=$(ipcalc $IP_END $netmask -n |cut -f 2 -d '=')
if [[ "$ip_end_net" != "$netaddr" ]]; then
echo "ip end $IP_END is not in $SUBNET"
exit 1
fi
ip_start_int=$(ipaddr_convert $IP_START)
ip_end_int=$(ipaddr_convert $IP_END)
let ip_range=${ip_end_int}-${ip_start_int}
if [ $ip_range -le 0 ]; then
echo "there is no available ips to assign between $IP_START and $IP_END"
exit 1
fi
echo "there will be at most $ip_range hosts deployed."
loadvars NEXTSERVER $ipaddr
ipcalc $NEXTSERVER -c
if [ $? -ne 0 ]; then
echo "next server $NEXTSERVER format should be x.x.x.x"
exit 1
fi
loadvars NAMESERVER_DOMAINS "ods.com"
if [[ -n $source ]] && [ $source = "local" ];then
loadvars WEB_SOURCE ${COMPASSDIR}/../web
loadvars ADAPTER_SOURCE ${COMPASSDIR}/../misc
else
loadvars WEB_SOURCE $REPO_URL'/stackforge/compass-web'
loadvars ADAPTER_SOURCE $REPO_URL'/stackforge/compass-adapters'
loadvars WEB_SOURCE 'http://git.openstack.org/stackforge/compass-web'
if [[ "$WEB_SOURCE" =~ https?:// ]]; then
loadvars WEB_GERRIT_URL 'https://review.openstack.org/stackforge/compass-web'
fi
loadvars ADAPTERS_SOURCE 'http://git.openstack.org/stackforge/compass-adapters'
if [[ "$ADAPTERS_SOURCE" =~ https?:// ]]; then
loadvars ADAPTERS_GERRIT_URL 'https://review.openstack.org/stackforge/compass-adapters'
fi
echo "script dir: $SCRIPT_DIR"

View File

@ -1,53 +1,64 @@
#!/bin/bash
# prepare the installation
copygit2dir()
{
project=$1
destdir=$2
if [ -z "$REPO_URL" ];then
git_repo=http://git.openstack.org/stackforge/$project
gerrit_repo=https://review.openstack.org/stackforge/$project
else
git_repo=$REPO_URL/stackforge/$project
gerrit_repo=$REPO_URL/stackforge/$project
fi
if [ -d $destdir ];then
echo "$destdir exists"
cd $destdir
git remote set-url origin $git_repo
git remote update
git reset --hard
git clean -x -f
git checkout master
git reset --hard remotes/origin/master
if [[ -n "$GERRIT_REFSPEC" ]];then
git fetch $gerrit_repo $GERRIT_REFSPEC && git checkout FETCH_HEAD
fi
git clean -x -f
else
echo "create $destdir"
mkdir -p $destdir
git clone $git_repo $destdir
if [[ -n "$GERRIT_REFSPEC" ]];then
# project=$(echo $repo|rev|cut -d '/' -f 1|rev)
cd $destdir
git fetch $gerrit_repo $GERRIT_REFSPEC && git checkout FETCH_HEAD
fi
fi
cd $SCRIPT_DIR
}
copylocal2dir()
copy2dir()
{
repo=$1
destdir=$2
if [ -d $destdir ];then
echo "$destdir exists"
if [[ "$repo" =~ (git|http|https|ftp):// ]]; then
if [[ -d $destdir || -L $destdir ]]; then
cd $destdir
git status &> /dev/null
if [ $? -ne 0 ]; then
echo "$destdir is not git repo"
rm -rf $destdir
fi
cd -
fi
if [[ -d $destdir || -L $destdir ]]; then
echo "$destdir exists"
cd $destdir
git remote set-url origin $repo
git remote update
git reset --hard
git clean -x -f
git checkout master
git reset --hard remotes/origin/master
else
echo "create $destdir"
mkdir -p $destdir
git clone $repo $destdir
if [ $? -ne 0 ]; then
echo "failed to git clone $repo $destdir"
exit 1
fi
cd $destdir
fi
gerrit_repo=$3
if [ -z $gerrit_repo ]; then
if [[ -n "$GERRIT_REFSPEC" ]];then
git fetch $gerrit_repo $GERRIT_REFSPEC && git checkout FETCH_HEAD
if [ $? -ne 0 ]; then
echo "failed to git fetch $gerrit_repo $GERRIT_REFSPEC"
exit 1
fi
fi
fi
git clean -x -f
else
mkdir -p $destdir
sudo rm -rf $destdir
sudo cp -rf $repo $destdir
if [ $? -ne 0 ]; then
echo "failed to copy $repo to $destdir"
exit 1
fi
fi
sudo cp -rf $repo/* $destdir
if [[ ! -d $destdir && ! -L $destdir ]]; then
echo "$destdir doest not exist"
exit 1
fi
cd $SCRIPT_DIR
}
# Create backup dir
@ -115,13 +126,16 @@ else
fi
cd $SCRIPT_DIR
if [ "$source" != "local" ]; then
copygit2dir compass-web $WEB_HOME
copygit2dir compass-adapters $ADAPTER_HOME
else
copylocal2dir $WEB_SOURCE $WEB_HOME
copylocal2dir $ADAPTER_SOURCE $ADAPTER_HOME
if [ -z $WEB_SOURCE ]; then
echo "web source $WEB_SOURCE is not set"
exit 1
fi
copy2dir $WEB_SOURCE $WEB_HOME $WEB_GERRIT_URL
if [ -z $ADAPTERS_SOURCE ]; then
echo "adpaters source $ADAPTERS_SOURCE is not set"
exit 1
fi
copy2dir $ADAPTERS_SOURCE $ADAPTERS_HOME $ADAPTERS_GERRIT_URL
if [ "$tempest" == "true" ]; then
if [[ ! -e /tmp/tempest ]]; then
@ -144,58 +158,48 @@ download()
{
url=$1
package=${2:-$(basename $url)}
if [[ -f /tmp/${package} ]]; then
action=${3:-""}
if [[ -f /tmp/${package} || -L /tmp/${package} ]]; then
echo "$package already exists"
else
wget -c --progress=bar:force -O /tmp/${package}.tmp $url
if [[ "$url" =~ (http|https|ftp):// ]]; then
wget -c --progress=bar:force -O /tmp/${package}.tmp $url
if [[ "$?" != "0" ]]; then
echo "failed to download $package"
exit 1
else
echo "successfully download $package"
cp -rf /tmp/${package}.tmp /tmp/${package}
fi
else
cp -rf $url /tmp/${package}
fi
if [[ ! -f /tmp/${package} && ! -L /tmp/${package} ]]; then
echo "/tmp/$package is not created"
exit 1
fi
fi
if [[ "$action" == "install" ]]; then
sudo rpm -Uvh /tmp/$package
if [[ "$?" != "0" ]]; then
echo "failed to download $package"
echo "failed to install $package"
exit 1
else
echo "successfully download $package"
cp -rf /tmp/${package}.tmp /tmp/${package}
echo "$package is installed"
fi
elif [[ "$action" == "copy" ]]; then
destdir=$4
sudo cp /tmp/$package $destdir
elif [[ "$action" == "unzip" ]]; then
unzipped_package=${package%%.zip}
sudo rm -rf /tmp/$unzipped_package
sudo unzip -o /tmp/$package /tmp/
sudo cp -rf /tmp/$unzipped_package/. $destdir
fi
}
# download chef-server package
download $CHEF_SRV
# download centos image
download $IMAGE_SOURCE ${IMAGE_NAME}-${IMAGE_ARCH}.iso
# download ppa_repo packages
ppa_repo_packages="ntp-4.2.6p5-1.el6.${IMAGE_TYPE,,}.$IMAGE_ARCH.rpm
openssh-clients-5.3p1-94.el6.${IMAGE_ARCH}.rpm
iproute-2.6.32-31.el6.${IMAGE_ARCH}.rpm
wget-1.12-1.8.el6.${IMAGE_ARCH}.rpm
ntpdate-4.2.6p5-1.el6.${IMAGE_TYPE,,}.${IMAGE_ARCH}.rpm"
for f in $ppa_repo_packages
do
download ftp://rpmfind.net/linux/${IMAGE_TYPE,,}/${IMAGE_VERSION_MAJOR}/os/${IMAGE_ARCH}/Packages/$f $f
done
ppa_repo_rsyslog_packages="json-c-0.10-2.el6.$IMAGE_ARCH.rpm
libestr-0.1.9-1.el6.$IMAGE_ARCH.rpm
libgt-0.3.11-1.el6.$IMAGE_ARCH.rpm
liblogging-1.0.4-1.el6.$IMAGE_ARCH.rpm
rsyslog-7.6.3-1.el6.$IMAGE_ARCH.rpm"
for f in $ppa_repo_rsyslog_packages
do
download http://rpms.adiscon.com/v7-stable/epel-6/${IMAGE_ARCH}/RPMS/$f $f
done
# download chef client for ppa repo
download http://opscode-omnibus-packages.s3.amazonaws.com/el/${IMAGE_VERSION_MAJOR}/${IMAGE_ARCH}/chef-11.8.0-1.el6.${IMAGE_ARCH}.rpm
# download js mvc
download http://github.com/downloads/bitovi/javascriptmvc/$JS_MVC.zip
if [ -d /tmp/$JS_MVC ]; then
echo "/tmp/$JS_MVC is already unzipped"
else
sudo unzip -o /tmp/$JS_MVC.zip -d /tmp/
fi
sudo cp -rf /tmp/$JS_MVC/. $WEB_HOME/public/
download http://github.com/downloads/bitovi/javascriptmvc/$JS_MVC.zip $JS_MVC.zip unzip $WEB_HOME/public/
# Install net-snmp
sudo cp -rn /etc/snmp/snmp.conf /root/backup/
@ -206,3 +210,9 @@ sudo cp -rf $COMPASSDIR/misc/snmp/snmp.conf /etc/snmp/snmp.conf
sudo chmod 644 /etc/snmp/snmp.conf
sudo mkdir -p /var/lib/net-snmp/mib_indexes
sudo chmod 755 /var/lib/net-snmp/mib_indexes
# generate ssh key
if [ ! -e $HOME/.ssh/id_rsa.pub ]; then
rm -rf $HOME/.ssh/id_rsa
ssh-keygen -t rsa -f $HOME/.ssh/id_rsa -q -N ''
fi