48 lines
1.3 KiB
Bash
48 lines
1.3 KiB
Bash
|
|
#!/usr/bin/env bash
|
||
|
|
#
|
||
|
|
# Vérifie la qualité du projet :
|
||
|
|
# 1. shellcheck sur tous les scripts shell.
|
||
|
|
# 2. nginx -t sur la conf templatée (via un conteneur jetable).
|
||
|
|
|
||
|
|
set -euo pipefail
|
||
|
|
|
||
|
|
PROJECT_ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
||
|
|
cd "$PROJECT_ROOT"
|
||
|
|
|
||
|
|
shell_files=(
|
||
|
|
scripts/build-ip-list.sh
|
||
|
|
scripts/entrypoint.sh
|
||
|
|
scripts/lint.sh
|
||
|
|
tests/run.sh
|
||
|
|
tests/lib.sh
|
||
|
|
tests/cases/whitelist_authorized_ip.sh
|
||
|
|
tests/cases/whitelist_unauthorized_ip.sh
|
||
|
|
tests/cases/blacklist_blocked_ip.sh
|
||
|
|
tests/cases/blacklist_normal_ip.sh
|
||
|
|
tests/cases/log_dedicated.sh
|
||
|
|
tests/cases/nginx_syntax.sh
|
||
|
|
)
|
||
|
|
|
||
|
|
echo "==> shellcheck"
|
||
|
|
if command -v shellcheck >/dev/null 2>&1; then
|
||
|
|
shellcheck -x "${shell_files[@]}"
|
||
|
|
else
|
||
|
|
# Fallback : shellcheck via Docker si l'outil n'est pas installé localement.
|
||
|
|
docker run --rm -v "$PROJECT_ROOT:/mnt" -w /mnt koalaman/shellcheck:stable -x "${shell_files[@]}"
|
||
|
|
fi
|
||
|
|
echo "shellcheck OK"
|
||
|
|
|
||
|
|
echo "==> nginx -t (build d'image + check)"
|
||
|
|
docker build --quiet -t maintenance-proxy:lint . >/dev/null
|
||
|
|
|
||
|
|
docker run --rm \
|
||
|
|
-e MAINTENANCE_MODE=whitelist \
|
||
|
|
-e MAINTENANCE_IP_LIST="1.2.3.4,5.6.7.8" \
|
||
|
|
-e UPSTREAM_HOST="upstream:80" \
|
||
|
|
-e LISTEN_PORT=8080 \
|
||
|
|
-e SERVER_NAME=_ \
|
||
|
|
--entrypoint /bin/sh \
|
||
|
|
maintenance-proxy:lint \
|
||
|
|
-c '/docker-entrypoint.sh nginx -t'
|
||
|
|
echo "nginx -t OK"
|