Skip to content

Commit c3bec0b

Browse files
authored
Merge pull request kubernetes#74601 from mrbobbytables/fix-test-image-shellcheck
Fix shellcheck lint errors in test/images/* scripts
2 parents b359b6b + 5518def commit c3bec0b

File tree

4 files changed

+21
-23
lines changed

4 files changed

+21
-23
lines changed

hack/.shellcheck_failures

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,3 @@
8585
./test/e2e_node/environment/setup_host.sh
8686
./test/e2e_node/gubernator.sh
8787
./test/images/image-util.sh
88-
./test/images/volume/gluster/run_gluster.sh
89-
./test/images/volume/iscsi/create_block.sh
90-
./test/images/volume/nfs/run_nfs.sh

test/images/volume/gluster/run_gluster.sh

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,24 @@
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
1616

17-
DIR=`mktemp -d`
17+
DIR="$(mktemp -d)"
1818

1919
function start()
2020
{
21-
mount -t tmpfs test $DIR
22-
chmod 755 $DIR
23-
cp /vol/* $DIR/
21+
mount -t tmpfs test "$DIR"
22+
chmod 755 "$DIR"
23+
cp /vol/* "$DIR/"
2424
/usr/sbin/glusterd -p /run/glusterd.pid
25-
gluster volume create test_vol `hostname -i`:$DIR force
25+
gluster volume create test_vol "$(hostname -i):$DIR" force
2626
gluster volume start test_vol
2727
}
2828

2929
function stop()
3030
{
3131
gluster --mode=script volume stop test_vol force
32-
kill $(cat /run/glusterd.pid)
33-
umount $DIR
34-
rm -rf $DIR
32+
kill "$(cat /run/glusterd.pid)"
33+
umount "$DIR"
34+
rm -rf "$DIR"
3535
exit 0
3636
}
3737

test/images/volume/iscsi/create_block.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,16 @@
1717
# Exit on the first error.
1818
set -e
1919

20-
MNTDIR=`mktemp -d`
20+
MNTDIR="$(mktemp -d)"
2121

2222
cleanup()
2323
{
2424
# Make sure we return the right exit code
2525
RET=$?
2626
# Silently remove everything and ignore errors
2727
set +e
28-
/bin/umount $MNTDIR 2>/dev/null
29-
/bin/rmdir $MNTDIR 2>/dev/null
28+
/bin/umount "$MNTDIR" 2>/dev/null
29+
/bin/rmdir "$MNTDIR" 2>/dev/null
3030
/bin/rm block 2>/dev/null
3131
exit $RET
3232
}
@@ -39,9 +39,9 @@ dd if=/dev/zero of=block seek=120 count=1 bs=1M
3939
mkfs.ext2 block
4040

4141
# Add index.html to it
42-
mount -o loop block $MNTDIR
43-
echo "Hello from iscsi" > $MNTDIR/index.html
44-
umount $MNTDIR
42+
mount -o loop block "$MNTDIR"
43+
echo "Hello from iscsi" > "$MNTDIR/index.html"
44+
umount "$MNTDIR"
4545

4646
rm block.tar.gz 2>/dev/null || :
4747
tar cfz block.tar.gz block

test/images/volume/nfs/run_nfs.sh

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,22 @@ function start()
2222
while getopts "G:" opt; do
2323
case ${opt} in
2424
G) gid=${OPTARG};;
25+
*):;;
2526
esac
2627
done
27-
shift $(($OPTIND - 1))
28+
shift $((OPTIND - 1))
2829

2930
# prepare /etc/exports
3031
for i in "$@"; do
3132
# fsid=0: needed for NFSv4
3233
echo "$i *(rw,fsid=0,insecure,no_root_squash)" >> /etc/exports
3334
if [ -v gid ] ; then
34-
chmod 070 $i
35-
chgrp $gid $i
35+
chmod 070 "$i"
36+
chgrp "$gid" "$i"
3637
fi
3738
# move index.html to here
38-
/bin/cp /tmp/index.html $i/
39-
chmod 644 $i/index.html
39+
/bin/cp /tmp/index.html "$i/"
40+
chmod 644 "$i/index.html"
4041
echo "Serving $i"
4142
done
4243

@@ -67,7 +68,7 @@ function stop()
6768
/usr/sbin/exportfs -au
6869
/usr/sbin/exportfs -f
6970

70-
kill $( pidof rpc.mountd )
71+
kill "$( pidof rpc.mountd )"
7172
umount /proc/fs/nfsd
7273
echo > /etc/exports
7374
exit 0

0 commit comments

Comments
 (0)