Enable shellcheck linting, fix problems 14/53814/2
authorDaniel Farrell <dfarrell@redhat.com>
Fri, 24 Mar 2017 20:07:01 +0000 (16:07 -0400)
committerDaniel Farrell <dfarrell@redhat.com>
Mon, 27 Mar 2017 16:43:56 +0000 (12:43 -0400)
Change-Id: I5043e5b2c700dab5de82ff37c698dc5dcf17e2cf
Signed-off-by: Daniel Farrell <dfarrell@redhat.com>
.coafile
docker/openstack/compute/build_compute.sh
docker/openstack/compute/run_compute.sh
docker/openstack/key-value/start_key_value_server.sh
docker/openstack/key-value/stop_key_key_value_server.sh
puppet/puppet-opendaylight
rpm/connect.sh
tutorials/cluster-nodes/scripts/setup_cluster.sh
tutorials/cluster-nodes/scripts/setup_odl.sh

index 5c65f4cce277aedc51983494538ee29bf4db1e45..0105a923a7591ca269816152fab7d92e23e70bd4 100644 (file)
--- a/.coafile
+++ b/.coafile
@@ -24,7 +24,7 @@ default_actions = JSONFormatBear: ApplyPatchAction
 
 [shellcheck]
 bears = ShellCheckBear
-#files = **/*.sh
+files = ./**/*.sh
 
 [python]
 bears = PyUnusedCodeBear
index d79269a0f974715ca59e56bbcb893a6d0e5618b6..757f2702dedbc09476043d21c60e114d8d936ef2 100755 (executable)
@@ -12,17 +12,19 @@ DOCKERFILE=Dockerfile
 
 echo "Building $IMAGE_NAME from Dockerfile=$DOCKERFILE at $(date) ... "
 docker build -t ${IMAGE_NAME} -f ${DOCKERFILE} \
+# noqa ShellCheckBear
     --build-arg http_proxy=$http_proxy --build-arg https_proxy=$https_proxy .
 
 if [ $? = 0 ] ; then
     PROXIES=""
     if [ -n "$http_proxy" ] ; then
+        # noqa ShellCheckBear
         PROXIES="--env http_proxy=$http_proxy --env https_proxy=$https_proxy --env no_proxy=$no_proxy"
     fi
-    echo -e "\nDocker image $IMAGE_NAME built successfully.\n"
+    echo "Docker image $IMAGE_NAME built successfully."
     docker images $IMAGE_NAME
-    echo -e "\nYou can launch it with the following example command:\n"
-    echo -e "  docker run -it --rm $PROXIES $IMAGE_NAME bash\n"
+    echo "You can launch it with the following example command:"
+    echo "  docker run -it --rm $PROXIES $IMAGE_NAME bash"
 else
     echo "An error occurred during the build of $IMAGE_NAME"
 fi
index ea86f34b276eefc0fe3b13c8bb0b5b6d763abf03..be82df0d23ae3fcd94d2751cb1d09ac713e9c86c 100755 (executable)
@@ -30,6 +30,7 @@ _no_proxy=localhost,10.0.0.0/8,192.168.0.0/16,172.17.0.0/16,127.0.0.1,127.0.0.0/
 #    COMMAND="$1"
 #fi
 
+# noqa ShellCheckBear
 SERVICE_NODE_NAME="service-node"
 # check to see that service-node is running first and get its IP from Docker
 SERVICE_NODE_IP=$(docker inspect -f "{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}" service-node)
@@ -39,7 +40,9 @@ if [ -z "$SERVICE_NODE_IP" ] ; then
 fi
 SERV_HOST=$SERVICE_NODE_IP
 docker run -dit --name ${NAME} --hostname ${NAME} \
+    # noqa ShellCheckBear
     --env http_proxy=$http_proxy --env https_proxy=$https_proxy \
+    # noqa ShellCheckBear
     --env no_proxy=$_no_proxy \
     --env ODL_NETWORK=$ODL_NETWORK \
     --env STACK_PASS=$STACK_PASS \
index f996d6051f948f4bc7092bf54e377f91e4e5512d..b6cd3493dc114764c399f943076818b6f6cd9415 100755 (executable)
@@ -6,7 +6,8 @@ _image=progrium/consul
 docker run -d -p 8500:8500 -h $_hostname --name $_container_name \
     $_image -server -bootstrap
 
-export _consul_IP=$( docker inspect -f '{{.NetworkSettings.IPAddress}}' consul)
+_consul_IP=$( docker inspect -f '{{.NetworkSettings.IPAddress}}' consul)
+export _consul_IP
 
 echo "Consul key-value server is now running at $_consul_IP:8500"
 docker ps | grep $_container_name
index c69483911b04123b1f52ff9c01b8fb548cc28b1e..ff186ae80753049baf03de1e313f5c54543c1c4b 100755 (executable)
@@ -1,7 +1,6 @@
 #!/bin/bash
 _hostname=consul
 _container_name=$_hostname
-_image=progrium/consul
 
 docker stop $_container_name
 
index e2a26e2629015b356f997b1bf4e4c8d6533ce3e5..d090f21da61fec48470a32c35036eab78139b101 160000 (submodule)
@@ -1 +1 @@
-Subproject commit e2a26e2629015b356f997b1bf4e4c8d6533ce3e5
+Subproject commit d090f21da61fec48470a32c35036eab78139b101
index d99f407a75f9585c20ee1331041572c936a570d7..c64f145d4d2e58aa3f1d182b371b1dc01846f985 100755 (executable)
@@ -5,7 +5,7 @@
 KARAF_SHELL_PORT=8101
 
 # This could be done with public key crypto, but sshpass is easier
-if ! command -v sshpass &> /dev/null; then
+if ! command -v sshpass >/dev/null 2>&1 /dev/null; then
     echo "Installing sshpass. It's used connecting non-interactively"
     if ! sudo yum install -y sshpass; then
         echo "Couldn't find sshpass pkg, trying to install EPEL"
index d309cf2d621fa5f59334b6d82231902ec0f8f7da..004db69232aae19c82edc85bb85ebd46dd0ea195 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
 SCRIPTS="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
 ROOT="$( cd "$SCRIPTS" && cd .. && pwd)"
 
-function setup_env {
-    source $SCRIPTS/config.properties
+setup_env() {
+    . $SCRIPTS/config.properties
     export NUM_OF_NODES=$NUM_OF_NODES
     echo "Cluster will be deployed using $ODL_VERSION."
     echo "The cluster will have $NUM_OF_NODES nodes."
 }
 
-function dowload_odl {
+dowload_odl() {
     if [ ! -d "$ROOT/opendaylight" ]; then
         echo "Download OpenDaylight distribution"
         mkdir opendaylight
@@ -32,7 +33,7 @@ function dowload_odl {
     fi
 }
 
-function setup_odl {
+setup_odl() {
     env_banner
     cd $ROOT/opendaylight
 
@@ -47,23 +48,24 @@ function setup_odl {
     # the custom_shard_config.txt located under /bin
 }
 
-function spwan_vms {
+spwan_vms() {
     env_banner
     cd $ROOT
     vagrant destroy -f
     vagrant up
 }
 
-function spwan_containers {
+spwan_containers() {
     env_banner
     # create docker network specific to ODL cluster
-    if [ `docker network ls | grep -w odl-cluster-network | wc -l | xargs echo ` == 0 ]; then
+    if [ "`docker network ls | grep -w odl-cluster-network | wc -l | xargs echo `" = 0 ]; then
         echo "Docker network for OpenDaylight don't exist - creating ..."
         docker network create -o com.docker.network.bridge.enable_icc=true -o com.docker.network.bridge.enable_ip_masquerade=true --subnet 192.168.50.0/24 --gateway 192.168.50.1  odl-cluster-network
     fi
 
     # create all the containers
     MAX=$NUM_OF_NODES
+    # noqa ShellCheckBear
     for ((i=1; i<=MAX; i++))
     do
         export NODE_NUMBER=$i
@@ -72,7 +74,7 @@ function spwan_containers {
     done
 }
 
-function prerequisites {
+prerequisites() {
     cat <<EOF
 ################################################
 ##              Setup environment             ##
@@ -95,7 +97,7 @@ EOF
     setup_odl
 }
 
-function env_banner {
+env_banner() {
 cat <<EOF
 ################################################
 ##             Spawn cluster nodes            ##
@@ -103,7 +105,7 @@ cat <<EOF
 EOF
 }
 
-function end_banner {
+end_banner() {
 cat <<EOF
 ################################################
 ##          Your environment is setup         ##
@@ -132,10 +134,10 @@ if [ -z $p ]; then
     usage
 fi
 
-if [ $p == "docker" ]; then
+if [ $p = "docker" ]; then
     prerequisites
     spwan_containers
-elif [ $p == "vagrant" ]; then
+elif [ $p = "vagrant" ]; then
     prerequisites
     spwan_vms
 else
index db5c1559b105071d0a4f5081957a449822441037..1e63452dc4efae5cda44087f6001544fbf7bfc8b 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
 SCRIPTS="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
 
-source $SCRIPTS/config.properties
+. $SCRIPTS/config.properties
 
-function install_packages {
+install_packages() {
     # required if using Docker, else could be commented-out
     sudo apt-get update -y
     sudo apt-get -y install software-properties-common
@@ -31,7 +32,7 @@ function install_packages {
     export JAVA_HOME=/usr/lib/jvm/java-8-oracle
 }
 
-function start_odl {
+start_odl() {
     cd $HOME/opendaylight
 
     seed_nodes=""
@@ -55,6 +56,7 @@ start_odl
 
 # For the docker container, we have to let the container
 # live else it will stop once the setup is ready
+# noqa ShellCheckBear
 while [ 1 ];
 do
   sleep 10