| Dean Troyer | 7f9aa71 | 2012-01-31 12:11:56 -0600 | [diff] [blame] | 1 | # functions - Common functions used by DevStack components | 
| Dean Troyer | 13dc5cc | 2012-03-27 14:50:45 -0500 | [diff] [blame] | 2 | # | 
| Dean Troyer | 4a43b7b | 2012-08-28 17:43:40 -0500 | [diff] [blame] | 3 | # The following variables are assumed to be defined by certain functions: | 
| Dean Troyer | 4a43b7b | 2012-08-28 17:43:40 -0500 | [diff] [blame] | 4 | # ``ENABLED_SERVICES`` | 
|  | 5 | # ``EROR_ON_CLONE`` | 
|  | 6 | # ``FILES`` | 
|  | 7 | # ``GLANCE_HOSTPORT`` | 
|  | 8 | # ``OFFLINE`` | 
|  | 9 | # ``PIP_DOWNLOAD_CACHE`` | 
| Maru Newby | 3a87edd | 2012-10-25 23:01:06 +0000 | [diff] [blame] | 10 | # ``PIP_USE_MIRRORS`` | 
| Dean Troyer | 4a43b7b | 2012-08-28 17:43:40 -0500 | [diff] [blame] | 11 | # ``RECLONE`` | 
|  | 12 | # ``TRACK_DEPENDS`` | 
|  | 13 | # ``http_proxy``, ``https_proxy``, ``no_proxy`` | 
| Dean Troyer | 13dc5cc | 2012-03-27 14:50:45 -0500 | [diff] [blame] | 14 |  | 
| Dean Troyer | 7f9aa71 | 2012-01-31 12:11:56 -0600 | [diff] [blame] | 15 |  | 
| Dean Troyer | 27e3269 | 2012-03-16 16:16:56 -0500 | [diff] [blame] | 16 | # Save trace setting | 
|  | 17 | XTRACE=$(set +o | grep xtrace) | 
|  | 18 | set +o xtrace | 
|  | 19 |  | 
| Dean Troyer | 7f9aa71 | 2012-01-31 12:11:56 -0600 | [diff] [blame] | 20 |  | 
| Dean Troyer | 4a43b7b | 2012-08-28 17:43:40 -0500 | [diff] [blame] | 21 | # Exit 0 if address is in network or 1 if address is not in | 
|  | 22 | # network or netaddr library is not installed. | 
|  | 23 | # address_in_net ip-address ip-range | 
| Vishvananda Ishaya | c9ad14b | 2012-07-03 20:29:01 +0000 | [diff] [blame] | 24 | function address_in_net() { | 
|  | 25 | python -c " | 
|  | 26 | import netaddr | 
|  | 27 | import sys | 
|  | 28 | sys.exit(netaddr.IPAddress('$1') not in netaddr.IPNetwork('$2')) | 
|  | 29 | " | 
|  | 30 | } | 
|  | 31 |  | 
|  | 32 |  | 
| Dean Troyer | 4a43b7b | 2012-08-28 17:43:40 -0500 | [diff] [blame] | 33 | # Wrapper for ``apt-get`` to set cache and proxy environment variables | 
|  | 34 | # Uses globals ``OFFLINE``, ``*_proxy` | 
| Dean Troyer | 13dc5cc | 2012-03-27 14:50:45 -0500 | [diff] [blame] | 35 | # apt_get operation package [package ...] | 
| Dean Troyer | 7f9aa71 | 2012-01-31 12:11:56 -0600 | [diff] [blame] | 36 | function apt_get() { | 
| Dean Troyer | d0b21e2 | 2012-03-07 14:52:25 -0600 | [diff] [blame] | 37 | [[ "$OFFLINE" = "True" || -z "$@" ]] && return | 
| Dean Troyer | 7f9aa71 | 2012-01-31 12:11:56 -0600 | [diff] [blame] | 38 | local sudo="sudo" | 
|  | 39 | [[ "$(id -u)" = "0" ]] && sudo="env" | 
|  | 40 | $sudo DEBIAN_FRONTEND=noninteractive \ | 
|  | 41 | http_proxy=$http_proxy https_proxy=$https_proxy \ | 
| Osamu Habuka | 7abe4f2 | 2012-07-25 12:39:32 +0900 | [diff] [blame] | 42 | no_proxy=$no_proxy \ | 
| Dean Troyer | 7f9aa71 | 2012-01-31 12:11:56 -0600 | [diff] [blame] | 43 | apt-get --option "Dpkg::Options::=--force-confold" --assume-yes "$@" | 
|  | 44 | } | 
|  | 45 |  | 
|  | 46 |  | 
|  | 47 | # Gracefully cp only if source file/dir exists | 
|  | 48 | # cp_it source destination | 
|  | 49 | function cp_it { | 
|  | 50 | if [ -e $1 ] || [ -d $1 ]; then | 
|  | 51 | cp -pRL $1 $2 | 
|  | 52 | fi | 
|  | 53 | } | 
|  | 54 |  | 
|  | 55 |  | 
| Dean Troyer | ac93efb | 2013-03-13 14:30:54 -0500 | [diff] [blame^] | 56 | # Prints line number and "message" then exits | 
|  | 57 | # die $LINENO "message" | 
| Dean Troyer | 27e3269 | 2012-03-16 16:16:56 -0500 | [diff] [blame] | 58 | function die() { | 
| Dean Troyer | 489bd2a | 2012-03-02 10:44:29 -0600 | [diff] [blame] | 59 | local exitcode=$? | 
| Nachi Ueno | 07115eb | 2013-02-26 12:38:18 -0800 | [diff] [blame] | 60 | if [ $exitcode == 0 ]; then | 
|  | 61 | exitcode=1 | 
|  | 62 | fi | 
| Dean Troyer | 27e3269 | 2012-03-16 16:16:56 -0500 | [diff] [blame] | 63 | set +o xtrace | 
| Nachi Ueno | 07115eb | 2013-02-26 12:38:18 -0800 | [diff] [blame] | 64 | local msg="[ERROR] $0:$1 $2" | 
|  | 65 | echo $msg 1>&2; | 
|  | 66 | if [[ -n ${SCREEN_LOGDIR} ]]; then | 
|  | 67 | echo $msg >> "${SCREEN_LOGDIR}/error.log" | 
|  | 68 | fi | 
| Dean Troyer | 27e3269 | 2012-03-16 16:16:56 -0500 | [diff] [blame] | 69 | exit $exitcode | 
| Dean Troyer | 489bd2a | 2012-03-02 10:44:29 -0600 | [diff] [blame] | 70 | } | 
|  | 71 |  | 
|  | 72 |  | 
|  | 73 | # Checks an environment variable is not set or has length 0 OR if the | 
|  | 74 | # exit code is non-zero and prints "message" and exits | 
|  | 75 | # NOTE: env-var is the variable name without a '$' | 
| Dean Troyer | ac93efb | 2013-03-13 14:30:54 -0500 | [diff] [blame^] | 76 | # die_if_not_set $LINENO env-var "message" | 
| Dean Troyer | 489bd2a | 2012-03-02 10:44:29 -0600 | [diff] [blame] | 77 | function die_if_not_set() { | 
| Dean Troyer | 27e3269 | 2012-03-16 16:16:56 -0500 | [diff] [blame] | 78 | ( | 
|  | 79 | local exitcode=$? | 
|  | 80 | set +o xtrace | 
| Nachi Ueno | 07115eb | 2013-02-26 12:38:18 -0800 | [diff] [blame] | 81 | local evar=$2; shift | 
| Dean Troyer | 27e3269 | 2012-03-16 16:16:56 -0500 | [diff] [blame] | 82 | if ! is_set $evar || [ $exitcode != 0 ]; then | 
| Nachi Ueno | 07115eb | 2013-02-26 12:38:18 -0800 | [diff] [blame] | 83 | die $@ | 
| Dean Troyer | 27e3269 | 2012-03-16 16:16:56 -0500 | [diff] [blame] | 84 | fi | 
|  | 85 | ) | 
| Dean Troyer | 489bd2a | 2012-03-02 10:44:29 -0600 | [diff] [blame] | 86 | } | 
|  | 87 |  | 
|  | 88 |  | 
| Dean Troyer | 48352ee | 2012-12-12 12:50:38 -0600 | [diff] [blame] | 89 | # HTTP and HTTPS proxy servers are supported via the usual environment variables [1] | 
|  | 90 | # ``http_proxy``, ``https_proxy`` and ``no_proxy``. They can be set in | 
|  | 91 | # ``localrc`` or on the command line if necessary:: | 
|  | 92 | # | 
|  | 93 | # [1] http://www.w3.org/Daemon/User/Proxies/ProxyClients.html | 
|  | 94 | # | 
|  | 95 | #     http_proxy=http://proxy.example.com:3128/ no_proxy=repo.example.net ./stack.sh | 
|  | 96 |  | 
|  | 97 | function export_proxy_variables() { | 
|  | 98 | if [[ -n "$http_proxy" ]]; then | 
|  | 99 | export http_proxy=$http_proxy | 
|  | 100 | fi | 
|  | 101 | if [[ -n "$https_proxy" ]]; then | 
|  | 102 | export https_proxy=$https_proxy | 
|  | 103 | fi | 
|  | 104 | if [[ -n "$no_proxy" ]]; then | 
|  | 105 | export no_proxy=$no_proxy | 
|  | 106 | fi | 
|  | 107 | } | 
|  | 108 |  | 
|  | 109 |  | 
| Dean Troyer | 489bd2a | 2012-03-02 10:44:29 -0600 | [diff] [blame] | 110 | # Grab a numbered field from python prettytable output | 
|  | 111 | # Fields are numbered starting with 1 | 
|  | 112 | # Reverse syntax is supported: -1 is the last field, -2 is second to last, etc. | 
|  | 113 | # get_field field-number | 
|  | 114 | function get_field() { | 
|  | 115 | while read data; do | 
|  | 116 | if [ "$1" -lt 0 ]; then | 
|  | 117 | field="(\$(NF$1))" | 
|  | 118 | else | 
|  | 119 | field="\$$(($1 + 1))" | 
|  | 120 | fi | 
|  | 121 | echo "$data" | awk -F'[ \t]*\\|[ \t]*' "{print $field}" | 
|  | 122 | done | 
|  | 123 | } | 
|  | 124 |  | 
|  | 125 |  | 
| Isaku Yamahata | 8c43809 | 2013-02-12 22:30:56 +0900 | [diff] [blame] | 126 | function _get_package_dir() { | 
|  | 127 | local pkg_dir | 
|  | 128 | if is_ubuntu; then | 
|  | 129 | pkg_dir=$FILES/apts | 
|  | 130 | elif is_fedora; then | 
|  | 131 | pkg_dir=$FILES/rpms | 
|  | 132 | elif is_suse; then | 
|  | 133 | pkg_dir=$FILES/rpms-suse | 
|  | 134 | else | 
|  | 135 | exit_distro_not_supported "list of packages" | 
|  | 136 | fi | 
|  | 137 | echo "$pkg_dir" | 
|  | 138 | } | 
|  | 139 |  | 
| Dean Troyer | 7e27051 | 2012-06-14 15:23:24 -0500 | [diff] [blame] | 140 | # get_packages() collects a list of package names of any type from the | 
| Dean Troyer | 4a43b7b | 2012-08-28 17:43:40 -0500 | [diff] [blame] | 141 | # prerequisite files in ``files/{apts|rpms}``.  The list is intended | 
|  | 142 | # to be passed to a package installer such as apt or yum. | 
| Dean Troyer | 7e27051 | 2012-06-14 15:23:24 -0500 | [diff] [blame] | 143 | # | 
| Isaku Yamahata | 8c43809 | 2013-02-12 22:30:56 +0900 | [diff] [blame] | 144 | # Only packages required for the services in 1st argument will be | 
| Dean Troyer | 7e27051 | 2012-06-14 15:23:24 -0500 | [diff] [blame] | 145 | # included.  Two bits of metadata are recognized in the prerequisite files: | 
|  | 146 | # - ``# NOPRIME`` defers installation to be performed later in stack.sh | 
|  | 147 | # - ``# dist:DISTRO`` or ``dist:DISTRO1,DISTRO2`` limits the selection | 
|  | 148 | #   of the package to the distros listed.  The distro names are case insensitive. | 
| Dean Troyer | 7e27051 | 2012-06-14 15:23:24 -0500 | [diff] [blame] | 149 | function get_packages() { | 
| Isaku Yamahata | 8c43809 | 2013-02-12 22:30:56 +0900 | [diff] [blame] | 150 | local services=$1 | 
|  | 151 | local package_dir=$(_get_package_dir) | 
| Dean Troyer | 7e27051 | 2012-06-14 15:23:24 -0500 | [diff] [blame] | 152 | local file_to_parse | 
|  | 153 | local service | 
|  | 154 |  | 
|  | 155 | if [[ -z "$package_dir" ]]; then | 
|  | 156 | echo "No package directory supplied" | 
|  | 157 | return 1 | 
|  | 158 | fi | 
|  | 159 | if [[ -z "$DISTRO" ]]; then | 
| Vincent Untz | 855c587 | 2012-10-04 13:36:46 +0200 | [diff] [blame] | 160 | GetDistro | 
| Dean Troyer | 7e27051 | 2012-06-14 15:23:24 -0500 | [diff] [blame] | 161 | fi | 
| Isaku Yamahata | 8c43809 | 2013-02-12 22:30:56 +0900 | [diff] [blame] | 162 | for service in general ${services//,/ }; do | 
| Dean Troyer | 7e27051 | 2012-06-14 15:23:24 -0500 | [diff] [blame] | 163 | # Allow individual services to specify dependencies | 
|  | 164 | if [[ -e ${package_dir}/${service} ]]; then | 
|  | 165 | file_to_parse="${file_to_parse} $service" | 
|  | 166 | fi | 
|  | 167 | # NOTE(sdague) n-api needs glance for now because that's where | 
|  | 168 | # glance client is | 
|  | 169 | if [[ $service == n-api ]]; then | 
|  | 170 | if [[ ! $file_to_parse =~ nova ]]; then | 
|  | 171 | file_to_parse="${file_to_parse} nova" | 
|  | 172 | fi | 
|  | 173 | if [[ ! $file_to_parse =~ glance ]]; then | 
|  | 174 | file_to_parse="${file_to_parse} glance" | 
|  | 175 | fi | 
|  | 176 | elif [[ $service == c-* ]]; then | 
|  | 177 | if [[ ! $file_to_parse =~ cinder ]]; then | 
|  | 178 | file_to_parse="${file_to_parse} cinder" | 
|  | 179 | fi | 
| John H. Tran | 9336164 | 2012-07-26 11:22:05 -0700 | [diff] [blame] | 180 | elif [[ $service == ceilometer-* ]]; then | 
|  | 181 | if [[ ! $file_to_parse =~ ceilometer ]]; then | 
|  | 182 | file_to_parse="${file_to_parse} ceilometer" | 
|  | 183 | fi | 
| Dean Troyer | 7e27051 | 2012-06-14 15:23:24 -0500 | [diff] [blame] | 184 | elif [[ $service == n-* ]]; then | 
|  | 185 | if [[ ! $file_to_parse =~ nova ]]; then | 
|  | 186 | file_to_parse="${file_to_parse} nova" | 
|  | 187 | fi | 
|  | 188 | elif [[ $service == g-* ]]; then | 
|  | 189 | if [[ ! $file_to_parse =~ glance ]]; then | 
|  | 190 | file_to_parse="${file_to_parse} glance" | 
|  | 191 | fi | 
|  | 192 | elif [[ $service == key* ]]; then | 
|  | 193 | if [[ ! $file_to_parse =~ keystone ]]; then | 
|  | 194 | file_to_parse="${file_to_parse} keystone" | 
|  | 195 | fi | 
| Robert Collins | 0a9954f | 2012-11-20 11:34:25 +1300 | [diff] [blame] | 196 | elif [[ $service == q-* ]]; then | 
|  | 197 | if [[ ! $file_to_parse =~ quantum ]]; then | 
|  | 198 | file_to_parse="${file_to_parse} quantum" | 
|  | 199 | fi | 
| Dean Troyer | 7e27051 | 2012-06-14 15:23:24 -0500 | [diff] [blame] | 200 | fi | 
|  | 201 | done | 
|  | 202 |  | 
|  | 203 | for file in ${file_to_parse}; do | 
|  | 204 | local fname=${package_dir}/${file} | 
|  | 205 | local OIFS line package distros distro | 
|  | 206 | [[ -e $fname ]] || continue | 
|  | 207 |  | 
|  | 208 | OIFS=$IFS | 
|  | 209 | IFS=$'\n' | 
|  | 210 | for line in $(<${fname}); do | 
|  | 211 | if [[ $line =~ "NOPRIME" ]]; then | 
|  | 212 | continue | 
|  | 213 | fi | 
|  | 214 |  | 
|  | 215 | if [[ $line =~ (.*)#.*dist:([^ ]*) ]]; then | 
|  | 216 | # We are using BASH regexp matching feature. | 
|  | 217 | package=${BASH_REMATCH[1]} | 
|  | 218 | distros=${BASH_REMATCH[2]} | 
|  | 219 | # In bash ${VAR,,} will lowecase VAR | 
|  | 220 | [[ ${distros,,} =~ ${DISTRO,,} ]] && echo $package | 
|  | 221 | continue | 
|  | 222 | fi | 
|  | 223 |  | 
|  | 224 | echo ${line%#*} | 
|  | 225 | done | 
|  | 226 | IFS=$OIFS | 
|  | 227 | done | 
|  | 228 | } | 
|  | 229 |  | 
|  | 230 |  | 
| Dean Troyer | 13dc5cc | 2012-03-27 14:50:45 -0500 | [diff] [blame] | 231 | # Determine OS Vendor, Release and Update | 
|  | 232 | # Tested with OS/X, Ubuntu, RedHat, CentOS, Fedora | 
|  | 233 | # Returns results in global variables: | 
|  | 234 | # os_VENDOR - vendor name | 
|  | 235 | # os_RELEASE - release | 
|  | 236 | # os_UPDATE - update | 
|  | 237 | # os_PACKAGE - package type | 
|  | 238 | # os_CODENAME - vendor's codename for release | 
|  | 239 | # GetOSVersion | 
|  | 240 | GetOSVersion() { | 
|  | 241 | # Figure out which vendor we are | 
|  | 242 | if [[ -n "`which sw_vers 2>/dev/null`" ]]; then | 
|  | 243 | # OS/X | 
|  | 244 | os_VENDOR=`sw_vers -productName` | 
|  | 245 | os_RELEASE=`sw_vers -productVersion` | 
|  | 246 | os_UPDATE=${os_RELEASE##*.} | 
|  | 247 | os_RELEASE=${os_RELEASE%.*} | 
|  | 248 | os_PACKAGE="" | 
|  | 249 | if [[ "$os_RELEASE" =~ "10.7" ]]; then | 
|  | 250 | os_CODENAME="lion" | 
|  | 251 | elif [[ "$os_RELEASE" =~ "10.6" ]]; then | 
|  | 252 | os_CODENAME="snow leopard" | 
|  | 253 | elif [[ "$os_RELEASE" =~ "10.5" ]]; then | 
|  | 254 | os_CODENAME="leopard" | 
|  | 255 | elif [[ "$os_RELEASE" =~ "10.4" ]]; then | 
|  | 256 | os_CODENAME="tiger" | 
|  | 257 | elif [[ "$os_RELEASE" =~ "10.3" ]]; then | 
|  | 258 | os_CODENAME="panther" | 
|  | 259 | else | 
|  | 260 | os_CODENAME="" | 
|  | 261 | fi | 
|  | 262 | elif [[ -x $(which lsb_release 2>/dev/null) ]]; then | 
|  | 263 | os_VENDOR=$(lsb_release -i -s) | 
|  | 264 | os_RELEASE=$(lsb_release -r -s) | 
|  | 265 | os_UPDATE="" | 
| Attila Fazekas | af988fd | 2013-01-13 14:20:47 +0100 | [diff] [blame] | 266 | os_PACKAGE="rpm" | 
| Dean Troyer | 13dc5cc | 2012-03-27 14:50:45 -0500 | [diff] [blame] | 267 | if [[ "Debian,Ubuntu" =~ $os_VENDOR ]]; then | 
|  | 268 | os_PACKAGE="deb" | 
| Vincent Untz | 856a11e | 2012-11-21 16:04:12 +0100 | [diff] [blame] | 269 | elif [[ "SUSE LINUX" =~ $os_VENDOR ]]; then | 
|  | 270 | lsb_release -d -s | grep -q openSUSE | 
|  | 271 | if [[ $? -eq 0 ]]; then | 
|  | 272 | os_VENDOR="openSUSE" | 
|  | 273 | fi | 
| Attila Fazekas | af988fd | 2013-01-13 14:20:47 +0100 | [diff] [blame] | 274 | elif [[ $os_VENDOR =~ Red.*Hat ]]; then | 
|  | 275 | os_VENDOR="Red Hat" | 
| Dean Troyer | 13dc5cc | 2012-03-27 14:50:45 -0500 | [diff] [blame] | 276 | fi | 
|  | 277 | os_CODENAME=$(lsb_release -c -s) | 
|  | 278 | elif [[ -r /etc/redhat-release ]]; then | 
|  | 279 | # Red Hat Enterprise Linux Server release 5.5 (Tikanga) | 
|  | 280 | # CentOS release 5.5 (Final) | 
|  | 281 | # CentOS Linux release 6.0 (Final) | 
|  | 282 | # Fedora release 16 (Verne) | 
|  | 283 | os_CODENAME="" | 
|  | 284 | for r in "Red Hat" CentOS Fedora; do | 
|  | 285 | os_VENDOR=$r | 
|  | 286 | if [[ -n "`grep \"$r\" /etc/redhat-release`" ]]; then | 
|  | 287 | ver=`sed -e 's/^.* \(.*\) (\(.*\)).*$/\1\|\2/' /etc/redhat-release` | 
|  | 288 | os_CODENAME=${ver#*|} | 
|  | 289 | os_RELEASE=${ver%|*} | 
|  | 290 | os_UPDATE=${os_RELEASE##*.} | 
|  | 291 | os_RELEASE=${os_RELEASE%.*} | 
|  | 292 | break | 
|  | 293 | fi | 
|  | 294 | os_VENDOR="" | 
|  | 295 | done | 
|  | 296 | os_PACKAGE="rpm" | 
| Vincent Untz | 856a11e | 2012-11-21 16:04:12 +0100 | [diff] [blame] | 297 | elif [[ -r /etc/SuSE-release ]]; then | 
|  | 298 | for r in openSUSE "SUSE Linux"; do | 
|  | 299 | if [[ "$r" = "SUSE Linux" ]]; then | 
|  | 300 | os_VENDOR="SUSE LINUX" | 
|  | 301 | else | 
|  | 302 | os_VENDOR=$r | 
|  | 303 | fi | 
|  | 304 |  | 
|  | 305 | if [[ -n "`grep \"$r\" /etc/SuSE-release`" ]]; then | 
|  | 306 | os_CODENAME=`grep "CODENAME = " /etc/SuSE-release | sed 's:.* = ::g'` | 
|  | 307 | os_RELEASE=`grep "VERSION = " /etc/SuSE-release | sed 's:.* = ::g'` | 
|  | 308 | os_UPDATE=`grep "PATCHLEVEL = " /etc/SuSE-release | sed 's:.* = ::g'` | 
|  | 309 | break | 
|  | 310 | fi | 
|  | 311 | os_VENDOR="" | 
|  | 312 | done | 
|  | 313 | os_PACKAGE="rpm" | 
| Dean Troyer | 13dc5cc | 2012-03-27 14:50:45 -0500 | [diff] [blame] | 314 | fi | 
|  | 315 | export os_VENDOR os_RELEASE os_UPDATE os_PACKAGE os_CODENAME | 
|  | 316 | } | 
|  | 317 |  | 
| Evgeniy Afonichev | 6a3912d | 2012-07-10 14:02:43 +0300 | [diff] [blame] | 318 | # git update using reference as a branch. | 
| Dean Troyer | 4a43b7b | 2012-08-28 17:43:40 -0500 | [diff] [blame] | 319 | # git_update_branch ref | 
| Evgeniy Afonichev | 6a3912d | 2012-07-10 14:02:43 +0300 | [diff] [blame] | 320 | function git_update_branch() { | 
|  | 321 |  | 
|  | 322 | GIT_BRANCH=$1 | 
|  | 323 |  | 
|  | 324 | git checkout -f origin/$GIT_BRANCH | 
|  | 325 | # a local branch might not exist | 
|  | 326 | git branch -D $GIT_BRANCH || true | 
|  | 327 | git checkout -b $GIT_BRANCH | 
|  | 328 | } | 
|  | 329 |  | 
|  | 330 |  | 
|  | 331 | # git update using reference as a tag. Be careful editing source at that repo | 
|  | 332 | # as working copy will be in a detached mode | 
| Dean Troyer | 4a43b7b | 2012-08-28 17:43:40 -0500 | [diff] [blame] | 333 | # git_update_tag ref | 
| Evgeniy Afonichev | 6a3912d | 2012-07-10 14:02:43 +0300 | [diff] [blame] | 334 | function git_update_tag() { | 
|  | 335 |  | 
|  | 336 | GIT_TAG=$1 | 
|  | 337 |  | 
|  | 338 | git tag -d $GIT_TAG | 
|  | 339 | # fetching given tag only | 
|  | 340 | git fetch origin tag $GIT_TAG | 
|  | 341 | git checkout -f $GIT_TAG | 
|  | 342 | } | 
|  | 343 |  | 
| Dean Troyer | 13dc5cc | 2012-03-27 14:50:45 -0500 | [diff] [blame] | 344 |  | 
| Andrew Laski | f900bd7 | 2012-09-05 17:23:14 -0400 | [diff] [blame] | 345 | # git update using reference as a branch. | 
|  | 346 | # git_update_remote_branch ref | 
|  | 347 | function git_update_remote_branch() { | 
|  | 348 |  | 
|  | 349 | GIT_BRANCH=$1 | 
|  | 350 |  | 
|  | 351 | git checkout -b $GIT_BRANCH -t origin/$GIT_BRANCH | 
|  | 352 | } | 
|  | 353 |  | 
|  | 354 |  | 
| Dean Troyer | a9e0a48 | 2012-07-09 14:07:23 -0500 | [diff] [blame] | 355 | # Translate the OS version values into common nomenclature | 
|  | 356 | # Sets ``DISTRO`` from the ``os_*`` values | 
|  | 357 | function GetDistro() { | 
|  | 358 | GetOSVersion | 
|  | 359 | if [[ "$os_VENDOR" =~ (Ubuntu) ]]; then | 
|  | 360 | # 'Everyone' refers to Ubuntu releases by the code name adjective | 
|  | 361 | DISTRO=$os_CODENAME | 
|  | 362 | elif [[ "$os_VENDOR" =~ (Fedora) ]]; then | 
|  | 363 | # For Fedora, just use 'f' and the release | 
|  | 364 | DISTRO="f$os_RELEASE" | 
| Vincent Untz | 856a11e | 2012-11-21 16:04:12 +0100 | [diff] [blame] | 365 | elif [[ "$os_VENDOR" =~ (openSUSE) ]]; then | 
|  | 366 | DISTRO="opensuse-$os_RELEASE" | 
|  | 367 | elif [[ "$os_VENDOR" =~ (SUSE LINUX) ]]; then | 
|  | 368 | # For SLE, also use the service pack | 
|  | 369 | if [[ -z "$os_UPDATE" ]]; then | 
|  | 370 | DISTRO="sle${os_RELEASE}" | 
|  | 371 | else | 
|  | 372 | DISTRO="sle${os_RELEASE}sp${os_UPDATE}" | 
|  | 373 | fi | 
| Dean Troyer | a9e0a48 | 2012-07-09 14:07:23 -0500 | [diff] [blame] | 374 | else | 
|  | 375 | # Catch-all for now is Vendor + Release + Update | 
|  | 376 | DISTRO="$os_VENDOR-$os_RELEASE.$os_UPDATE" | 
|  | 377 | fi | 
|  | 378 | export DISTRO | 
|  | 379 | } | 
|  | 380 |  | 
|  | 381 |  | 
| Vincent Untz | c18b965 | 2012-12-04 12:36:34 +0100 | [diff] [blame] | 382 | # Determine if current distribution is an Ubuntu-based distribution. | 
|  | 383 | # It will also detect non-Ubuntu but Debian-based distros; this is not an issue | 
|  | 384 | # since Debian and Ubuntu should be compatible. | 
|  | 385 | # is_ubuntu | 
|  | 386 | function is_ubuntu { | 
|  | 387 | if [[ -z "$os_PACKAGE" ]]; then | 
|  | 388 | GetOSVersion | 
|  | 389 | fi | 
|  | 390 |  | 
|  | 391 | [ "$os_PACKAGE" = "deb" ] | 
|  | 392 | } | 
|  | 393 |  | 
|  | 394 |  | 
| Vincent Untz | 00011c0 | 2012-12-06 09:56:32 +0100 | [diff] [blame] | 395 | # Determine if current distribution is a Fedora-based distribution | 
|  | 396 | # (Fedora, RHEL, CentOS). | 
|  | 397 | # is_fedora | 
|  | 398 | function is_fedora { | 
|  | 399 | if [[ -z "$os_VENDOR" ]]; then | 
|  | 400 | GetOSVersion | 
|  | 401 | fi | 
|  | 402 |  | 
|  | 403 | [ "$os_VENDOR" = "Fedora" ] || [ "$os_VENDOR" = "Red Hat" ] || [ "$os_VENDOR" = "CentOS" ] | 
|  | 404 | } | 
|  | 405 |  | 
|  | 406 |  | 
| Vincent Untz | 856a11e | 2012-11-21 16:04:12 +0100 | [diff] [blame] | 407 | # Determine if current distribution is a SUSE-based distribution | 
|  | 408 | # (openSUSE, SLE). | 
|  | 409 | # is_suse | 
|  | 410 | function is_suse { | 
|  | 411 | if [[ -z "$os_VENDOR" ]]; then | 
|  | 412 | GetOSVersion | 
|  | 413 | fi | 
|  | 414 |  | 
| Steve Baker | 1a7bbd2 | 2012-12-03 17:04:02 +1300 | [diff] [blame] | 415 | [ "$os_VENDOR" = "openSUSE" ] || [ "$os_VENDOR" = "SUSE LINUX" ] | 
| Vincent Untz | 856a11e | 2012-11-21 16:04:12 +0100 | [diff] [blame] | 416 | } | 
|  | 417 |  | 
|  | 418 |  | 
| Vincent Untz | 00011c0 | 2012-12-06 09:56:32 +0100 | [diff] [blame] | 419 | # Exit after outputting a message about the distribution not being supported. | 
|  | 420 | # exit_distro_not_supported [optional-string-telling-what-is-missing] | 
|  | 421 | function exit_distro_not_supported { | 
|  | 422 | if [[ -z "$DISTRO" ]]; then | 
|  | 423 | GetDistro | 
|  | 424 | fi | 
|  | 425 |  | 
|  | 426 | if [ $# -gt 0 ]; then | 
| Nachi Ueno | 07115eb | 2013-02-26 12:38:18 -0800 | [diff] [blame] | 427 | die $LINENO "Support for $DISTRO is incomplete: no support for $@" | 
| Vincent Untz | 00011c0 | 2012-12-06 09:56:32 +0100 | [diff] [blame] | 428 | else | 
| Nachi Ueno | 07115eb | 2013-02-26 12:38:18 -0800 | [diff] [blame] | 429 | die $LINENO "Support for $DISTRO is incomplete." | 
| Vincent Untz | 00011c0 | 2012-12-06 09:56:32 +0100 | [diff] [blame] | 430 | fi | 
| Vincent Untz | 00011c0 | 2012-12-06 09:56:32 +0100 | [diff] [blame] | 431 | } | 
|  | 432 |  | 
|  | 433 |  | 
| Dean Troyer | 7f9aa71 | 2012-01-31 12:11:56 -0600 | [diff] [blame] | 434 | # git clone only if directory doesn't exist already.  Since ``DEST`` might not | 
|  | 435 | # be owned by the installation user, we create the directory and change the | 
|  | 436 | # ownership to the proper user. | 
|  | 437 | # Set global RECLONE=yes to simulate a clone when dest-dir exists | 
| James E. Blair | 94cb960 | 2012-06-22 15:28:29 -0700 | [diff] [blame] | 438 | # Set global ERROR_ON_CLONE=True to abort execution with an error if the git repo | 
|  | 439 | # does not exist (default is False, meaning the repo will be cloned). | 
| Dean Troyer | 4a43b7b | 2012-08-28 17:43:40 -0500 | [diff] [blame] | 440 | # Uses global ``OFFLINE`` | 
| Dean Troyer | 7f9aa71 | 2012-01-31 12:11:56 -0600 | [diff] [blame] | 441 | # git_clone remote dest-dir branch | 
|  | 442 | function git_clone { | 
|  | 443 | [[ "$OFFLINE" = "True" ]] && return | 
|  | 444 |  | 
|  | 445 | GIT_REMOTE=$1 | 
|  | 446 | GIT_DEST=$2 | 
| Evgeniy Afonichev | 6a3912d | 2012-07-10 14:02:43 +0300 | [diff] [blame] | 447 | GIT_REF=$3 | 
| Dean Troyer | 7f9aa71 | 2012-01-31 12:11:56 -0600 | [diff] [blame] | 448 |  | 
| Evgeniy Afonichev | 6a3912d | 2012-07-10 14:02:43 +0300 | [diff] [blame] | 449 | if echo $GIT_REF | egrep -q "^refs"; then | 
| Dean Troyer | 7f9aa71 | 2012-01-31 12:11:56 -0600 | [diff] [blame] | 450 | # If our branch name is a gerrit style refs/changes/... | 
|  | 451 | if [[ ! -d $GIT_DEST ]]; then | 
| James E. Blair | 94cb960 | 2012-06-22 15:28:29 -0700 | [diff] [blame] | 452 | [[ "$ERROR_ON_CLONE" = "True" ]] && exit 1 | 
| Dean Troyer | 7f9aa71 | 2012-01-31 12:11:56 -0600 | [diff] [blame] | 453 | git clone $GIT_REMOTE $GIT_DEST | 
|  | 454 | fi | 
|  | 455 | cd $GIT_DEST | 
| Evgeniy Afonichev | 6a3912d | 2012-07-10 14:02:43 +0300 | [diff] [blame] | 456 | git fetch $GIT_REMOTE $GIT_REF && git checkout FETCH_HEAD | 
| Dean Troyer | 7f9aa71 | 2012-01-31 12:11:56 -0600 | [diff] [blame] | 457 | else | 
|  | 458 | # do a full clone only if the directory doesn't exist | 
|  | 459 | if [[ ! -d $GIT_DEST ]]; then | 
| James E. Blair | 94cb960 | 2012-06-22 15:28:29 -0700 | [diff] [blame] | 460 | [[ "$ERROR_ON_CLONE" = "True" ]] && exit 1 | 
| Dean Troyer | 7f9aa71 | 2012-01-31 12:11:56 -0600 | [diff] [blame] | 461 | git clone $GIT_REMOTE $GIT_DEST | 
|  | 462 | cd $GIT_DEST | 
|  | 463 | # This checkout syntax works for both branches and tags | 
| Evgeniy Afonichev | 6a3912d | 2012-07-10 14:02:43 +0300 | [diff] [blame] | 464 | git checkout $GIT_REF | 
| Dean Troyer | 7f9aa71 | 2012-01-31 12:11:56 -0600 | [diff] [blame] | 465 | elif [[ "$RECLONE" == "yes" ]]; then | 
|  | 466 | # if it does exist then simulate what clone does if asked to RECLONE | 
|  | 467 | cd $GIT_DEST | 
|  | 468 | # set the url to pull from and fetch | 
|  | 469 | git remote set-url origin $GIT_REMOTE | 
|  | 470 | git fetch origin | 
|  | 471 | # remove the existing ignored files (like pyc) as they cause breakage | 
|  | 472 | # (due to the py files having older timestamps than our pyc, so python | 
|  | 473 | # thinks the pyc files are correct using them) | 
|  | 474 | find $GIT_DEST -name '*.pyc' -delete | 
| Evgeniy Afonichev | 6a3912d | 2012-07-10 14:02:43 +0300 | [diff] [blame] | 475 |  | 
|  | 476 | # handle GIT_REF accordingly to type (tag, branch) | 
|  | 477 | if [[ -n "`git show-ref refs/tags/$GIT_REF`" ]]; then | 
|  | 478 | git_update_tag $GIT_REF | 
|  | 479 | elif [[ -n "`git show-ref refs/heads/$GIT_REF`" ]]; then | 
|  | 480 | git_update_branch $GIT_REF | 
| Andrew Laski | f900bd7 | 2012-09-05 17:23:14 -0400 | [diff] [blame] | 481 | elif [[ -n "`git show-ref refs/remotes/origin/$GIT_REF`" ]]; then | 
|  | 482 | git_update_remote_branch $GIT_REF | 
| Evgeniy Afonichev | 6a3912d | 2012-07-10 14:02:43 +0300 | [diff] [blame] | 483 | else | 
|  | 484 | echo $GIT_REF is neither branch nor tag | 
|  | 485 | exit 1 | 
|  | 486 | fi | 
|  | 487 |  | 
| Dean Troyer | 7f9aa71 | 2012-01-31 12:11:56 -0600 | [diff] [blame] | 488 | fi | 
|  | 489 | fi | 
|  | 490 | } | 
|  | 491 |  | 
|  | 492 |  | 
| Dean Troyer | 13dc5cc | 2012-03-27 14:50:45 -0500 | [diff] [blame] | 493 | # Comment an option in an INI file | 
| Chmouel Boudjnah | c7214e8 | 2012-06-06 13:56:39 +0200 | [diff] [blame] | 494 | # inicomment config-file section option | 
| Dean Troyer | 13dc5cc | 2012-03-27 14:50:45 -0500 | [diff] [blame] | 495 | function inicomment() { | 
|  | 496 | local file=$1 | 
|  | 497 | local section=$2 | 
|  | 498 | local option=$3 | 
| Attila Fazekas | 588eb41 | 2012-12-20 10:57:16 +0100 | [diff] [blame] | 499 | sed -i -e "/^\[$section\]/,/^\[.*\]/ s|^\($option[ \t]*=.*$\)|#\1|" "$file" | 
| Dean Troyer | 13dc5cc | 2012-03-27 14:50:45 -0500 | [diff] [blame] | 500 | } | 
|  | 501 |  | 
| Chmouel Boudjnah | c7214e8 | 2012-06-06 13:56:39 +0200 | [diff] [blame] | 502 | # Uncomment an option in an INI file | 
|  | 503 | # iniuncomment config-file section option | 
|  | 504 | function iniuncomment() { | 
|  | 505 | local file=$1 | 
|  | 506 | local section=$2 | 
|  | 507 | local option=$3 | 
| Attila Fazekas | 588eb41 | 2012-12-20 10:57:16 +0100 | [diff] [blame] | 508 | sed -i -e "/^\[$section\]/,/^\[.*\]/ s|[^ \t]*#[ \t]*\($option[ \t]*=.*$\)|\1|" "$file" | 
| Chmouel Boudjnah | c7214e8 | 2012-06-06 13:56:39 +0200 | [diff] [blame] | 509 | } | 
|  | 510 |  | 
| Dean Troyer | 13dc5cc | 2012-03-27 14:50:45 -0500 | [diff] [blame] | 511 |  | 
|  | 512 | # Get an option from an INI file | 
| Dean Troyer | 09e636e | 2012-03-19 16:31:12 -0500 | [diff] [blame] | 513 | # iniget config-file section option | 
| Dean Troyer | 13dc5cc | 2012-03-27 14:50:45 -0500 | [diff] [blame] | 514 | function iniget() { | 
|  | 515 | local file=$1 | 
|  | 516 | local section=$2 | 
|  | 517 | local option=$3 | 
|  | 518 | local line | 
| Attila Fazekas | 588eb41 | 2012-12-20 10:57:16 +0100 | [diff] [blame] | 519 | line=$(sed -ne "/^\[$section\]/,/^\[.*\]/ { /^$option[ \t]*=/ p; }" "$file") | 
| Dean Troyer | 13dc5cc | 2012-03-27 14:50:45 -0500 | [diff] [blame] | 520 | echo ${line#*=} | 
|  | 521 | } | 
|  | 522 |  | 
| Attila Fazekas | 588eb41 | 2012-12-20 10:57:16 +0100 | [diff] [blame] | 523 | # Determinate is the given option present in the INI file | 
|  | 524 | # ini_has_option config-file section option | 
|  | 525 | function ini_has_option() { | 
|  | 526 | local file=$1 | 
|  | 527 | local section=$2 | 
|  | 528 | local option=$3 | 
|  | 529 | local line | 
|  | 530 | line=$(sed -ne "/^\[$section\]/,/^\[.*\]/ { /^$option[ \t]*=/ p; }" "$file") | 
|  | 531 | [ -n "$line" ] | 
|  | 532 | } | 
| Dean Troyer | 13dc5cc | 2012-03-27 14:50:45 -0500 | [diff] [blame] | 533 |  | 
|  | 534 | # Set an option in an INI file | 
| Dean Troyer | 09e636e | 2012-03-19 16:31:12 -0500 | [diff] [blame] | 535 | # iniset config-file section option value | 
| Dean Troyer | 13dc5cc | 2012-03-27 14:50:45 -0500 | [diff] [blame] | 536 | function iniset() { | 
|  | 537 | local file=$1 | 
|  | 538 | local section=$2 | 
|  | 539 | local option=$3 | 
|  | 540 | local value=$4 | 
| Attila Fazekas | 588eb41 | 2012-12-20 10:57:16 +0100 | [diff] [blame] | 541 | if ! grep -q "^\[$section\]" "$file"; then | 
| Dean Troyer | 09e636e | 2012-03-19 16:31:12 -0500 | [diff] [blame] | 542 | # Add section at the end | 
| Attila Fazekas | 588eb41 | 2012-12-20 10:57:16 +0100 | [diff] [blame] | 543 | echo -e "\n[$section]" >>"$file" | 
| Dean Troyer | 09e636e | 2012-03-19 16:31:12 -0500 | [diff] [blame] | 544 | fi | 
| Attila Fazekas | 588eb41 | 2012-12-20 10:57:16 +0100 | [diff] [blame] | 545 | if ! ini_has_option "$file" "$section" "$option"; then | 
| Dean Troyer | 09e636e | 2012-03-19 16:31:12 -0500 | [diff] [blame] | 546 | # Add it | 
| Attila Fazekas | 588eb41 | 2012-12-20 10:57:16 +0100 | [diff] [blame] | 547 | sed -i -e "/^\[$section\]/ a\\ | 
| Dean Troyer | 09e636e | 2012-03-19 16:31:12 -0500 | [diff] [blame] | 548 | $option = $value | 
| Attila Fazekas | 588eb41 | 2012-12-20 10:57:16 +0100 | [diff] [blame] | 549 | " "$file" | 
| Dean Troyer | 09e636e | 2012-03-19 16:31:12 -0500 | [diff] [blame] | 550 | else | 
|  | 551 | # Replace it | 
| Attila Fazekas | 588eb41 | 2012-12-20 10:57:16 +0100 | [diff] [blame] | 552 | sed -i -e "/^\[$section\]/,/^\[.*\]/ s|^\($option[ \t]*=[ \t]*\).*$|\1$value|" "$file" | 
| Dean Troyer | 09e636e | 2012-03-19 16:31:12 -0500 | [diff] [blame] | 553 | fi | 
| Dean Troyer | 13dc5cc | 2012-03-27 14:50:45 -0500 | [diff] [blame] | 554 | } | 
|  | 555 |  | 
|  | 556 |  | 
| Chmouel Boudjnah | 408b009 | 2012-03-15 23:21:55 +0000 | [diff] [blame] | 557 | # is_service_enabled() checks if the service(s) specified as arguments are | 
| Dean Troyer | 4a43b7b | 2012-08-28 17:43:40 -0500 | [diff] [blame] | 558 | # enabled by the user in ``ENABLED_SERVICES``. | 
| Chmouel Boudjnah | 408b009 | 2012-03-15 23:21:55 +0000 | [diff] [blame] | 559 | # | 
| Dean Troyer | 4a43b7b | 2012-08-28 17:43:40 -0500 | [diff] [blame] | 560 | # Multiple services specified as arguments are ``OR``'ed together; the test | 
|  | 561 | # is a short-circuit boolean, i.e it returns on the first match. | 
| Chmouel Boudjnah | 408b009 | 2012-03-15 23:21:55 +0000 | [diff] [blame] | 562 | # | 
| Dean Troyer | 4a43b7b | 2012-08-28 17:43:40 -0500 | [diff] [blame] | 563 | # There are special cases for some 'catch-all' services:: | 
| Chmouel Boudjnah | 408b009 | 2012-03-15 23:21:55 +0000 | [diff] [blame] | 564 | #   **nova** returns true if any service enabled start with **n-** | 
| Dean Troyer | 4a43b7b | 2012-08-28 17:43:40 -0500 | [diff] [blame] | 565 | #   **cinder** returns true if any service enabled start with **c-** | 
|  | 566 | #   **ceilometer** returns true if any service enabled start with **ceilometer** | 
| Chmouel Boudjnah | 408b009 | 2012-03-15 23:21:55 +0000 | [diff] [blame] | 567 | #   **glance** returns true if any service enabled start with **g-** | 
|  | 568 | #   **quantum** returns true if any service enabled start with **q-** | 
| Dean Troyer | 4a43b7b | 2012-08-28 17:43:40 -0500 | [diff] [blame] | 569 | # | 
|  | 570 | # Uses global ``ENABLED_SERVICES`` | 
|  | 571 | # is_service_enabled service [service ...] | 
| Chmouel Boudjnah | 408b009 | 2012-03-15 23:21:55 +0000 | [diff] [blame] | 572 | function is_service_enabled() { | 
|  | 573 | services=$@ | 
|  | 574 | for service in ${services}; do | 
|  | 575 | [[ ,${ENABLED_SERVICES}, =~ ,${service}, ]] && return 0 | 
|  | 576 | [[ ${service} == "nova" && ${ENABLED_SERVICES} =~ "n-" ]] && return 0 | 
| Dean Troyer | 67787e6 | 2012-05-02 11:48:15 -0500 | [diff] [blame] | 577 | [[ ${service} == "cinder" && ${ENABLED_SERVICES} =~ "c-" ]] && return 0 | 
| John H. Tran | 9336164 | 2012-07-26 11:22:05 -0700 | [diff] [blame] | 578 | [[ ${service} == "ceilometer" && ${ENABLED_SERVICES} =~ "ceilometer-" ]] && return 0 | 
| Chmouel Boudjnah | 408b009 | 2012-03-15 23:21:55 +0000 | [diff] [blame] | 579 | [[ ${service} == "glance" && ${ENABLED_SERVICES} =~ "g-" ]] && return 0 | 
|  | 580 | [[ ${service} == "quantum" && ${ENABLED_SERVICES} =~ "q-" ]] && return 0 | 
|  | 581 | done | 
|  | 582 | return 1 | 
|  | 583 | } | 
|  | 584 |  | 
| Dean Troyer | 4a43b7b | 2012-08-28 17:43:40 -0500 | [diff] [blame] | 585 |  | 
|  | 586 | # remove extra commas from the input string (i.e. ``ENABLED_SERVICES``) | 
|  | 587 | # _cleanup_service_list service-list | 
| Doug Hellmann | f04178f | 2012-07-05 17:10:03 -0400 | [diff] [blame] | 588 | function _cleanup_service_list () { | 
| Dean Troyer | ca0e3d0 | 2012-04-13 15:58:37 -0500 | [diff] [blame] | 589 | echo "$1" | sed -e ' | 
| Doug Hellmann | f04178f | 2012-07-05 17:10:03 -0400 | [diff] [blame] | 590 | s/,,/,/g; | 
|  | 591 | s/^,//; | 
|  | 592 | s/,$// | 
|  | 593 | ' | 
|  | 594 | } | 
|  | 595 |  | 
| Dean Troyer | 4a43b7b | 2012-08-28 17:43:40 -0500 | [diff] [blame] | 596 |  | 
| Doug Hellmann | f04178f | 2012-07-05 17:10:03 -0400 | [diff] [blame] | 597 | # enable_service() adds the services passed as argument to the | 
| Dean Troyer | 4a43b7b | 2012-08-28 17:43:40 -0500 | [diff] [blame] | 598 | # ``ENABLED_SERVICES`` list, if they are not already present. | 
| Doug Hellmann | f04178f | 2012-07-05 17:10:03 -0400 | [diff] [blame] | 599 | # | 
|  | 600 | # For example: | 
| Joe Gordon | 6fd2811 | 2012-11-13 16:55:41 -0800 | [diff] [blame] | 601 | #   enable_service qpid | 
| Doug Hellmann | f04178f | 2012-07-05 17:10:03 -0400 | [diff] [blame] | 602 | # | 
|  | 603 | # This function does not know about the special cases | 
|  | 604 | # for nova, glance, and quantum built into is_service_enabled(). | 
| Dean Troyer | 4a43b7b | 2012-08-28 17:43:40 -0500 | [diff] [blame] | 605 | # Uses global ``ENABLED_SERVICES`` | 
|  | 606 | # enable_service service [service ...] | 
| Doug Hellmann | f04178f | 2012-07-05 17:10:03 -0400 | [diff] [blame] | 607 | function enable_service() { | 
|  | 608 | local tmpsvcs="${ENABLED_SERVICES}" | 
|  | 609 | for service in $@; do | 
|  | 610 | if ! is_service_enabled $service; then | 
|  | 611 | tmpsvcs+=",$service" | 
|  | 612 | fi | 
|  | 613 | done | 
|  | 614 | ENABLED_SERVICES=$(_cleanup_service_list "$tmpsvcs") | 
|  | 615 | disable_negated_services | 
|  | 616 | } | 
|  | 617 |  | 
| Dean Troyer | 4a43b7b | 2012-08-28 17:43:40 -0500 | [diff] [blame] | 618 |  | 
| Doug Hellmann | f04178f | 2012-07-05 17:10:03 -0400 | [diff] [blame] | 619 | # disable_service() removes the services passed as argument to the | 
| Dean Troyer | 4a43b7b | 2012-08-28 17:43:40 -0500 | [diff] [blame] | 620 | # ``ENABLED_SERVICES`` list, if they are present. | 
| Doug Hellmann | f04178f | 2012-07-05 17:10:03 -0400 | [diff] [blame] | 621 | # | 
|  | 622 | # For example: | 
| Joe Gordon | 6fd2811 | 2012-11-13 16:55:41 -0800 | [diff] [blame] | 623 | #   disable_service rabbit | 
| Doug Hellmann | f04178f | 2012-07-05 17:10:03 -0400 | [diff] [blame] | 624 | # | 
|  | 625 | # This function does not know about the special cases | 
|  | 626 | # for nova, glance, and quantum built into is_service_enabled(). | 
| Dean Troyer | 4a43b7b | 2012-08-28 17:43:40 -0500 | [diff] [blame] | 627 | # Uses global ``ENABLED_SERVICES`` | 
|  | 628 | # disable_service service [service ...] | 
| Doug Hellmann | f04178f | 2012-07-05 17:10:03 -0400 | [diff] [blame] | 629 | function disable_service() { | 
|  | 630 | local tmpsvcs=",${ENABLED_SERVICES}," | 
|  | 631 | local service | 
|  | 632 | for service in $@; do | 
|  | 633 | if is_service_enabled $service; then | 
|  | 634 | tmpsvcs=${tmpsvcs//,$service,/,} | 
|  | 635 | fi | 
|  | 636 | done | 
|  | 637 | ENABLED_SERVICES=$(_cleanup_service_list "$tmpsvcs") | 
|  | 638 | } | 
|  | 639 |  | 
| Dean Troyer | 4a43b7b | 2012-08-28 17:43:40 -0500 | [diff] [blame] | 640 |  | 
| Doug Hellmann | f04178f | 2012-07-05 17:10:03 -0400 | [diff] [blame] | 641 | # disable_all_services() removes all current services | 
| Dean Troyer | 4a43b7b | 2012-08-28 17:43:40 -0500 | [diff] [blame] | 642 | # from ``ENABLED_SERVICES`` to reset the configuration | 
| Doug Hellmann | f04178f | 2012-07-05 17:10:03 -0400 | [diff] [blame] | 643 | # before a minimal installation | 
| Dean Troyer | 4a43b7b | 2012-08-28 17:43:40 -0500 | [diff] [blame] | 644 | # Uses global ``ENABLED_SERVICES`` | 
|  | 645 | # disable_all_services | 
| Doug Hellmann | f04178f | 2012-07-05 17:10:03 -0400 | [diff] [blame] | 646 | function disable_all_services() { | 
|  | 647 | ENABLED_SERVICES="" | 
|  | 648 | } | 
|  | 649 |  | 
| Dean Troyer | 4a43b7b | 2012-08-28 17:43:40 -0500 | [diff] [blame] | 650 |  | 
|  | 651 | # Remove all services starting with '-'.  For example, to install all default | 
| Joe Gordon | 6fd2811 | 2012-11-13 16:55:41 -0800 | [diff] [blame] | 652 | # services except rabbit (rabbit) set in ``localrc``: | 
|  | 653 | # ENABLED_SERVICES+=",-rabbit" | 
| Dean Troyer | 4a43b7b | 2012-08-28 17:43:40 -0500 | [diff] [blame] | 654 | # Uses global ``ENABLED_SERVICES`` | 
|  | 655 | # disable_negated_services | 
| Doug Hellmann | f04178f | 2012-07-05 17:10:03 -0400 | [diff] [blame] | 656 | function disable_negated_services() { | 
|  | 657 | local tmpsvcs="${ENABLED_SERVICES}" | 
|  | 658 | local service | 
|  | 659 | for service in ${tmpsvcs//,/ }; do | 
|  | 660 | if [[ ${service} == -* ]]; then | 
|  | 661 | tmpsvcs=$(echo ${tmpsvcs}|sed -r "s/(,)?(-)?${service#-}(,)?/,/g") | 
|  | 662 | fi | 
|  | 663 | done | 
|  | 664 | ENABLED_SERVICES=$(_cleanup_service_list "$tmpsvcs") | 
|  | 665 | } | 
| Dean Troyer | 489bd2a | 2012-03-02 10:44:29 -0600 | [diff] [blame] | 666 |  | 
| Dean Troyer | 4a43b7b | 2012-08-28 17:43:40 -0500 | [diff] [blame] | 667 |  | 
| Dean Troyer | 13dc5cc | 2012-03-27 14:50:45 -0500 | [diff] [blame] | 668 | # Distro-agnostic package installer | 
|  | 669 | # install_package package [package ...] | 
|  | 670 | function install_package() { | 
| Vincent Untz | c18b965 | 2012-12-04 12:36:34 +0100 | [diff] [blame] | 671 | if is_ubuntu; then | 
| Vincent Untz | c0482e6 | 2012-06-12 11:30:43 +0200 | [diff] [blame] | 672 | [[ "$NO_UPDATE_REPOS" = "True" ]] || apt_get update | 
|  | 673 | NO_UPDATE_REPOS=True | 
|  | 674 |  | 
| Dean Troyer | 13dc5cc | 2012-03-27 14:50:45 -0500 | [diff] [blame] | 675 | apt_get install "$@" | 
| Vincent Untz | 00011c0 | 2012-12-06 09:56:32 +0100 | [diff] [blame] | 676 | elif is_fedora; then | 
|  | 677 | yum_install "$@" | 
|  | 678 | elif is_suse; then | 
|  | 679 | zypper_install "$@" | 
| Dean Troyer | 13dc5cc | 2012-03-27 14:50:45 -0500 | [diff] [blame] | 680 | else | 
| Vincent Untz | 00011c0 | 2012-12-06 09:56:32 +0100 | [diff] [blame] | 681 | exit_distro_not_supported "installing packages" | 
| Dean Troyer | 13dc5cc | 2012-03-27 14:50:45 -0500 | [diff] [blame] | 682 | fi | 
|  | 683 | } | 
|  | 684 |  | 
|  | 685 |  | 
| Vincent Untz | 71ebc6f | 2012-06-12 13:45:15 +0200 | [diff] [blame] | 686 | # Distro-agnostic function to tell if a package is installed | 
|  | 687 | # is_package_installed package [package ...] | 
|  | 688 | function is_package_installed() { | 
|  | 689 | if [[ -z "$@" ]]; then | 
|  | 690 | return 1 | 
|  | 691 | fi | 
|  | 692 |  | 
|  | 693 | if [[ -z "$os_PACKAGE" ]]; then | 
|  | 694 | GetOSVersion | 
|  | 695 | fi | 
| Vincent Untz | c18b965 | 2012-12-04 12:36:34 +0100 | [diff] [blame] | 696 |  | 
| Vincent Untz | 71ebc6f | 2012-06-12 13:45:15 +0200 | [diff] [blame] | 697 | if [[ "$os_PACKAGE" = "deb" ]]; then | 
|  | 698 | dpkg -l "$@" > /dev/null | 
| Vincent Untz | 00011c0 | 2012-12-06 09:56:32 +0100 | [diff] [blame] | 699 | elif [[ "$os_PACKAGE" = "rpm" ]]; then | 
| Vincent Untz | 71ebc6f | 2012-06-12 13:45:15 +0200 | [diff] [blame] | 700 | rpm --quiet -q "$@" | 
| Vincent Untz | 00011c0 | 2012-12-06 09:56:32 +0100 | [diff] [blame] | 701 | else | 
|  | 702 | exit_distro_not_supported "finding if a package is installed" | 
| Vincent Untz | 71ebc6f | 2012-06-12 13:45:15 +0200 | [diff] [blame] | 703 | fi | 
|  | 704 | } | 
|  | 705 |  | 
|  | 706 |  | 
| Dean Troyer | 489bd2a | 2012-03-02 10:44:29 -0600 | [diff] [blame] | 707 | # Test if the named environment variable is set and not zero length | 
|  | 708 | # is_set env-var | 
|  | 709 | function is_set() { | 
|  | 710 | local var=\$"$1" | 
| Attila Fazekas | 251d3b5 | 2012-12-16 15:05:44 +0100 | [diff] [blame] | 711 | eval "[ -n \"$var\" ]" # For ex.: sh -c "[ -n \"$var\" ]" would be better, but several exercises depends on this | 
| Dean Troyer | 489bd2a | 2012-03-02 10:44:29 -0600 | [diff] [blame] | 712 | } | 
|  | 713 |  | 
|  | 714 |  | 
| Dean Troyer | 4a43b7b | 2012-08-28 17:43:40 -0500 | [diff] [blame] | 715 | # Wrapper for ``pip install`` to set cache and proxy environment variables | 
| Maru Newby | 3a87edd | 2012-10-25 23:01:06 +0000 | [diff] [blame] | 716 | # Uses globals ``OFFLINE``, ``PIP_DOWNLOAD_CACHE``, ``PIP_USE_MIRRORS``, | 
|  | 717 | #   ``TRACK_DEPENDS``, ``*_proxy` | 
| Dean Troyer | 7f9aa71 | 2012-01-31 12:11:56 -0600 | [diff] [blame] | 718 | # pip_install package [package ...] | 
|  | 719 | function pip_install { | 
| Dean Troyer | d0b21e2 | 2012-03-07 14:52:25 -0600 | [diff] [blame] | 720 | [[ "$OFFLINE" = "True" || -z "$@" ]] && return | 
| Dean Troyer | 13dc5cc | 2012-03-27 14:50:45 -0500 | [diff] [blame] | 721 | if [[ -z "$os_PACKAGE" ]]; then | 
|  | 722 | GetOSVersion | 
|  | 723 | fi | 
| Monty Taylor | 47f0206 | 2012-07-26 11:09:24 -0500 | [diff] [blame] | 724 | if [[ $TRACK_DEPENDS = True ]] ; then | 
|  | 725 | source $DEST/.venv/bin/activate | 
|  | 726 | CMD_PIP=$DEST/.venv/bin/pip | 
|  | 727 | SUDO_PIP="env" | 
| Dean Troyer | 13dc5cc | 2012-03-27 14:50:45 -0500 | [diff] [blame] | 728 | else | 
| Monty Taylor | 47f0206 | 2012-07-26 11:09:24 -0500 | [diff] [blame] | 729 | SUDO_PIP="sudo" | 
| Vincent Untz | 8ec2722 | 2012-11-29 09:25:31 +0100 | [diff] [blame] | 730 | CMD_PIP=$(get_pip_command) | 
| Dean Troyer | 13dc5cc | 2012-03-27 14:50:45 -0500 | [diff] [blame] | 731 | fi | 
| Maru Newby | 3a87edd | 2012-10-25 23:01:06 +0000 | [diff] [blame] | 732 | if [[ "$PIP_USE_MIRRORS" != "False" ]]; then | 
|  | 733 | PIP_MIRROR_OPT="--use-mirrors" | 
|  | 734 | fi | 
| Monty Taylor | 47f0206 | 2012-07-26 11:09:24 -0500 | [diff] [blame] | 735 | $SUDO_PIP PIP_DOWNLOAD_CACHE=${PIP_DOWNLOAD_CACHE:-/var/cache/pip} \ | 
| Dean Troyer | 7f9aa71 | 2012-01-31 12:11:56 -0600 | [diff] [blame] | 736 | HTTP_PROXY=$http_proxy \ | 
|  | 737 | HTTPS_PROXY=$https_proxy \ | 
| Osamu Habuka | 7abe4f2 | 2012-07-25 12:39:32 +0900 | [diff] [blame] | 738 | NO_PROXY=$no_proxy \ | 
| Maru Newby | 3a87edd | 2012-10-25 23:01:06 +0000 | [diff] [blame] | 739 | $CMD_PIP install $PIP_MIRROR_OPT $@ | 
| Dean Troyer | 13dc5cc | 2012-03-27 14:50:45 -0500 | [diff] [blame] | 740 | } | 
|  | 741 |  | 
|  | 742 |  | 
|  | 743 | # Service wrapper to restart services | 
|  | 744 | # restart_service service-name | 
|  | 745 | function restart_service() { | 
| Vincent Untz | c18b965 | 2012-12-04 12:36:34 +0100 | [diff] [blame] | 746 | if is_ubuntu; then | 
| Dean Troyer | 5218d45 | 2012-02-04 02:13:23 -0600 | [diff] [blame] | 747 | sudo /usr/sbin/service $1 restart | 
|  | 748 | else | 
|  | 749 | sudo /sbin/service $1 restart | 
|  | 750 | fi | 
| Dean Troyer | 13dc5cc | 2012-03-27 14:50:45 -0500 | [diff] [blame] | 751 | } | 
|  | 752 |  | 
|  | 753 |  | 
| Dean Troyer | 1573335 | 2012-09-06 11:51:30 -0500 | [diff] [blame] | 754 | # Helper to launch a service in a named screen | 
|  | 755 | # screen_it service "command-line" | 
|  | 756 | function screen_it { | 
| Dean Troyer | 1573335 | 2012-09-06 11:51:30 -0500 | [diff] [blame] | 757 | SCREEN_NAME=${SCREEN_NAME:-stack} | 
| jiajun xu | a941424 | 2012-12-06 16:30:57 +0800 | [diff] [blame] | 758 | SERVICE_DIR=${SERVICE_DIR:-${DEST}/status} | 
| Vishvananda Ishaya | 58e2134 | 2013-02-11 16:48:12 -0800 | [diff] [blame] | 759 | SCREEN_DEV=`trueorfalse True $SCREEN_DEV` | 
| jiajun xu | a941424 | 2012-12-06 16:30:57 +0800 | [diff] [blame] | 760 |  | 
| Dean Troyer | 1573335 | 2012-09-06 11:51:30 -0500 | [diff] [blame] | 761 | if is_service_enabled $1; then | 
|  | 762 | # Append the service to the screen rc file | 
|  | 763 | screen_rc "$1" "$2" | 
|  | 764 |  | 
|  | 765 | screen -S $SCREEN_NAME -X screen -t $1 | 
| Jeremy Stanley | 25ebbcd | 2013-02-17 15:45:55 +0000 | [diff] [blame] | 766 |  | 
|  | 767 | if [[ -n ${SCREEN_LOGDIR} ]]; then | 
|  | 768 | screen -S $SCREEN_NAME -p $1 -X logfile ${SCREEN_LOGDIR}/screen-${1}.${CURRENT_LOG_TIME}.log | 
|  | 769 | screen -S $SCREEN_NAME -p $1 -X log on | 
|  | 770 | ln -sf ${SCREEN_LOGDIR}/screen-${1}.${CURRENT_LOG_TIME}.log ${SCREEN_LOGDIR}/screen-${1}.log | 
|  | 771 | fi | 
|  | 772 |  | 
| Vishvananda Ishaya | 58e2134 | 2013-02-11 16:48:12 -0800 | [diff] [blame] | 773 | if [[ "$SCREEN_DEV" = "True" ]]; then | 
|  | 774 | # sleep to allow bash to be ready to be send the command - we are | 
|  | 775 | # creating a new window in screen and then sends characters, so if | 
|  | 776 | # bash isn't running by the time we send the command, nothing happens | 
|  | 777 | sleep 1.5 | 
| Dean Troyer | 1573335 | 2012-09-06 11:51:30 -0500 | [diff] [blame] | 778 |  | 
| Vishvananda Ishaya | 58e2134 | 2013-02-11 16:48:12 -0800 | [diff] [blame] | 779 | NL=`echo -ne '\015'` | 
|  | 780 | screen -S $SCREEN_NAME -p $1 -X stuff "$2 || touch \"$SERVICE_DIR/$SCREEN_NAME/$1.failure\"$NL" | 
|  | 781 | else | 
|  | 782 | screen -S $SCREEN_NAME -p $1 -X exec /bin/bash -c "$2 || touch \"$SERVICE_DIR/$SCREEN_NAME/$1.failure\"" | 
| Dean Troyer | 1573335 | 2012-09-06 11:51:30 -0500 | [diff] [blame] | 783 | fi | 
| Dean Troyer | 1573335 | 2012-09-06 11:51:30 -0500 | [diff] [blame] | 784 | fi | 
|  | 785 | } | 
|  | 786 |  | 
|  | 787 |  | 
|  | 788 | # Screen rc file builder | 
|  | 789 | # screen_rc service "command-line" | 
|  | 790 | function screen_rc { | 
|  | 791 | SCREEN_NAME=${SCREEN_NAME:-stack} | 
|  | 792 | SCREENRC=$TOP_DIR/$SCREEN_NAME-screenrc | 
|  | 793 | if [[ ! -e $SCREENRC ]]; then | 
|  | 794 | # Name the screen session | 
|  | 795 | echo "sessionname $SCREEN_NAME" > $SCREENRC | 
|  | 796 | # Set a reasonable statusbar | 
|  | 797 | echo "hardstatus alwayslastline '$SCREEN_HARDSTATUS'" >> $SCREENRC | 
|  | 798 | echo "screen -t shell bash" >> $SCREENRC | 
|  | 799 | fi | 
|  | 800 | # If this service doesn't already exist in the screenrc file | 
|  | 801 | if ! grep $1 $SCREENRC 2>&1 > /dev/null; then | 
|  | 802 | NL=`echo -ne '\015'` | 
|  | 803 | echo "screen -t $1 bash" >> $SCREENRC | 
|  | 804 | echo "stuff \"$2$NL\"" >> $SCREENRC | 
|  | 805 | fi | 
|  | 806 | } | 
|  | 807 |  | 
| jiajun xu | a941424 | 2012-12-06 16:30:57 +0800 | [diff] [blame] | 808 | # Helper to remove the *.failure files under $SERVICE_DIR/$SCREEN_NAME | 
|  | 809 | # This is used for service_check when all the screen_it are called finished | 
|  | 810 | # init_service_check | 
|  | 811 | function init_service_check() { | 
|  | 812 | SCREEN_NAME=${SCREEN_NAME:-stack} | 
|  | 813 | SERVICE_DIR=${SERVICE_DIR:-${DEST}/status} | 
|  | 814 |  | 
|  | 815 | if [[ ! -d "$SERVICE_DIR/$SCREEN_NAME" ]]; then | 
|  | 816 | mkdir -p "$SERVICE_DIR/$SCREEN_NAME" | 
|  | 817 | fi | 
|  | 818 |  | 
|  | 819 | rm -f "$SERVICE_DIR/$SCREEN_NAME"/*.failure | 
|  | 820 | } | 
|  | 821 |  | 
|  | 822 | # Helper to get the status of each running service | 
|  | 823 | # service_check | 
|  | 824 | function service_check() { | 
|  | 825 | local service | 
|  | 826 | local failures | 
|  | 827 | SCREEN_NAME=${SCREEN_NAME:-stack} | 
|  | 828 | SERVICE_DIR=${SERVICE_DIR:-${DEST}/status} | 
|  | 829 |  | 
|  | 830 |  | 
|  | 831 | if [[ ! -d "$SERVICE_DIR/$SCREEN_NAME" ]]; then | 
|  | 832 | echo "No service status directory found" | 
|  | 833 | return | 
|  | 834 | fi | 
|  | 835 |  | 
|  | 836 | # Check if there is any falure flag file under $SERVICE_DIR/$SCREEN_NAME | 
|  | 837 | failures=`ls "$SERVICE_DIR/$SCREEN_NAME"/*.failure 2>/dev/null` | 
|  | 838 |  | 
|  | 839 | for service in $failures; do | 
|  | 840 | service=`basename $service` | 
|  | 841 | service=${service::-8} | 
|  | 842 | echo "Error: Service $service is not running" | 
|  | 843 | done | 
|  | 844 |  | 
|  | 845 | if [ -n "$failures" ]; then | 
|  | 846 | echo "More details about the above errors can be found with screen, with ./rejoin-stack.sh" | 
|  | 847 | fi | 
|  | 848 | } | 
| Dean Troyer | 1573335 | 2012-09-06 11:51:30 -0500 | [diff] [blame] | 849 |  | 
| Dean Troyer | 4a43b7b | 2012-08-28 17:43:40 -0500 | [diff] [blame] | 850 | # ``pip install`` the dependencies of the package before ``setup.py develop`` | 
|  | 851 | # so pip and not distutils processes the dependency chain | 
|  | 852 | # Uses globals ``TRACK_DEPENDES``, ``*_proxy` | 
| Dean Troyer | bbafb1b | 2012-06-11 16:51:39 -0500 | [diff] [blame] | 853 | # setup_develop directory | 
|  | 854 | function setup_develop() { | 
| Monty Taylor | 47f0206 | 2012-07-26 11:09:24 -0500 | [diff] [blame] | 855 | if [[ $TRACK_DEPENDS = True ]] ; then | 
|  | 856 | SUDO_CMD="env" | 
|  | 857 | else | 
|  | 858 | SUDO_CMD="sudo" | 
|  | 859 | fi | 
| Dean Troyer | bbafb1b | 2012-06-11 16:51:39 -0500 | [diff] [blame] | 860 | (cd $1; \ | 
|  | 861 | python setup.py egg_info; \ | 
|  | 862 | raw_links=$(awk '/^.+/ {print "-f " $1}' *.egg-info/dependency_links.txt); \ | 
|  | 863 | depend_links=$(echo $raw_links | xargs); \ | 
| Dean Troyer | 1a3c9fe | 2012-09-29 17:25:02 -0500 | [diff] [blame] | 864 | require_file=$([ ! -r *-info/requires.txt ] || echo "-r *-info/requires.txt"); \ | 
|  | 865 | pip_install $require_file $depend_links; \ | 
| Monty Taylor | 47f0206 | 2012-07-26 11:09:24 -0500 | [diff] [blame] | 866 | $SUDO_CMD \ | 
| Dean Troyer | bbafb1b | 2012-06-11 16:51:39 -0500 | [diff] [blame] | 867 | HTTP_PROXY=$http_proxy \ | 
|  | 868 | HTTPS_PROXY=$https_proxy \ | 
| Osamu Habuka | 7abe4f2 | 2012-07-25 12:39:32 +0900 | [diff] [blame] | 869 | NO_PROXY=$no_proxy \ | 
| Dean Troyer | bbafb1b | 2012-06-11 16:51:39 -0500 | [diff] [blame] | 870 | python setup.py develop \ | 
|  | 871 | ) | 
|  | 872 | } | 
|  | 873 |  | 
|  | 874 |  | 
| Dean Troyer | 13dc5cc | 2012-03-27 14:50:45 -0500 | [diff] [blame] | 875 | # Service wrapper to start services | 
|  | 876 | # start_service service-name | 
|  | 877 | function start_service() { | 
| Vincent Untz | c18b965 | 2012-12-04 12:36:34 +0100 | [diff] [blame] | 878 | if is_ubuntu; then | 
| Dean Troyer | 5218d45 | 2012-02-04 02:13:23 -0600 | [diff] [blame] | 879 | sudo /usr/sbin/service $1 start | 
|  | 880 | else | 
|  | 881 | sudo /sbin/service $1 start | 
|  | 882 | fi | 
| Dean Troyer | 13dc5cc | 2012-03-27 14:50:45 -0500 | [diff] [blame] | 883 | } | 
|  | 884 |  | 
|  | 885 |  | 
|  | 886 | # Service wrapper to stop services | 
|  | 887 | # stop_service service-name | 
|  | 888 | function stop_service() { | 
| Vincent Untz | c18b965 | 2012-12-04 12:36:34 +0100 | [diff] [blame] | 889 | if is_ubuntu; then | 
| Dean Troyer | 5218d45 | 2012-02-04 02:13:23 -0600 | [diff] [blame] | 890 | sudo /usr/sbin/service $1 stop | 
|  | 891 | else | 
|  | 892 | sudo /sbin/service $1 stop | 
|  | 893 | fi | 
| Dean Troyer | 7f9aa71 | 2012-01-31 12:11:56 -0600 | [diff] [blame] | 894 | } | 
|  | 895 |  | 
|  | 896 |  | 
|  | 897 | # Normalize config values to True or False | 
| Dean Troyer | 4a43b7b | 2012-08-28 17:43:40 -0500 | [diff] [blame] | 898 | # Accepts as False: 0 no false False FALSE | 
|  | 899 | # Accepts as True: 1 yes true True TRUE | 
|  | 900 | # VAR=$(trueorfalse default-value test-value) | 
| Dean Troyer | 7f9aa71 | 2012-01-31 12:11:56 -0600 | [diff] [blame] | 901 | function trueorfalse() { | 
|  | 902 | local default=$1 | 
|  | 903 | local testval=$2 | 
|  | 904 |  | 
|  | 905 | [[ -z "$testval" ]] && { echo "$default"; return; } | 
|  | 906 | [[ "0 no false False FALSE" =~ "$testval" ]] && { echo "False"; return; } | 
|  | 907 | [[ "1 yes true True TRUE" =~ "$testval" ]] && { echo "True"; return; } | 
|  | 908 | echo "$default" | 
|  | 909 | } | 
| Dean Troyer | 27e3269 | 2012-03-16 16:16:56 -0500 | [diff] [blame] | 910 |  | 
| Dean Troyer | 13dc5cc | 2012-03-27 14:50:45 -0500 | [diff] [blame] | 911 |  | 
| Dean Troyer | ca0e3d0 | 2012-04-13 15:58:37 -0500 | [diff] [blame] | 912 | # Retrieve an image from a URL and upload into Glance | 
|  | 913 | # Uses the following variables: | 
| Dean Troyer | 4a43b7b | 2012-08-28 17:43:40 -0500 | [diff] [blame] | 914 | #   ``FILES`` must be set to the cache dir | 
|  | 915 | #   ``GLANCE_HOSTPORT`` | 
| Dean Troyer | ca0e3d0 | 2012-04-13 15:58:37 -0500 | [diff] [blame] | 916 | # upload_image image-url glance-token | 
|  | 917 | function upload_image() { | 
|  | 918 | local image_url=$1 | 
|  | 919 | local token=$2 | 
|  | 920 |  | 
|  | 921 | # Create a directory for the downloaded image tarballs. | 
|  | 922 | mkdir -p $FILES/images | 
|  | 923 |  | 
|  | 924 | # Downloads the image (uec ami+aki style), then extracts it. | 
|  | 925 | IMAGE_FNAME=`basename "$image_url"` | 
|  | 926 | if [[ ! -f $FILES/$IMAGE_FNAME || "$(stat -c "%s" $FILES/$IMAGE_FNAME)" = "0" ]]; then | 
|  | 927 | wget -c $image_url -O $FILES/$IMAGE_FNAME | 
|  | 928 | if [[ $? -ne 0 ]]; then | 
|  | 929 | echo "Not found: $image_url" | 
|  | 930 | return | 
|  | 931 | fi | 
|  | 932 | fi | 
|  | 933 |  | 
|  | 934 | # OpenVZ-format images are provided as .tar.gz, but not decompressed prior to loading | 
|  | 935 | if [[ "$image_url" =~ 'openvz' ]]; then | 
|  | 936 | IMAGE="$FILES/${IMAGE_FNAME}" | 
|  | 937 | IMAGE_NAME="${IMAGE_FNAME%.tar.gz}" | 
|  | 938 | glance --os-auth-token $token --os-image-url http://$GLANCE_HOSTPORT image-create --name "$IMAGE_NAME" --is-public=True --container-format ami --disk-format ami < "${IMAGE}" | 
|  | 939 | return | 
|  | 940 | fi | 
|  | 941 |  | 
| Davanum Srinivas | 316ed6c | 2013-02-06 15:29:49 -0500 | [diff] [blame] | 942 | # XenServer-ovf-format images are provided as .vhd.tgz as well | 
|  | 943 | # and should not be decompressed prior to loading | 
|  | 944 | if [[ "$image_url" =~ '.vhd.tgz' ]]; then | 
|  | 945 | IMAGE="$FILES/${IMAGE_FNAME}" | 
|  | 946 | IMAGE_NAME="${IMAGE_FNAME%.vhd.tgz}" | 
|  | 947 | glance --os-auth-token $token --os-image-url http://$GLANCE_HOSTPORT image-create --name "$IMAGE_NAME" --is-public=True --container-format=ovf --disk-format=vhd < "${IMAGE}" | 
|  | 948 | return | 
|  | 949 | fi | 
|  | 950 |  | 
| Dean Troyer | ca0e3d0 | 2012-04-13 15:58:37 -0500 | [diff] [blame] | 951 | KERNEL="" | 
|  | 952 | RAMDISK="" | 
|  | 953 | DISK_FORMAT="" | 
|  | 954 | CONTAINER_FORMAT="" | 
|  | 955 | UNPACK="" | 
|  | 956 | case "$IMAGE_FNAME" in | 
|  | 957 | *.tar.gz|*.tgz) | 
|  | 958 | # Extract ami and aki files | 
|  | 959 | [ "${IMAGE_FNAME%.tar.gz}" != "$IMAGE_FNAME" ] && | 
|  | 960 | IMAGE_NAME="${IMAGE_FNAME%.tar.gz}" || | 
|  | 961 | IMAGE_NAME="${IMAGE_FNAME%.tgz}" | 
|  | 962 | xdir="$FILES/images/$IMAGE_NAME" | 
|  | 963 | rm -Rf "$xdir"; | 
|  | 964 | mkdir "$xdir" | 
|  | 965 | tar -zxf $FILES/$IMAGE_FNAME -C "$xdir" | 
|  | 966 | KERNEL=$(for f in "$xdir/"*-vmlinuz* "$xdir/"aki-*/image; do | 
|  | 967 | [ -f "$f" ] && echo "$f" && break; done; true) | 
|  | 968 | RAMDISK=$(for f in "$xdir/"*-initrd* "$xdir/"ari-*/image; do | 
|  | 969 | [ -f "$f" ] && echo "$f" && break; done; true) | 
|  | 970 | IMAGE=$(for f in "$xdir/"*.img "$xdir/"ami-*/image; do | 
|  | 971 | [ -f "$f" ] && echo "$f" && break; done; true) | 
|  | 972 | if [[ -z "$IMAGE_NAME" ]]; then | 
|  | 973 | IMAGE_NAME=$(basename "$IMAGE" ".img") | 
|  | 974 | fi | 
|  | 975 | ;; | 
|  | 976 | *.img) | 
|  | 977 | IMAGE="$FILES/$IMAGE_FNAME"; | 
|  | 978 | IMAGE_NAME=$(basename "$IMAGE" ".img") | 
| Dean Troyer | 636a3ff | 2012-09-14 11:36:07 -0500 | [diff] [blame] | 979 | format=$(qemu-img info ${IMAGE} | awk '/^file format/ { print $3; exit }') | 
|  | 980 | if [[ ",qcow2,raw,vdi,vmdk,vpc," =~ ",$format," ]]; then | 
|  | 981 | DISK_FORMAT=$format | 
|  | 982 | else | 
|  | 983 | DISK_FORMAT=raw | 
|  | 984 | fi | 
| Dean Troyer | ca0e3d0 | 2012-04-13 15:58:37 -0500 | [diff] [blame] | 985 | CONTAINER_FORMAT=bare | 
|  | 986 | ;; | 
|  | 987 | *.img.gz) | 
|  | 988 | IMAGE="$FILES/${IMAGE_FNAME}" | 
|  | 989 | IMAGE_NAME=$(basename "$IMAGE" ".img.gz") | 
|  | 990 | DISK_FORMAT=raw | 
|  | 991 | CONTAINER_FORMAT=bare | 
|  | 992 | UNPACK=zcat | 
|  | 993 | ;; | 
|  | 994 | *.qcow2) | 
|  | 995 | IMAGE="$FILES/${IMAGE_FNAME}" | 
|  | 996 | IMAGE_NAME=$(basename "$IMAGE" ".qcow2") | 
|  | 997 | DISK_FORMAT=qcow2 | 
|  | 998 | CONTAINER_FORMAT=bare | 
|  | 999 | ;; | 
|  | 1000 | *) echo "Do not know what to do with $IMAGE_FNAME"; false;; | 
|  | 1001 | esac | 
|  | 1002 |  | 
|  | 1003 | if [ "$CONTAINER_FORMAT" = "bare" ]; then | 
|  | 1004 | if [ "$UNPACK" = "zcat" ]; then | 
|  | 1005 | glance --os-auth-token $token --os-image-url http://$GLANCE_HOSTPORT image-create --name "$IMAGE_NAME" --public --container-format=$CONTAINER_FORMAT --disk-format $DISK_FORMAT < <(zcat --force "${IMAGE}") | 
|  | 1006 | else | 
|  | 1007 | glance --os-auth-token $token --os-image-url http://$GLANCE_HOSTPORT image-create --name "$IMAGE_NAME" --public --container-format=$CONTAINER_FORMAT --disk-format $DISK_FORMAT < "${IMAGE}" | 
|  | 1008 | fi | 
|  | 1009 | else | 
|  | 1010 | # Use glance client to add the kernel the root filesystem. | 
|  | 1011 | # We parse the results of the first upload to get the glance ID of the | 
|  | 1012 | # kernel for use when uploading the root filesystem. | 
|  | 1013 | KERNEL_ID=""; RAMDISK_ID=""; | 
|  | 1014 | if [ -n "$KERNEL" ]; then | 
|  | 1015 | KERNEL_ID=$(glance --os-auth-token $token --os-image-url http://$GLANCE_HOSTPORT image-create --name "$IMAGE_NAME-kernel" --public --container-format aki --disk-format aki < "$KERNEL" | grep ' id ' | get_field 2) | 
|  | 1016 | fi | 
|  | 1017 | if [ -n "$RAMDISK" ]; then | 
|  | 1018 | RAMDISK_ID=$(glance --os-auth-token $token --os-image-url http://$GLANCE_HOSTPORT image-create --name "$IMAGE_NAME-ramdisk" --public --container-format ari --disk-format ari < "$RAMDISK" | grep ' id ' | get_field 2) | 
|  | 1019 | fi | 
|  | 1020 | glance --os-auth-token $token --os-image-url http://$GLANCE_HOSTPORT image-create --name "${IMAGE_NAME%.img}" --public --container-format ami --disk-format ami ${KERNEL_ID:+--property kernel_id=$KERNEL_ID} ${RAMDISK_ID:+--property ramdisk_id=$RAMDISK_ID} < "${IMAGE}" | 
|  | 1021 | fi | 
|  | 1022 | } | 
|  | 1023 |  | 
| Dean Troyer | c1b486a | 2012-11-05 14:26:09 -0600 | [diff] [blame] | 1024 | # Set the database backend to use | 
|  | 1025 | # When called from stackrc/localrc DATABASE_BACKENDS has not been | 
|  | 1026 | # initialized yet, just save the configuration selection and call back later | 
|  | 1027 | # to validate it. | 
|  | 1028 | #  $1 The name of the database backend to use (mysql, postgresql, ...) | 
|  | 1029 | function use_database { | 
|  | 1030 | if [[ -z "$DATABASE_BACKENDS" ]]; then | 
| Dean Troyer | afc29fe | 2013-02-07 15:56:24 -0600 | [diff] [blame] | 1031 | # No backends registered means this is likely called from ``localrc`` | 
|  | 1032 | # This is now deprecated usage | 
| Dean Troyer | c1b486a | 2012-11-05 14:26:09 -0600 | [diff] [blame] | 1033 | DATABASE_TYPE=$1 | 
| Bob Ball | 3aa8887 | 2013-02-28 17:39:41 +0000 | [diff] [blame] | 1034 | DEPRECATED_TEXT="$DEPRECATED_TEXT\nThe database backend needs to be properly set in ENABLED_SERVICES; use_database is deprecated localrc\n" | 
| Attila Fazekas | 251d3b5 | 2012-12-16 15:05:44 +0100 | [diff] [blame] | 1035 | else | 
| Dean Troyer | afc29fe | 2013-02-07 15:56:24 -0600 | [diff] [blame] | 1036 | # This should no longer get called...here for posterity | 
| Attila Fazekas | 251d3b5 | 2012-12-16 15:05:44 +0100 | [diff] [blame] | 1037 | use_exclusive_service DATABASE_BACKENDS DATABASE_TYPE $1 | 
| Dean Troyer | c1b486a | 2012-11-05 14:26:09 -0600 | [diff] [blame] | 1038 | fi | 
| Dean Troyer | c1b486a | 2012-11-05 14:26:09 -0600 | [diff] [blame] | 1039 | } | 
|  | 1040 |  | 
| Terry Wilson | 428af5a | 2012-11-01 16:12:39 -0400 | [diff] [blame] | 1041 | # Toggle enable/disable_service for services that must run exclusive of each other | 
|  | 1042 | #  $1 The name of a variable containing a space-separated list of services | 
|  | 1043 | #  $2 The name of a variable in which to store the enabled service's name | 
|  | 1044 | #  $3 The name of the service to enable | 
|  | 1045 | function use_exclusive_service { | 
|  | 1046 | local options=${!1} | 
|  | 1047 | local selection=$3 | 
|  | 1048 | out=$2 | 
|  | 1049 | [ -z $selection ] || [[ ! "$options" =~ "$selection" ]] && return 1 | 
|  | 1050 | for opt in $options;do | 
|  | 1051 | [[ "$opt" = "$selection" ]] && enable_service $opt || disable_service $opt | 
|  | 1052 | done | 
|  | 1053 | eval "$out=$selection" | 
|  | 1054 | return 0 | 
|  | 1055 | } | 
| Dean Troyer | ca0e3d0 | 2012-04-13 15:58:37 -0500 | [diff] [blame] | 1056 |  | 
| Dean Troyer | 3a3a2ba | 2012-12-11 15:26:24 -0600 | [diff] [blame] | 1057 | # Wait for an HTTP server to start answering requests | 
|  | 1058 | # wait_for_service timeout url | 
|  | 1059 | function wait_for_service() { | 
|  | 1060 | local timeout=$1 | 
|  | 1061 | local url=$2 | 
|  | 1062 | timeout $timeout sh -c "while ! http_proxy= https_proxy= curl -s $url >/dev/null; do sleep 1; done" | 
|  | 1063 | } | 
|  | 1064 |  | 
| Dean Troyer | 4a43b7b | 2012-08-28 17:43:40 -0500 | [diff] [blame] | 1065 | # Wrapper for ``yum`` to set proxy environment variables | 
|  | 1066 | # Uses globals ``OFFLINE``, ``*_proxy` | 
| Dean Troyer | 13dc5cc | 2012-03-27 14:50:45 -0500 | [diff] [blame] | 1067 | # yum_install package [package ...] | 
|  | 1068 | function yum_install() { | 
|  | 1069 | [[ "$OFFLINE" = "True" ]] && return | 
|  | 1070 | local sudo="sudo" | 
|  | 1071 | [[ "$(id -u)" = "0" ]] && sudo="env" | 
|  | 1072 | $sudo http_proxy=$http_proxy https_proxy=$https_proxy \ | 
| Osamu Habuka | 7abe4f2 | 2012-07-25 12:39:32 +0900 | [diff] [blame] | 1073 | no_proxy=$no_proxy \ | 
| Dean Troyer | 13dc5cc | 2012-03-27 14:50:45 -0500 | [diff] [blame] | 1074 | yum install -y "$@" | 
|  | 1075 | } | 
|  | 1076 |  | 
| Nachi Ueno | fda946e | 2012-10-24 17:26:02 -0700 | [diff] [blame] | 1077 | # ping check | 
|  | 1078 | # Uses globals ``ENABLED_SERVICES`` | 
|  | 1079 | function ping_check() { | 
| Nachi Ueno | 5db5bfa | 2012-10-29 11:25:29 -0700 | [diff] [blame] | 1080 | if is_service_enabled quantum; then | 
|  | 1081 | _ping_check_quantum  "$1" $2 $3 $4 | 
|  | 1082 | return | 
|  | 1083 | fi | 
|  | 1084 | _ping_check_novanet "$1" $2 $3 $4 | 
| Nachi Ueno | fda946e | 2012-10-24 17:26:02 -0700 | [diff] [blame] | 1085 | } | 
|  | 1086 |  | 
|  | 1087 | # ping check for nova | 
|  | 1088 | # Uses globals ``MULTI_HOST``, ``PRIVATE_NETWORK`` | 
|  | 1089 | function _ping_check_novanet() { | 
|  | 1090 | local from_net=$1 | 
|  | 1091 | local ip=$2 | 
|  | 1092 | local boot_timeout=$3 | 
| Nachi Ueno | 5db5bfa | 2012-10-29 11:25:29 -0700 | [diff] [blame] | 1093 | local expected=${4:-"True"} | 
|  | 1094 | local check_command="" | 
| Nachi Ueno | fda946e | 2012-10-24 17:26:02 -0700 | [diff] [blame] | 1095 | MULTI_HOST=`trueorfalse False $MULTI_HOST` | 
|  | 1096 | if [[ "$MULTI_HOST" = "True" && "$from_net" = "$PRIVATE_NETWORK_NAME" ]]; then | 
|  | 1097 | sleep $boot_timeout | 
|  | 1098 | return | 
|  | 1099 | fi | 
| Nachi Ueno | 5db5bfa | 2012-10-29 11:25:29 -0700 | [diff] [blame] | 1100 | if [[ "$expected" = "True" ]]; then | 
|  | 1101 | check_command="while ! ping -c1 -w1 $ip; do sleep 1; done" | 
|  | 1102 | else | 
|  | 1103 | check_command="while ping -c1 -w1 $ip; do sleep 1; done" | 
|  | 1104 | fi | 
|  | 1105 | if ! timeout $boot_timeout sh -c "$check_command"; then | 
|  | 1106 | if [[ "$expected" = "True" ]]; then | 
| Nachi Ueno | 07115eb | 2013-02-26 12:38:18 -0800 | [diff] [blame] | 1107 | die $LINENO "[Fail] Couldn't ping server" | 
| Nachi Ueno | 5db5bfa | 2012-10-29 11:25:29 -0700 | [diff] [blame] | 1108 | else | 
| Nachi Ueno | 07115eb | 2013-02-26 12:38:18 -0800 | [diff] [blame] | 1109 | die $LINENO "[Fail] Could ping server" | 
| Nachi Ueno | 5db5bfa | 2012-10-29 11:25:29 -0700 | [diff] [blame] | 1110 | fi | 
| Nachi Ueno | fda946e | 2012-10-24 17:26:02 -0700 | [diff] [blame] | 1111 | exit 1 | 
|  | 1112 | fi | 
|  | 1113 | } | 
|  | 1114 |  | 
|  | 1115 | # ssh check | 
| Nachi Ueno | 5db5bfa | 2012-10-29 11:25:29 -0700 | [diff] [blame] | 1116 |  | 
| Nachi Ueno | fda946e | 2012-10-24 17:26:02 -0700 | [diff] [blame] | 1117 | function ssh_check() { | 
| Nachi Ueno | 5db5bfa | 2012-10-29 11:25:29 -0700 | [diff] [blame] | 1118 | if is_service_enabled quantum; then | 
|  | 1119 | _ssh_check_quantum  "$1" $2 $3 $4 $5 | 
|  | 1120 | return | 
|  | 1121 | fi | 
|  | 1122 | _ssh_check_novanet "$1" $2 $3 $4 $5 | 
|  | 1123 | } | 
|  | 1124 |  | 
|  | 1125 | function _ssh_check_novanet() { | 
| Nachi Ueno | fda946e | 2012-10-24 17:26:02 -0700 | [diff] [blame] | 1126 | local NET_NAME=$1 | 
|  | 1127 | local KEY_FILE=$2 | 
|  | 1128 | local FLOATING_IP=$3 | 
|  | 1129 | local DEFAULT_INSTANCE_USER=$4 | 
|  | 1130 | local ACTIVE_TIMEOUT=$5 | 
| Dean Troyer | 6931c13 | 2012-11-07 16:51:21 -0600 | [diff] [blame] | 1131 | local probe_cmd="" | 
| Nachi Ueno | fda946e | 2012-10-24 17:26:02 -0700 | [diff] [blame] | 1132 | if ! timeout $ACTIVE_TIMEOUT sh -c "while ! ssh -o StrictHostKeyChecking=no -i $KEY_FILE ${DEFAULT_INSTANCE_USER}@$FLOATING_IP echo success ; do sleep 1; done"; then | 
| Nachi Ueno | 07115eb | 2013-02-26 12:38:18 -0800 | [diff] [blame] | 1133 | die $LINENO "server didn't become ssh-able!" | 
| Nachi Ueno | fda946e | 2012-10-24 17:26:02 -0700 | [diff] [blame] | 1134 | fi | 
|  | 1135 | } | 
| Dean Troyer | 13dc5cc | 2012-03-27 14:50:45 -0500 | [diff] [blame] | 1136 |  | 
| Vincent Untz | 856a11e | 2012-11-21 16:04:12 +0100 | [diff] [blame] | 1137 |  | 
|  | 1138 | # zypper wrapper to set arguments correctly | 
|  | 1139 | # zypper_install package [package ...] | 
|  | 1140 | function zypper_install() { | 
|  | 1141 | [[ "$OFFLINE" = "True" ]] && return | 
|  | 1142 | local sudo="sudo" | 
|  | 1143 | [[ "$(id -u)" = "0" ]] && sudo="env" | 
|  | 1144 | $sudo http_proxy=$http_proxy https_proxy=$https_proxy \ | 
|  | 1145 | zypper --non-interactive install --auto-agree-with-licenses "$@" | 
|  | 1146 | } | 
|  | 1147 |  | 
|  | 1148 |  | 
|  | 1149 | # Add a user to a group. | 
|  | 1150 | # add_user_to_group user group | 
|  | 1151 | function add_user_to_group() { | 
|  | 1152 | local user=$1 | 
|  | 1153 | local group=$2 | 
|  | 1154 |  | 
|  | 1155 | if [[ -z "$os_VENDOR" ]]; then | 
|  | 1156 | GetOSVersion | 
|  | 1157 | fi | 
|  | 1158 |  | 
|  | 1159 | # SLE11 and openSUSE 12.2 don't have the usual usermod | 
|  | 1160 | if ! is_suse || [[ "$os_VENDOR" = "openSUSE" && "$os_RELEASE" != "12.2" ]]; then | 
|  | 1161 | sudo usermod -a -G "$group" "$user" | 
|  | 1162 | else | 
|  | 1163 | sudo usermod -A "$group" "$user" | 
|  | 1164 | fi | 
|  | 1165 | } | 
|  | 1166 |  | 
|  | 1167 |  | 
| Jakub Ruzicka | 4196d55 | 2013-01-30 15:35:54 +0100 | [diff] [blame] | 1168 | # Get the path to the direcotry where python executables are installed. | 
|  | 1169 | # get_python_exec_prefix | 
|  | 1170 | function get_python_exec_prefix() { | 
|  | 1171 | if is_fedora; then | 
|  | 1172 | echo "/usr/bin" | 
|  | 1173 | else | 
|  | 1174 | echo "/usr/local/bin" | 
|  | 1175 | fi | 
|  | 1176 | } | 
|  | 1177 |  | 
| Vincent Untz | 856a11e | 2012-11-21 16:04:12 +0100 | [diff] [blame] | 1178 | # Get the location of the $module-rootwrap executables, where module is cinder | 
|  | 1179 | # or nova. | 
|  | 1180 | # get_rootwrap_location module | 
|  | 1181 | function get_rootwrap_location() { | 
|  | 1182 | local module=$1 | 
|  | 1183 |  | 
| Jakub Ruzicka | 4196d55 | 2013-01-30 15:35:54 +0100 | [diff] [blame] | 1184 | echo "$(get_python_exec_prefix)/$module-rootwrap" | 
| Vincent Untz | 856a11e | 2012-11-21 16:04:12 +0100 | [diff] [blame] | 1185 | } | 
|  | 1186 |  | 
| Vincent Untz | 8ec2722 | 2012-11-29 09:25:31 +0100 | [diff] [blame] | 1187 | # Get the path to the pip command. | 
|  | 1188 | # get_pip_command | 
|  | 1189 | function get_pip_command() { | 
| Vincent Untz | 00011c0 | 2012-12-06 09:56:32 +0100 | [diff] [blame] | 1190 | if is_fedora; then | 
| Nikhil Manchanda | 35138ed | 2013-01-03 17:49:58 -0800 | [diff] [blame] | 1191 | which pip-python | 
| Vincent Untz | 00011c0 | 2012-12-06 09:56:32 +0100 | [diff] [blame] | 1192 | else | 
| Nikhil Manchanda | 35138ed | 2013-01-03 17:49:58 -0800 | [diff] [blame] | 1193 | which pip | 
| Vincent Untz | 8ec2722 | 2012-11-29 09:25:31 +0100 | [diff] [blame] | 1194 | fi | 
|  | 1195 | } | 
| Vincent Untz | 856a11e | 2012-11-21 16:04:12 +0100 | [diff] [blame] | 1196 |  | 
| Dean Troyer | 27e3269 | 2012-03-16 16:16:56 -0500 | [diff] [blame] | 1197 | # Restore xtrace | 
| Chmouel Boudjnah | 408b009 | 2012-03-15 23:21:55 +0000 | [diff] [blame] | 1198 | $XTRACE | 
| Dean Troyer | 4a43b7b | 2012-08-28 17:43:40 -0500 | [diff] [blame] | 1199 |  | 
|  | 1200 |  | 
|  | 1201 | # Local variables: | 
|  | 1202 | # -*- mode: Shell-script -*- | 
| Andrew Laski | f900bd7 | 2012-09-05 17:23:14 -0400 | [diff] [blame] | 1203 | # End: |