Skip to content

Commit bb9e90a

Browse files
committed
Merge pull request #4136 from Joshua-Anderson/add-shellcheck-router
test(router): run shell scripts through shellcheck
2 parents c4b722d + 8420b83 commit bb9e90a

3 files changed

Lines changed: 24 additions & 21 deletions

File tree

router/Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ GO_FILES = $(wildcard *.go)
77
GO_PACKAGES = logger tests
88
GO_PACKAGES_REPO_PATH = $(addprefix $(repo_path)/,$(GO_PACKAGES))
99

10+
SHELL_SCRIPTS = $(shell find "." -name '*.sh') $(wildcard image/bin/*)
11+
1012
COMPONENT = $(notdir $(repo_path))
1113
IMAGE = $(IMAGE_PREFIX)$(COMPONENT):$(BUILD_TAG)
1214
DEV_IMAGE = $(REGISTRY)$(IMAGE)
@@ -70,6 +72,7 @@ test-style:
7072
@$(GOFMT) $(GO_PACKAGES) $(GO_FILES) | read; if [ $$? == 0 ]; then echo "gofmt check failed."; exit 1; fi
7173
$(GOVET) $(repo_path) $(GO_PACKAGES_REPO_PATH)
7274
$(GOLINT) ./...
75+
shellcheck $(SHELL_SCRIPTS)
7376

7477
test-unit:
7578
@echo no unit tests

router/build.sh

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ if [[ -z $DOCKER_BUILD ]]; then
1111
fi
1212

1313
function get_src {
14-
hash=$1
15-
url=$2
16-
f=$(basename $url)
14+
hash="$1"
15+
url="$2"
16+
f=$(basename "$url")
1717

18-
curl -sSL $url -o $f
18+
curl -sSL "$url" -o "$f"
1919
echo "$hash $f" | sha256sum -c - || exit 10
20-
tar xzf $f
21-
rm $f
20+
tar xzf "$f"
21+
rm "$f"
2222
}
2323

2424
export VERSION_NGINX=nginx-1.9.2
@@ -31,11 +31,11 @@ export BUILD_PATH=/tmp/build
3131
# nginx installation directory
3232
export PREFIX=/opt/nginx
3333

34-
rm -rf $PREFIX
35-
mkdir $PREFIX
34+
rm -rf "$PREFIX"
35+
mkdir "$PREFIX"
3636

37-
mkdir $BUILD_PATH
38-
cd $BUILD_PATH
37+
mkdir "$BUILD_PATH"
38+
cd "$BUILD_PATH"
3939

4040
# install required packages to build
4141
apk add --update-cache \
@@ -52,22 +52,22 @@ apk add --update-cache \
5252

5353
# download, verify and extract the source files
5454
get_src 80b6425be14a005c8cb15115f3c775f4bc06bf798aa1affaee84ed9cf641ed78 \
55-
http://nginx.org/download/$VERSION_NGINX.tar.gz
55+
"http://nginx.org/download/$VERSION_NGINX.tar.gz"
5656

5757
get_src 128b56873eedbd3f240dc0f88a8b260d791321db92f14ba2fc5c49fc5307e04d \
58-
https://github.com/nbs-system/naxsi/archive/$VERSION_NAXSI.tar.gz
58+
"https://github.com/nbs-system/naxsi/archive/$VERSION_NAXSI.tar.gz"
5959

6060
get_src 501f299abdb81b992a980bda182e5de5a4b2b3e275fbf72ee34dd7ae84c4b679 \
61-
https://github.com/simpl/ngx_devel_kit/archive/v$VERSION_NDK.tar.gz
61+
"https://github.com/simpl/ngx_devel_kit/archive/v$VERSION_NDK.tar.gz"
6262

6363
get_src 8d280fc083420afb41dbe10df9a8ceec98f1d391bd2caa42ebae67d5bc9295d8 \
64-
https://github.com/openresty/set-misc-nginx-module/archive/v$VERSION_SETMISC.tar.gz
64+
"https://github.com/openresty/set-misc-nginx-module/archive/v$VERSION_SETMISC.tar.gz"
6565

6666
# build nginx
67-
cd $BUILD_PATH/$VERSION_NGINX
67+
cd "$BUILD_PATH/$VERSION_NGINX"
6868

6969
./configure \
70-
--prefix=$PREFIX \
70+
--prefix="$PREFIX" \
7171
--pid-path=/run/nginx.pid \
7272
--with-debug \
7373
--with-pcre-jit \
@@ -85,9 +85,9 @@ cd $BUILD_PATH/$VERSION_NGINX
8585
--with-mail \
8686
--with-mail_ssl_module \
8787
--with-stream \
88-
--add-module=$BUILD_PATH/naxsi-$VERSION_NAXSI/naxsi_src \
89-
--add-module=$BUILD_PATH/ngx_devel_kit-$VERSION_NDK \
90-
--add-module=$BUILD_PATH/set-misc-nginx-module-$VERSION_SETMISC \
88+
--add-module="$BUILD_PATH/naxsi-$VERSION_NAXSI/naxsi_src" \
89+
--add-module="$BUILD_PATH/ngx_devel_kit-$VERSION_NDK" \
90+
--add-module="$BUILD_PATH/set-misc-nginx-module-$VERSION_SETMISC" \
9191
&& make && make install
9292

9393
mv /tmp/firewall /opt/nginx/firewall

router/image/bin/check

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
# Check that the configuration for deis-router is valid.
44
#
55

6-
if grep -q "<no value>" $1 ; then
6+
if grep -q "<no value>" "$1" ; then
77
exit 1
88
fi
99

10-
if ! /opt/nginx/sbin/nginx -t -c $1 ; then
10+
if ! /opt/nginx/sbin/nginx -t -c "$1" ; then
1111
exit 1
1212
fi

0 commit comments

Comments
 (0)