mirror of
https://github.com/ovh/debian-cis.git
synced 2024-11-21 21:17:00 +01:00
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:
parent
c51a8ee9b8
commit
176fb96fa4
13
shellcheck/Dockerfile.shellcheck
Normal file
13
shellcheck/Dockerfile.shellcheck
Normal 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"]
|
||||
|
7
shellcheck/docker_build_and_run_shellcheck.sh
Executable file
7
shellcheck/docker_build_and_run_shellcheck.sh
Executable 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
15
shellcheck/launch_shellcheck.sh
Executable 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
|
Loading…
Reference in New Issue
Block a user