Fix new shellcheck errors caught by latest version 56/58556/2
authorDaniel Farrell <dfarrell@redhat.com>
Thu, 8 Jun 2017 22:22:02 +0000 (18:22 -0400)
committerDaniel Farrell <dfarrell@redhat.com>
Fri, 9 Jun 2017 08:24:04 +0000 (04:24 -0400)
Main new shellcheck rule is related to exiting if cd commands fail. Add
or conditions to exit if they do, per recommendations.

Also make a few shellcheck ignores more explicit.

Change-Id: Ic8e290c1a75891b47b7aa874fe9cff0c3e9fd720
Signed-off-by: Daniel Farrell <dfarrell@redhat.com>
docker/openstack/compute/start.sh
tutorials/cluster-nodes/scripts/setup_cluster.sh
tutorials/cluster-nodes/scripts/setup_odl.sh

index f8a15e6c34ac690bf69aa70f53cc6ff1d384f962..9341a40d92256000aac849b90f37dcf4f48421d8 100755 (executable)
@@ -30,7 +30,7 @@ ip=`/sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1`
 #sudo service openvswitch-switch start
 
 # set the correct branch in devstack
-cd $DEVSTACK_HOME
+cd $DEVSTACK_HOME || exit
 git fetch
 git checkout -b ${BRANCH_NAME} -t ${TAG_NAME}
 
index 004db69232aae19c82edc85bb85ebd46dd0ea195..1b123795015d801c38008fd8a7f77211b108ee20 100755 (executable)
 # distribution to deploy on the nodes, or will download it, and it will
 # trigger vagrant or docker to build the cluster.
 
-# noqa ShellCheckBear
+# shellcheck disable=SC2039
 SCRIPTS="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
 ROOT="$( cd "$SCRIPTS" && cd .. && pwd)"
 
 setup_env() {
+    # shellcheck disable=SC1090
     . $SCRIPTS/config.properties
     export NUM_OF_NODES=$NUM_OF_NODES
     echo "Cluster will be deployed using $ODL_VERSION."
@@ -35,7 +36,7 @@ dowload_odl() {
 
 setup_odl() {
     env_banner
-    cd $ROOT/opendaylight
+    cd $ROOT/opendaylight || exit
 
     # for the OSX users, know that BSD-sed doesn't work the same as GNU-sed, hence this command won't work.
     # see http://stackoverflow.com/a/27834828/6937994
@@ -50,7 +51,7 @@ setup_odl() {
 
 spwan_vms() {
     env_banner
-    cd $ROOT
+    cd $ROOT || exit
     vagrant destroy -f
     vagrant up
 }
index 1e63452dc4efae5cda44087f6001544fbf7bfc8b..6b686e0951884319eb121d4b81b7fe9e637cdc46 100755 (executable)
 # Shard configuration:
 # see (configure-cluster-ipdetect.sh)[https://github.com/opendaylight/integration-distribution/blob/release/boron-sr2/distribution-karaf/src/main/assembly/bin/configure-cluster-ipdetect.sh]
 
-# noqa ShellCheckBear
+# shellcheck disable=SC2039
 SCRIPTS="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
 
+# shellcheck disable=SC1090
 . $SCRIPTS/config.properties
 
 install_packages() {
@@ -33,7 +34,7 @@ install_packages() {
 }
 
 start_odl() {
-    cd $HOME/opendaylight
+    cd $HOME/opendaylight || exit
 
     seed_nodes=""
     for i in $(seq $NUM_OF_NODES)