2222
2323# Warn users who aren't on natty, but allow them to override check and attempt
2424# installation with ``FORCE=yes ./stack``
25- if ! egrep -q ' natty|oneiric' /etc/lsb-release; then
25+ DISTRO=$( lsb_release -c -s)
26+
27+ if [[ ! ${DISTRO} =~ (natty| oneiric) ]]; then
2628 echo " WARNING: this script has only been tested on natty and oneiric"
2729 if [[ " $FORCE " != " yes" ]]; then
2830 echo " If you wish to run this script anyway run with FORCE=yes"
372374#
373375# Openstack uses a fair number of other projects.
374376
377+ # - We are going to install packages only for the services needed.
378+ # - We are parsing the packages files and detecting metadatas.
379+ # - If there is a NOPRIME as comment mean we are not doing the install
380+ # just yet.
381+ # - If we have the meta-keyword distro:DISTRO or
382+ # distro:DISTRO1,DISTRO2 it will be installed only for those
383+ # distros (case insensitive).
384+ function get_packages() {
385+ local file_to_parse=" general"
386+ local service
387+
388+ for service in ${ENABLED_SERVICES// ,/ } ; do
389+ if [[ $service == n-* ]]; then
390+ if [[ ! $file_to_parse =~ nova ]]; then
391+ file_to_parse=" ${file_to_parse} nova"
392+ fi
393+ elif [[ $service == g-* ]]; then
394+ if [[ ! $file_to_parse =~ glance ]]; then
395+ file_to_parse=" ${file_to_parse} glance"
396+ fi
397+ elif [[ $service == key* ]]; then
398+ if [[ ! $file_to_parse =~ keystone ]]; then
399+ file_to_parse=" ${file_to_parse} keystone"
400+ fi
401+ elif [[ -e $FILES /apts/${service} ]]; then
402+ file_to_parse=" ${file_to_parse} $service "
403+ fi
404+ done
405+
406+ for file in ${file_to_parse} ; do
407+ local fname=${FILES} /apts/${file}
408+ local OIFS line package distros distro
409+ [[ -e $fname ]] || { echo " missing: $fname " ; exit 1 ; }
410+
411+ OIFS=$IFS
412+ IFS=$' \n '
413+ for line in $( < ${fname} ) ; do
414+ if [[ $line =~ " NOPRIME" ]]; then
415+ continue
416+ fi
417+
418+ if [[ $line =~ (.* )# .*dist:([^ ]*) ]]; then # We are using BASH regexp matching feature.
419+ package= ${BASH_REMATCH[1]}
420+ distros= ${BASH_REMATCH[2]}
421+ for distro in ${distros// ,/ } ; do # In bash ${VAR,,} will lowecase VAR
422+ [[ ${distro,,} == ${DISTRO,,} ]] && echo $package
423+ done
424+ continue
425+ fi
426+
427+ echo ${line%#* }
428+ done
429+ IFS= $OIFS
430+ done
431+ }
375432
376433# install apt requirements
377434apt_get update
378- apt_get install ` cat $FILES /apts/ * | cut -d \# -f1 | grep -Ev " mysql-server|rabbitmq-server|memcached " `
435+ apt_get install $( get_packages )
379436
380437# install python requirements
381438sudo PIP_DOWNLOAD_CACHE= /var/cache/pip pip install --use-mirrors ` cat $FILES /pips/* `
@@ -689,7 +746,7 @@ if [[ "$ENABLED_SERVICES" =~ "swift" ]]; then
689746 sudo chown -R $USER :${USER_GROUP} ${SWIFT_DATA_LOCATION} /drives
690747
691748 # We then create a loopback disk and format it to XFS.
692- if [[ ! -e ${SWIFT_DATA_LOCATION} /drives/images/swift.img ]]; then
749+ if [[ ! -e ${SWIFT_DATA_LOCATION} /drives/images/swift.img ]]; then
693750 mkdir -p ${SWIFT_DATA_LOCATION} /drives/images
694751 sudo touch ${SWIFT_DATA_LOCATION} /drives/images/swift.img
695752 sudo chown $USER : ${SWIFT_DATA_LOCATION} /drives/images/swift.img
@@ -702,7 +759,7 @@ if [[ "$ENABLED_SERVICES" =~ "swift" ]]; then
702759 # After the drive being created we mount the disk with a few mount
703760 # options to make it most efficient as possible for swift.
704761 mkdir -p ${SWIFT_DATA_LOCATION} /drives/sdb1
705- if ! egrep -q ${SWIFT_DATA_LOCATION} /drives/sdb1 /proc/mounts; then
762+ if ! egrep -q ${SWIFT_DATA_LOCATION} /drives/sdb1 /proc/mounts; then
706763 sudo mount -t xfs -o loop,noatime,nodiratime,nobarrier,logbufs=8 \
707764 ${SWIFT_DATA_LOCATION} /drives/images/swift.img ${SWIFT_DATA_LOCATION} /drives/sdb1
708765 fi
@@ -716,7 +773,7 @@ if [[ "$ENABLED_SERVICES" =~ "swift" ]]; then
716773 tmpd=" "
717774 for d in ${SWIFT_DATA_LOCATION} /drives/sdb1/{1..4} \
718775 ${SWIFT_CONFIG_LOCATION} /{object,container,account}-server \
719- ${SWIFT_DATA_LOCATION} /{1..4}/node/sdb1 /var/run/swift ; do
776+ ${SWIFT_DATA_LOCATION} /{1..4}/node/sdb1 /var/run/swift; do
720777 [[ -d $d ]] && continue
721778 sudo install -o ${USER} -g $USER_GROUP -d $d
722779 done
@@ -770,7 +827,7 @@ if [[ "$ENABLED_SERVICES" =~ "swift" ]]; then
770827 local log_facility=$3
771828 local node_number
772829
773- for node_number in {1..4}; do
830+ for node_number in {1..4}; do
774831 node_path=${SWIFT_DATA_LOCATION} /${node_number}
775832 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} ," \
776833 $FILES /swift/${server_type} -server.conf > ${SWIFT_CONFIG_LOCATION} /${server_type} -server/${node_number} .conf
0 commit comments