FEAT: automate shellcheck test with docker

IMP: search for all .sh files to shellcheck
If no file is passed as argument, shellchek will be run on all
.sh files

Fix dockerfile location and expand full shellcheck options
This commit is contained in:
Charles Herlin 2019-01-17 12:39:15 +01:00
parent 001323f448
commit 70cb310c54
3 changed files with 35 additions and 0 deletions

View File

@ -0,0 +1,13 @@
FROM ubuntu:latest
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y shellcheck
COPY . /opt/debian-cis/
COPY debian/default /etc/default/cis-hardening
RUN sed -i 's#cis-hardening#debian-cis#' /etc/default/cis-hardening
WORKDIR /opt/debian-cis
ENTRYPOINT ["/opt/debian-cis/shellcheck/launch_shellcheck.sh"]

View File

@ -0,0 +1,7 @@
#!/bin/bash
set -e
dockerfile="$(dirname "$0")/Dockerfile.shellcheck"
docker build -f "$dockerfile" -t debiancis-shellcheck "$(dirname "$0")"/../
docker run --rm debiancis-shellcheck "$@"

15
shellcheck/launch_shellcheck.sh Executable file
View File

@ -0,0 +1,15 @@
#!/bin/bash
files=""
if [ $# -eq 0 ]; then
files=$(find . -name "*.sh")
else
files="$*"
fi
for f in $files; do
printf "\e[1;36mRunning shellcheck on: %s \e[0m\n" "$f"
/usr/bin/shellcheck --color=always --external-sources --shell=bash "$f"
done