From adfc029a023ccff700fe31e433717b05a3eaefa2 Mon Sep 17 00:00:00 2001 From: Chmouel Boudjnah Date: Mon, 14 Nov 2011 14:24:30 +0100 Subject: [PATCH 1/5] Use lsb_release for distro detection. --- stack.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/stack.sh b/stack.sh index 78851b9..1255ad0 100755 --- a/stack.sh +++ b/stack.sh @@ -22,7 +22,9 @@ # Warn users who aren't on natty, but allow them to override check and attempt # installation with ``FORCE=yes ./stack`` -if ! egrep -q 'natty|oneiric' /etc/lsb-release; then +DISTRO=$(lsb_release -c -s) + +if [[ ! ${DISTRO} =~ (natty|oneiric) ]]; then echo "WARNING: this script has only been tested on natty and oneiric" if [[ "$FORCE" != "yes" ]]; then echo "If you wish to run this script anyway run with FORCE=yes" From a4adff43cb18a26ce2975b6fcdcf1d972a0d9027 Mon Sep 17 00:00:00 2001 From: Chmouel Boudjnah Date: Mon, 14 Nov 2011 15:19:34 +0100 Subject: [PATCH 2/5] Only install dnsmasq-utils on oneiric. --- files/apts/nova | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/files/apts/nova b/files/apts/nova index 9eefed7..31dd86a 100644 --- a/files/apts/nova +++ b/files/apts/nova @@ -1,5 +1,5 @@ dnsmasq-base -dnsmasq-utils # for dhcp_release +dnsmasq-utils # for dhcp_release only available in dist:oneiric kpartx parted arping # used for send_arp_for_ha option in nova-network From 0277d5b91f8ad7763bf32e63d7b6d3c2236fce3c Mon Sep 17 00:00:00 2001 From: Chmouel Boudjnah Date: Mon, 14 Nov 2011 15:20:39 +0100 Subject: [PATCH 3/5] Install packages only for distros/services. - We are installing packages only for the services needed. - We are parsing the packages files and detecting metadatas. - If there is a NOPRIME as comment mean we are not doing the install just yet. - If we have the meta-keyword distro:DISTRO or distro:DISTRO1,DISTRO2 it will be installed only for those distros (case insensitive). --- stack.sh | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 56 insertions(+), 1 deletion(-) diff --git a/stack.sh b/stack.sh index 1255ad0..1043dc6 100755 --- a/stack.sh +++ b/stack.sh @@ -364,10 +364,65 @@ fi # # Openstack uses a fair number of other projects. +# - We are going to install packages only for the services needed. +# - We are parsing the packages files and detecting metadatas. +# - If there is a NOPRIME as comment mean we are not doing the install +# just yet. +# - If we have the meta-keyword distro:DISTRO or +# distro:DISTRO1,DISTRO2 it will be installed only for those +# distros (case insensitive). +function get_packages() { + local file_to_parse="general" + local service + + for service in ${ENABLED_SERVICES//,/ }; do + if [[ $service == n-* ]]; then + if [[ ! $file_to_parse =~ nova ]];then + file_to_parse="${file_to_parse} nova" + fi + elif [[ $service == g-* ]];then + if [[ ! $file_to_parse =~ glance ]];then + file_to_parse="${file_to_parse} glance" + fi + elif [[ $service == key* ]];then + if [[ ! $file_to_parse =~ keystone ]];then + file_to_parse="${file_to_parse} keystone" + fi + elif [[ -e $FILES/apts/${service} ]];then + file_to_parse="${file_to_parse} $service" + fi + done + + for file in ${file_to_parse};do + local fname=${FILES}/apts/${file} + local OIFS line package distros distro + [[ -e $fname ]] || { echo "missing: $fname"; exit 1 ;} + + OIFS=$IFS + IFS=$'\n' + for line in $(cat ${fname});do + if [[ $line =~ "NOPRIME" ]];then + continue + fi + + if [[ $line =~ (.*)#.*dist:([^ ]*) ]];then # We are using BASH regexp matching feature. + package=${BASH_REMATCH[1]} + distros=${BASH_REMATCH[2]} + for distro in ${distros//,/ };do #In bash ${VAR,,} will lowecase VAR + [[ ${distro,,} == ${DISTRO,,} ]] && echo $package + done + continue + fi + + echo ${line%#*} + done + IFS=$OIFS + done +} # install apt requirements apt_get update -apt_get install `cat $FILES/apts/* | cut -d\# -f1 | grep -Ev "mysql-server|rabbitmq-server|memcached"` +apt_get install $(get_packages) # install python requirements sudo PIP_DOWNLOAD_CACHE=/var/cache/pip pip install `cat $FILES/pips/*` From f990ded56786b21258cdff2acc946ab2eba2ee76 Mon Sep 17 00:00:00 2001 From: Chmouel Boudjnah Date: Mon, 14 Nov 2011 15:26:13 +0100 Subject: [PATCH 4/5] a-space-after-then/do compliance. --- stack.sh | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/stack.sh b/stack.sh index 1043dc6..536e913 100755 --- a/stack.sh +++ b/stack.sh @@ -377,38 +377,38 @@ function get_packages() { for service in ${ENABLED_SERVICES//,/ }; do if [[ $service == n-* ]]; then - if [[ ! $file_to_parse =~ nova ]];then + if [[ ! $file_to_parse =~ nova ]]; then file_to_parse="${file_to_parse} nova" fi - elif [[ $service == g-* ]];then - if [[ ! $file_to_parse =~ glance ]];then + elif [[ $service == g-* ]]; then + if [[ ! $file_to_parse =~ glance ]]; then file_to_parse="${file_to_parse} glance" fi - elif [[ $service == key* ]];then - if [[ ! $file_to_parse =~ keystone ]];then + elif [[ $service == key* ]]; then + if [[ ! $file_to_parse =~ keystone ]]; then file_to_parse="${file_to_parse} keystone" fi - elif [[ -e $FILES/apts/${service} ]];then + elif [[ -e $FILES/apts/${service} ]]; then file_to_parse="${file_to_parse} $service" fi done - for file in ${file_to_parse};do + for file in ${file_to_parse}; do local fname=${FILES}/apts/${file} local OIFS line package distros distro [[ -e $fname ]] || { echo "missing: $fname"; exit 1 ;} OIFS=$IFS IFS=$'\n' - for line in $(cat ${fname});do - if [[ $line =~ "NOPRIME" ]];then + for line in $(cat ${fname}); do + if [[ $line =~ "NOPRIME" ]]; then continue fi - if [[ $line =~ (.*)#.*dist:([^ ]*) ]];then # We are using BASH regexp matching feature. + if [[ $line =~ (.*)#.*dist:([^ ]*) ]]; then # We are using BASH regexp matching feature. package=${BASH_REMATCH[1]} distros=${BASH_REMATCH[2]} - for distro in ${distros//,/ };do #In bash ${VAR,,} will lowecase VAR + for distro in ${distros//,/ }; do #In bash ${VAR,,} will lowecase VAR [[ ${distro,,} == ${DISTRO,,} ]] && echo $package done continue @@ -710,7 +710,7 @@ if [[ "$ENABLED_SERVICES" =~ "swift" ]]; then sudo chown -R $USER:${USER_GROUP} ${SWIFT_DATA_LOCATION}/drives # We then create a loopback disk and format it to XFS. - if [[ ! -e ${SWIFT_DATA_LOCATION}/drives/images/swift.img ]];then + if [[ ! -e ${SWIFT_DATA_LOCATION}/drives/images/swift.img ]]; then mkdir -p ${SWIFT_DATA_LOCATION}/drives/images sudo touch ${SWIFT_DATA_LOCATION}/drives/images/swift.img sudo chown $USER: ${SWIFT_DATA_LOCATION}/drives/images/swift.img @@ -723,7 +723,7 @@ if [[ "$ENABLED_SERVICES" =~ "swift" ]]; then # After the drive being created we mount the disk with a few mount # options to make it most efficient as possible for swift. mkdir -p ${SWIFT_DATA_LOCATION}/drives/sdb1 - if ! egrep -q ${SWIFT_DATA_LOCATION}/drives/sdb1 /proc/mounts;then + if ! egrep -q ${SWIFT_DATA_LOCATION}/drives/sdb1 /proc/mounts; then sudo mount -t xfs -o loop,noatime,nodiratime,nobarrier,logbufs=8 \ ${SWIFT_DATA_LOCATION}/drives/images/swift.img ${SWIFT_DATA_LOCATION}/drives/sdb1 fi @@ -737,7 +737,7 @@ if [[ "$ENABLED_SERVICES" =~ "swift" ]]; then tmpd="" for d in ${SWIFT_DATA_LOCATION}/drives/sdb1/{1..4} \ ${SWIFT_CONFIG_LOCATION}/{object,container,account}-server \ - ${SWIFT_DATA_LOCATION}/{1..4}/node/sdb1 /var/run/swift ;do + ${SWIFT_DATA_LOCATION}/{1..4}/node/sdb1 /var/run/swift; do [[ -d $d ]] && continue sudo install -o ${USER} -g $USER_GROUP -d $d done @@ -786,7 +786,7 @@ if [[ "$ENABLED_SERVICES" =~ "swift" ]]; then local log_facility=$3 local node_number - for node_number in {1..4};do + for node_number in {1..4}; do node_path=${SWIFT_DATA_LOCATION}/${node_number} sed -e "s,%SWIFT_CONFIG_LOCATION%,${SWIFT_CONFIG_LOCATION},;s,%USER%,$USER,;s,%NODE_PATH%,${node_path},;s,%BIND_PORT%,${bind_port},;s,%LOG_FACILITY%,${log_facility}," \ $FILES/swift/${server_type}-server.conf > ${SWIFT_CONFIG_LOCATION}/${server_type}-server/${node_number}.conf From 2d1a8b34143f7d66a9aaf89ad6d0591bb52656ce Mon Sep 17 00:00:00 2001 From: Chmouel Boudjnah Date: Mon, 14 Nov 2011 22:16:11 +0100 Subject: [PATCH 5/5] Use internal bash reader. --- stack.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stack.sh b/stack.sh index 536e913..6399c7f 100755 --- a/stack.sh +++ b/stack.sh @@ -400,7 +400,7 @@ function get_packages() { OIFS=$IFS IFS=$'\n' - for line in $(cat ${fname}); do + for line in $(<${fname}); do if [[ $line =~ "NOPRIME" ]]; then continue fi