Browse code

Re-order stack.sh 2: target dir setup

Part 2 of a series

Re-order the setup and check bits in the top portion of stack.sh to
have a logical flow with similar things done together.

No behaviour changes are intended aside from the order of execution.
Any such changes are bugs.

* Consolidate DEST dir setup
* Move rpc & database init to just before project init

Change-Id: I2af1d4ed32ec34417c04592bf94fe645bb97f831

Dean Troyer authored on 2014/07/26 00:33:21
Showing 1 changed files
... ...
@@ -109,7 +109,7 @@ fi
109 109
 
110 110
 
111 111
 # Global Settings
112
-# ===============
112
+# ---------------
113 113
 
114 114
 # Check for a ``localrc`` section embedded in ``local.conf`` and extract if
115 115
 # ``localrc`` does not already exist
... ...
@@ -165,20 +165,11 @@ source $TOP_DIR/stackrc
165 165
 # Make sure the proxy config is visible to sub-processes
166 166
 export_proxy_variables
167 167
 
168
-# Destination path for installation ``DEST``
169
-DEST=${DEST:-/opt/stack}
170
-
171
-
172
-# Import common services (database, message queue) configuration
173
-source $TOP_DIR/lib/database
174
-source $TOP_DIR/lib/rpc_backend
175
-
176 168
 # Remove services which were negated in ENABLED_SERVICES
177 169
 # using the "-" prefix (e.g., "-rabbit") instead of
178 170
 # calling disable_service().
179 171
 disable_negated_services
180 172
 
181
-
182 173
 # Look for obsolete stuff
183 174
 if [[ ,${ENABLED_SERVICES}, =~ ,"swift", ]]; then
184 175
     echo "FATAL: 'swift' is not supported as a service name"
... ...
@@ -187,6 +178,8 @@ if [[ ,${ENABLED_SERVICES}, =~ ,"swift", ]]; then
187 187
     exit 1
188 188
 fi
189 189
 
190
+# Set up logging level
191
+VERBOSE=$(trueorfalse True $VERBOSE)
190 192
 
191 193
 # Configure sudo
192 194
 # --------------
... ...
@@ -209,8 +202,9 @@ chmod 0440 $TEMPFILE
209 209
 sudo chown root:root $TEMPFILE
210 210
 sudo mv $TEMPFILE /etc/sudoers.d/50_stack_sh
211 211
 
212
-# Additional repos
213
-# ----------------
212
+
213
+# Configure Distro Repositories
214
+# -----------------------------
214 215
 
215 216
 # For debian/ubuntu make apt attempt to retry network ops on it's own
216 217
 if is_ubuntu; then
... ...
@@ -252,8 +246,12 @@ if [[ is_fedora && $DISTRO =~ (rhel) ]]; then
252 252
 
253 253
 fi
254 254
 
255
-# Filesystem setup
256
-# ----------------
255
+
256
+# Configure Target Directories
257
+# ----------------------------
258
+
259
+# Destination path for installation ``DEST``
260
+DEST=${DEST:-/opt/stack}
257 261
 
258 262
 # Create the destination directory and ensure it is writable by the user
259 263
 # and read/executable by everybody for daemons (e.g. apache run for horizon)
... ...
@@ -264,6 +262,12 @@ safe_chmod 0755 $DEST
264 264
 # a basic test for $DEST path permissions (fatal on error unless skipped)
265 265
 check_path_perm_sanity ${DEST}
266 266
 
267
+# Destination path for service data
268
+DATA_DIR=${DATA_DIR:-${DEST}/data}
269
+sudo mkdir -p $DATA_DIR
270
+safe_chown -R $STACK_USER $DATA_DIR
271
+
272
+# Configure proper hostname
267 273
 # Certain services such as rabbitmq require that the local hostname resolves
268 274
 # correctly.  Make sure it exists in /etc/hosts so that is always true.
269 275
 LOCAL_HOSTNAME=`hostname -s`
... ...
@@ -271,11 +275,6 @@ if [ -z "`grep ^127.0.0.1 /etc/hosts | grep $LOCAL_HOSTNAME`" ]; then
271 271
     sudo sed -i "s/\(^127.0.0.1.*\)/\1 $LOCAL_HOSTNAME/" /etc/hosts
272 272
 fi
273 273
 
274
-# Destination path for service data
275
-DATA_DIR=${DATA_DIR:-${DEST}/data}
276
-sudo mkdir -p $DATA_DIR
277
-safe_chown -R $STACK_USER $DATA_DIR
278
-
279 274
 
280 275
 # Common Configuration
281 276
 # --------------------
... ...
@@ -327,6 +326,14 @@ SERVICE_TIMEOUT=${SERVICE_TIMEOUT:-60}
327 327
 SSL_BUNDLE_FILE="$DATA_DIR/ca-bundle.pem"
328 328
 rm -f $SSL_BUNDLE_FILE
329 329
 
330
+# Import common services (database, message queue) configuration
331
+source $TOP_DIR/lib/database
332
+source $TOP_DIR/lib/rpc_backend
333
+
334
+# Make sure we only have one rpc backend enabled,
335
+# and the specified rpc backend is available on your platform.
336
+check_rpc_backend
337
+
330 338
 
331 339
 # Configure Projects
332 340
 # ==================