a3470f
From 5c8fd80edb0133cad6ae10c2a6dc23b660b9fa38 Mon Sep 17 00:00:00 2001
a3470f
From: Anoop C S <anoopcs@redhat.com>
a3470f
Date: Wed, 11 Oct 2017 13:29:13 +0530
a3470f
Subject: [PATCH 095/128] extras/hooks: Fix errors reported via shellcheck
a3470f
 utility
a3470f
a3470f
> Change-Id: I217c6b2a39955f1709bb3452b00d33c2dcb60faa
a3470f
> BUG: 1500649
a3470f
> Upstream: https://review.gluster.org/#/c/18485/
a3470f
a3470f
Change-Id: I217c6b2a39955f1709bb3452b00d33c2dcb60faa
a3470f
BUG: 1444820
a3470f
Signed-off-by: Anoop C S <anoopcs@redhat.com>
a3470f
Reviewed-on: https://code.engineering.redhat.com/gerrit/124640
a3470f
Tested-by: RHGS Build Bot <nigelb@redhat.com>
a3470f
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
a3470f
---
a3470f
 .../add-brick/post/disabled-quota-root-xattr-heal.sh         |  2 +-
a3470f
 .../add-brick/pre/S28Quota-enable-root-xattr-heal.sh         |  8 ++++----
a3470f
 extras/hook-scripts/create/post/S10selinux-label-brick.sh    |  4 ++--
a3470f
 extras/hook-scripts/delete/pre/S10selinux-del-fcontext.sh    |  7 ++-----
a3470f
 extras/hook-scripts/set/post/S30samba-set.sh                 | 12 ++++++------
a3470f
 .../set/post/S32gluster_enable_shared_storage.sh             |  4 ++--
a3470f
 extras/hook-scripts/start/post/S29CTDBsetup.sh               |  4 ++--
a3470f
 extras/hook-scripts/start/post/S30samba-start.sh             | 10 +++++-----
a3470f
 extras/hook-scripts/stop/pre/S29CTDB-teardown.sh             |  4 ++--
a3470f
 extras/hook-scripts/stop/pre/S30samba-stop.sh                |  8 ++++----
a3470f
 10 files changed, 30 insertions(+), 33 deletions(-)
a3470f
a3470f
diff --git a/extras/hook-scripts/add-brick/post/disabled-quota-root-xattr-heal.sh b/extras/hook-scripts/add-brick/post/disabled-quota-root-xattr-heal.sh
a3470f
index bde7249..ce81816 100755
a3470f
--- a/extras/hook-scripts/add-brick/post/disabled-quota-root-xattr-heal.sh
a3470f
+++ b/extras/hook-scripts/add-brick/post/disabled-quota-root-xattr-heal.sh
a3470f
@@ -71,7 +71,7 @@ get_and_set_xattr ()
a3470f
 ##------------------------------------------
a3470f
 ## Parse the arguments
a3470f
 ##------------------------------------------
a3470f
-ARGS=$(getopt -l $OPTSPEC  -name $PROGNAME $@)
a3470f
+ARGS=$(getopt -l $OPTSPEC  -name $PROGNAME "$@")
a3470f
 eval set -- "$ARGS"
a3470f
 
a3470f
 while true;
a3470f
diff --git a/extras/hook-scripts/add-brick/pre/S28Quota-enable-root-xattr-heal.sh b/extras/hook-scripts/add-brick/pre/S28Quota-enable-root-xattr-heal.sh
a3470f
index 348f34e..38af73f 100755
a3470f
--- a/extras/hook-scripts/add-brick/pre/S28Quota-enable-root-xattr-heal.sh
a3470f
+++ b/extras/hook-scripts/add-brick/pre/S28Quota-enable-root-xattr-heal.sh
a3470f
@@ -29,7 +29,7 @@ VERSION=
a3470f
 ENABLED_NAME="S28Quota-root-xattr-heal.sh"
a3470f
 DISABLED_NAME="disabled-quota-root-xattr-heal.sh"
a3470f
 
a3470f
-enable ()
a3470f
+activate ()
a3470f
 {
a3470f
         ln -sf $DISABLED_STATE $1;
a3470f
 }
a3470f
@@ -37,7 +37,7 @@ enable ()
a3470f
 ##------------------------------------------
a3470f
 ## Parse the arguments
a3470f
 ##------------------------------------------
a3470f
-ARGS=$(getopt -l $OPTSPEC  -name $PROGNAME $@)
a3470f
+ARGS=$(getopt -l $OPTSPEC  -name $PROGNAME "$@")
a3470f
 eval set -- "$ARGS"
a3470f
 
a3470f
 while true;
a3470f
@@ -92,9 +92,9 @@ FLAG=`cat $GLUSTERD_WORKDIR/vols/$VOL_NAME/info | grep "^status=" \
a3470f
       | awk -F'=' '{print $NF}'`;
a3470f
 if [ "$FLAG" != "1" ]
a3470f
 then
a3470f
-        enable $ENABLED_STATE_START;
a3470f
+        activate $ENABLED_STATE_START;
a3470f
         exit $?
a3470f
 fi
a3470f
 
a3470f
-enable $ENABLED_STATE_ADD_BRICK;
a3470f
+activate $ENABLED_STATE_ADD_BRICK;
a3470f
 exit $?
a3470f
diff --git a/extras/hook-scripts/create/post/S10selinux-label-brick.sh b/extras/hook-scripts/create/post/S10selinux-label-brick.sh
a3470f
index f38555c..94c624d 100755
a3470f
--- a/extras/hook-scripts/create/post/S10selinux-label-brick.sh
a3470f
+++ b/extras/hook-scripts/create/post/S10selinux-label-brick.sh
a3470f
@@ -14,7 +14,7 @@ OPTSPEC="volname:"
a3470f
 VOL=
a3470f
 
a3470f
 parse_args () {
a3470f
-        ARGS=$(getopt -l $OPTSPEC  -name $PROGNAME $@)
a3470f
+        ARGS=$(getopt -l $OPTSPEC  -name $PROGNAME "$@")
a3470f
         eval set -- "$ARGS"
a3470f
 
a3470f
         while true; do
a3470f
@@ -53,7 +53,7 @@ set_brick_labels()
a3470f
 SELINUX_STATE=$(which getenforce && getenforce)
a3470f
 [ "${SELINUX_STATE}" = 'Disabled' ] && exit 0
a3470f
 
a3470f
-parse_args $@
a3470f
+parse_args "$@"
a3470f
 [ -z "$VOL" ] && exit 1
a3470f
 
a3470f
 set_brick_labels $VOL
a3470f
diff --git a/extras/hook-scripts/delete/pre/S10selinux-del-fcontext.sh b/extras/hook-scripts/delete/pre/S10selinux-del-fcontext.sh
a3470f
index 2c83331..7851e70 100755
a3470f
--- a/extras/hook-scripts/delete/pre/S10selinux-del-fcontext.sh
a3470f
+++ b/extras/hook-scripts/delete/pre/S10selinux-del-fcontext.sh
a3470f
@@ -13,12 +13,9 @@
a3470f
 PROGNAME="Sselinux"
a3470f
 OPTSPEC="volname:"
a3470f
 VOL=
a3470f
-CONFIGFILE=
a3470f
-LOGFILEBASE=
a3470f
-PIDDIR=
a3470f
 
a3470f
 function parse_args () {
a3470f
-        ARGS=$(getopt -l $OPTSPEC  -name $PROGNAME $@)
a3470f
+        ARGS=$(getopt -l $OPTSPEC  -name $PROGNAME "$@")
a3470f
         eval set -- "$ARGS"
a3470f
 
a3470f
         while true; do
a3470f
@@ -53,7 +50,7 @@ function delete_brick_fcontext()
a3470f
 SELINUX_STATE=$(which getenforce && getenforce)
a3470f
 [ "${SELINUX_STATE}" = 'Disabled' ] && exit 0
a3470f
 
a3470f
-parse_args $@
a3470f
+parse_args "$@"
a3470f
 [ -z "$VOL" ] && exit 1
a3470f
 
a3470f
 delete_brick_fcontext $VOL
a3470f
diff --git a/extras/hook-scripts/set/post/S30samba-set.sh b/extras/hook-scripts/set/post/S30samba-set.sh
a3470f
index 97d067f..c21cfb5 100755
a3470f
--- a/extras/hook-scripts/set/post/S30samba-set.sh
a3470f
+++ b/extras/hook-scripts/set/post/S30samba-set.sh
a3470f
@@ -28,7 +28,7 @@ USERSMB_SET=""
a3470f
 USERCIFS_SET=""
a3470f
 
a3470f
 function parse_args () {
a3470f
-        ARGS=$(getopt -l $OPTSPEC  --name $PROGNAME -o "o:" -- $@)
a3470f
+        ARGS=$(getopt -l $OPTSPEC  --name $PROGNAME -o "o:" -- "$@")
a3470f
         eval set -- "$ARGS"
a3470f
 
a3470f
         while true; do
a3470f
@@ -123,23 +123,23 @@ function get_smb () {
a3470f
         usersmbvalue=$(grep user.smb $GLUSTERD_WORKDIR/vols/"$volname"/info |\
a3470f
                        cut -d"=" -f2)
a3470f
 
a3470f
-        if [[ $usercifsvalue = "disable" || $usersmbvalue = "disable" ]]; then
a3470f
+        if [ $usercifsvalue = "disable" ] || [ $usersmbvalue = "disable" ]; then
a3470f
                 uservalue="disable"
a3470f
         fi
a3470f
         echo "$uservalue"
a3470f
 }
a3470f
 
a3470f
-parse_args $@
a3470f
-if [ "0" = $(is_volume_started "$VOL") ]; then
a3470f
+parse_args "$@"
a3470f
+if [ "0" = "$(is_volume_started "$VOL")" ]; then
a3470f
     exit 0
a3470f
 fi
a3470f
 
a3470f
 
a3470f
-if [[ "$USERCIFS_SET" = "YES" || "$USERSMB_SET" = "YES" ]]; then
a3470f
+if [ "$USERCIFS_SET" = "YES" ] || [ "$USERSMB_SET" = "YES" ]; then
a3470f
     #Find smb.conf, smbd pid directory and smbd logfile path
a3470f
     find_config_info
a3470f
 
a3470f
-    if [ $(get_smb "$VOL") = "disable" ]; then
a3470f
+    if [ "$(get_smb "$VOL")" = "disable" ]; then
a3470f
         del_samba_share $VOL
a3470f
         sighup_samba
a3470f
     else
a3470f
diff --git a/extras/hook-scripts/set/post/S32gluster_enable_shared_storage.sh b/extras/hook-scripts/set/post/S32gluster_enable_shared_storage.sh
a3470f
index c0aa735..885ed03 100755
a3470f
--- a/extras/hook-scripts/set/post/S32gluster_enable_shared_storage.sh
a3470f
+++ b/extras/hook-scripts/set/post/S32gluster_enable_shared_storage.sh
a3470f
@@ -104,7 +104,7 @@ function check_volume_status()
a3470f
     echo $status
a3470f
 }
a3470f
 
a3470f
-mount_cmd="mount -t glusterfs "$local_node_hostname":/gluster_shared_storage \
a3470f
+mount_cmd="mount -t glusterfs $local_node_hostname:/gluster_shared_storage \
a3470f
            /var/run/gluster/shared_storage"
a3470f
 
a3470f
 if [ "$option" == "enable" ]; then
a3470f
@@ -117,7 +117,7 @@ if [ "$option" == "enable" ]; then
a3470f
         if [ "$retry" == 3 ]; then
a3470f
             break;
a3470f
         fi
a3470f
-        status = check_volume_status;
a3470f
+        status=$(check_volume_status)
a3470f
     done
a3470f
     # Mount the volume on all the nodes
a3470f
     umount /var/run/gluster/shared_storage
a3470f
diff --git a/extras/hook-scripts/start/post/S29CTDBsetup.sh b/extras/hook-scripts/start/post/S29CTDBsetup.sh
a3470f
index 4265cba..330ce74 100755
a3470f
--- a/extras/hook-scripts/start/post/S29CTDBsetup.sh
a3470f
+++ b/extras/hook-scripts/start/post/S29CTDBsetup.sh
a3470f
@@ -21,7 +21,7 @@ VOL=
a3470f
 META="all"
a3470f
 
a3470f
 function parse_args () {
a3470f
-        ARGS=$(getopt -l $OPTSPEC  -name $PROGNAME $@)
a3470f
+        ARGS=$(getopt -l $OPTSPEC  -name $PROGNAME "$@")
a3470f
         eval set -- "$ARGS"
a3470f
 
a3470f
         while true; do
a3470f
@@ -55,7 +55,7 @@ function add_fstab_entry () {
a3470f
         fi
a3470f
 }
a3470f
 
a3470f
-parse_args $@
a3470f
+parse_args "$@"
a3470f
 if [ "$META" = "$VOL" ]
a3470f
 then
a3470f
         mkdir -p $CTDB_MNT
a3470f
diff --git a/extras/hook-scripts/start/post/S30samba-start.sh b/extras/hook-scripts/start/post/S30samba-start.sh
a3470f
index 3e0f257..d6b94e6 100755
a3470f
--- a/extras/hook-scripts/start/post/S30samba-start.sh
a3470f
+++ b/extras/hook-scripts/start/post/S30samba-start.sh
a3470f
@@ -29,7 +29,7 @@ PIDDIR=
a3470f
 GLUSTERD_WORKDIR=
a3470f
 
a3470f
 function parse_args () {
a3470f
-        ARGS=$(getopt -l $OPTSPEC  -name $PROGNAME $@)
a3470f
+        ARGS=$(getopt -l $OPTSPEC  -name $PROGNAME "$@")
a3470f
         eval set -- "$ARGS"
a3470f
 
a3470f
         while true; do
a3470f
@@ -57,8 +57,8 @@ function find_config_info () {
a3470f
                 echo "Samba is not installed"
a3470f
                 exit 1
a3470f
         fi
a3470f
-        CONFIGFILE=`echo $cmdout | awk {'print $2'}`
a3470f
-        PIDDIR=`smbd -b | grep PIDDIR | awk {'print $2'}`
a3470f
+        CONFIGFILE=`echo $cmdout | awk '{print $2}'`
a3470f
+        PIDDIR=`smbd -b | grep PIDDIR | awk '{print $2}'`
a3470f
         LOGFILEBASE=`smbd -b | grep 'LOGFILEBASE' | awk '{print $2}'`
a3470f
 }
a3470f
 
a3470f
@@ -95,13 +95,13 @@ function get_smb () {
a3470f
         usersmbvalue=$(grep user.smb $GLUSTERD_WORKDIR/vols/"$volname"/info |\
a3470f
                        cut -d"=" -f2)
a3470f
 
a3470f
-        if [[ $usercifsvalue = "disable" || $usersmbvalue = "disable" ]]; then
a3470f
+        if [ $usercifsvalue = "disable" ] || [ $usersmbvalue = "disable" ]; then
a3470f
                 uservalue="disable"
a3470f
         fi
a3470f
         echo "$uservalue"
a3470f
 }
a3470f
 
a3470f
-parse_args $@
a3470f
+parse_args "$@"
a3470f
 if [ "$(get_smb "$VOL")" = "disable" ]; then
a3470f
         exit 0
a3470f
 fi
a3470f
diff --git a/extras/hook-scripts/stop/pre/S29CTDB-teardown.sh b/extras/hook-scripts/stop/pre/S29CTDB-teardown.sh
a3470f
index 5fb49bd..e9116c8 100755
a3470f
--- a/extras/hook-scripts/stop/pre/S29CTDB-teardown.sh
a3470f
+++ b/extras/hook-scripts/stop/pre/S29CTDB-teardown.sh
a3470f
@@ -12,7 +12,7 @@ VOL=
a3470f
 META="all"
a3470f
 
a3470f
 function parse_args () {
a3470f
-        ARGS=$(getopt -l $OPTSPEC  -name $PROGNAME $@)
a3470f
+        ARGS=$(getopt -l $OPTSPEC  -name $PROGNAME "$@")
a3470f
         eval set -- "$ARGS"
a3470f
 
a3470f
         while true; do
a3470f
@@ -51,7 +51,7 @@ function remove_fstab_entry () {
a3470f
         fi
a3470f
 }
a3470f
 
a3470f
-parse_args $@
a3470f
+parse_args "$@"
a3470f
 if [ "$META" = "$VOL" ]
a3470f
 then
a3470f
         umount "$CTDB_MNT"
a3470f
diff --git a/extras/hook-scripts/stop/pre/S30samba-stop.sh b/extras/hook-scripts/stop/pre/S30samba-stop.sh
a3470f
index 62cf7d1..6e542da 100755
a3470f
--- a/extras/hook-scripts/stop/pre/S30samba-stop.sh
a3470f
+++ b/extras/hook-scripts/stop/pre/S30samba-stop.sh
a3470f
@@ -22,7 +22,7 @@ CONFIGFILE=
a3470f
 PIDDIR=
a3470f
 
a3470f
 function parse_args () {
a3470f
-        ARGS=$(getopt -l $OPTSPEC  -name $PROGNAME $@)
a3470f
+        ARGS=$(getopt -l $OPTSPEC  -name $PROGNAME "$@")
a3470f
         eval set -- "$ARGS"
a3470f
 
a3470f
         while true; do
a3470f
@@ -46,8 +46,8 @@ function find_config_info () {
a3470f
                 echo "Samba is not installed"
a3470f
                 exit 1
a3470f
         fi
a3470f
-        CONFIGFILE=`echo $cmdout | awk {'print $2'}`
a3470f
-        PIDDIR=`smbd -b | grep PIDDIR | awk {'print $2'}`
a3470f
+        CONFIGFILE=`echo $cmdout | awk '{print $2}'`
a3470f
+        PIDDIR=`smbd -b | grep PIDDIR | awk '{print $2}'`
a3470f
 }
a3470f
 
a3470f
 function del_samba_share () {
a3470f
@@ -65,7 +65,7 @@ function sighup_samba () {
a3470f
         fi
a3470f
 }
a3470f
 
a3470f
-parse_args $@
a3470f
+parse_args "$@"
a3470f
 find_config_info
a3470f
 del_samba_share $VOL
a3470f
 sighup_samba
a3470f
-- 
a3470f
1.8.3.1
a3470f