Skip to content

Commit 535b61a

Browse files
committed
Moved check for valid zone config file to beginning.
1 parent 3c11e25 commit 535b61a

1 file changed

Lines changed: 11 additions & 12 deletions

File tree

scripts/install_management_node.sh

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
# Installs all the packages that a TryStack management node requires
44
# and sets up the basic DHCP server, netboot install server and
55
# Chef Server
6+
SCRIPTS_DIR=$(cd $(dirname "$0") && pwd)
7+
ROOT_DIR=$(cd $SCRIPTS_DIR/../ && pwd)
8+
VAR_DIR=$(cd $ROOT_DIR/var && pwd)
9+
ETC_DIR=$(cd $ROOT_DIR/etc && pwd)
10+
PRECISE_DOWNLOAD_URI="http://www.ubuntu.com/start-download?distro=server&bits=64&release=precise"
611

712
if [ ! $USER == "root" ]; then
813
echo "Please run this script as root. Exiting."
@@ -18,15 +23,15 @@ if [ -z $ZONE_ID ]; then
1823
ZONE_ID=$1
1924
fi
2025

26+
NODE_INFO_FILE=$VAR_DIR/zones/${ZONE_ID,,}.info
27+
if [ ! -f $NODE_INFO_FILE ]; then
28+
echo "Could not locate node info file for zone $ZONE_ID. Expected $NODE_INFO_FILE."
29+
exit 1
30+
fi
31+
2132
# Exit on error to stop unexpected errors
2233
set -o errexit
2334

24-
SCRIPTS_DIR=$(cd $(dirname "$0") && pwd)
25-
ROOT_DIR=$(cd $SCRIPTS_DIR/../ && pwd)
26-
VAR_DIR=$(cd $ROOT_DIR/var && pwd)
27-
ETC_DIR=$(cd $ROOT_DIR/etc && pwd)
28-
PRECISE_DOWNLOAD_URI="http://www.ubuntu.com/start-download?distro=server&bits=64&release=precise"
29-
3035
# Create the images download and mount directories
3136
IMAGES_DIR=$ROOT_DIR/images
3237
if [[ ! -d $IMAGES_DIR ]]; then
@@ -80,12 +85,6 @@ umount $PRECISE_MNT_PATH
8085
# and other things are set up on individual service nodes
8186
cobbler profile add --name=service_node --distro=precise-x86_64
8287

83-
# In bash ${VAR,,} will lowercase VAR
84-
NODE_INFO_FILE=$VAR_DIR/zones/${ZONE_ID,,}.info
85-
if [ ! -f $NODE_INFO_FILE ]; then
86-
die "Could not locate node info file for zone $ZONE_ID. Expected $NODE_INFO_FILE."
87-
fi
88-
8988
# Create a record in Cobbler for each service node in the zone
9089
OIFS=$IFS
9190
IFS=$'\n'

0 commit comments

Comments
 (0)