Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix shellcheck lint errors in test/images/* scripts #74601

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 0 additions & 3 deletions hack/.shellcheck_failures
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,3 @@
./test/e2e_node/environment/setup_host.sh
./test/e2e_node/gubernator.sh
./test/images/image-util.sh
./test/images/volume/gluster/run_gluster.sh
./test/images/volume/iscsi/create_block.sh
./test/images/volume/nfs/run_nfs.sh
16 changes: 8 additions & 8 deletions test/images/volume/gluster/run_gluster.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,24 @@
# See the License for the specific language governing permissions and
# limitations under the License.

DIR=`mktemp -d`
DIR="$(mktemp -d)"

function start()
{
mount -t tmpfs test $DIR
chmod 755 $DIR
cp /vol/* $DIR/
mount -t tmpfs test "$DIR"
chmod 755 "$DIR"
cp /vol/* "$DIR/"
/usr/sbin/glusterd -p /run/glusterd.pid
gluster volume create test_vol `hostname -i`:$DIR force
gluster volume create test_vol "$(hostname -i):$DIR" force
gluster volume start test_vol
}

function stop()
{
gluster --mode=script volume stop test_vol force
kill $(cat /run/glusterd.pid)
umount $DIR
rm -rf $DIR
kill "$(cat /run/glusterd.pid)"
umount "$DIR"
rm -rf "$DIR"
exit 0
}

Expand Down
12 changes: 6 additions & 6 deletions test/images/volume/iscsi/create_block.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@
# Exit on the first error.
set -e

MNTDIR=`mktemp -d`
MNTDIR="$(mktemp -d)"

cleanup()
{
# Make sure we return the right exit code
RET=$?
# Silently remove everything and ignore errors
set +e
/bin/umount $MNTDIR 2>/dev/null
/bin/rmdir $MNTDIR 2>/dev/null
/bin/umount "$MNTDIR" 2>/dev/null
/bin/rmdir "$MNTDIR" 2>/dev/null
/bin/rm block 2>/dev/null
exit $RET
}
Expand All @@ -39,9 +39,9 @@ dd if=/dev/zero of=block seek=120 count=1 bs=1M
mkfs.ext2 block

# Add index.html to it
mount -o loop block $MNTDIR
echo "Hello from iscsi" > $MNTDIR/index.html
umount $MNTDIR
mount -o loop block "$MNTDIR"
echo "Hello from iscsi" > "$MNTDIR/index.html"
umount "$MNTDIR"

rm block.tar.gz 2>/dev/null || :
tar cfz block.tar.gz block
13 changes: 7 additions & 6 deletions test/images/volume/nfs/run_nfs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,22 @@ function start()
while getopts "G:" opt; do
case ${opt} in
G) gid=${OPTARG};;
*):;;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SC2220 - "Invalid flags are not handled. Add a *) case."

This just adds a default 'true' case that does nothing, alternative could be to just disable the check.

esac
done
shift $(($OPTIND - 1))
shift $((OPTIND - 1))

# prepare /etc/exports
for i in "$@"; do
# fsid=0: needed for NFSv4
echo "$i *(rw,fsid=0,insecure,no_root_squash)" >> /etc/exports
if [ -v gid ] ; then
chmod 070 $i
chgrp $gid $i
chmod 070 "$i"
chgrp "$gid" "$i"
fi
# move index.html to here
/bin/cp /tmp/index.html $i/
chmod 644 $i/index.html
/bin/cp /tmp/index.html "$i/"
chmod 644 "$i/index.html"
echo "Serving $i"
done

Expand Down Expand Up @@ -67,7 +68,7 @@ function stop()
/usr/sbin/exportfs -au
/usr/sbin/exportfs -f

kill $( pidof rpc.mountd )
kill "$( pidof rpc.mountd )"
umount /proc/fs/nfsd
echo > /etc/exports
exit 0
Expand Down