Fix shellcheck tests failing

This commit is contained in:
Théophile Diot 2023-10-02 11:05:15 +01:00
parent e21e0c812b
commit 5ed595be68
No known key found for this signature in database
GPG key ID: 248FEA4BAE400D06
79 changed files with 595 additions and 290 deletions

View file

@ -1,6 +1,6 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
exclude: (^LICENSE.md$|^src/VERSION$|^src/(bw/misc/root-ca.pem$|deps/src/|common/core/modsecurity/files/coreruleset/|ui/static/js/(editor/|utils/purify/|tsparticles\.bundle\.min\.js))|\.(svg|drawio|patch\d?|ascii|tf|tftpl)$)
exclude: (^LICENSE.md$|^src/VERSION$|^src/(bw/misc/root-ca.pem$|deps/src/|common/core/modsecurity/files|ui/static/js/(editor/|utils/purify/|tsparticles\.bundle\.min\.js))|\.(svg|drawio|patch\d?|ascii|tf|tftpl)$)
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
@ -17,12 +17,12 @@ repos:
- id: black
language_version: python3.9
- repo: https://github.com/koalaman/shellcheck-precommit
rev: v0.9.0
hooks:
- id: shellcheck
- repo: https://github.com/gitleaks/gitleaks
rev: v8.18.0
hooks:
- id: gitleaks
- repo: https://github.com/koalaman/shellcheck-precommit
rev: v0.9.0
hooks:
- id: shellcheck

View file

@ -1,6 +1,6 @@
#!/bin/bash
if [ $(id -u) -ne 0 ] ; then
if [ "$(id -u)" -ne 0 ] ; then
echo "❌ Run me as root"
exit 1
fi

View file

@ -1,6 +1,6 @@
#!/bin/bash
if [ $(id -u) -ne 0 ] ; then
if [ "$(id -u)" -ne 0 ] ; then
echo "❌ Run me as root"
exit 1
fi

View file

@ -1,6 +1,6 @@
#!/bin/bash
if [ $(id -u) -ne 0 ] ; then
if [ "$(id -u)" -ne 0 ] ; then
echo "❌ Run me as root"
exit 1
fi
@ -8,9 +8,9 @@ fi
DNF=$(which dnf)
APT=$(which apt)
if [ ! -z $DNF ] ; then
if [ -n "$DNF" ] ; then
dnf install -y haproxy
elif [ ! -z $APT ] ; then
elif [ -n "$APT" ] ; then
apt install -y haproxy
fi

View file

@ -2,7 +2,7 @@
echo "Certbot started, domains = $DOMAINS"
first_domain="$(echo -n $DOMAINS | cut -d ',' -f 1 | sed 's/*\.//g')"
first_domain="$(echo "$DOMAINS" | tr -d '\n' | cut -d ',' -f 1 | sed 's/*\.//g')"
if [ "$EMAIL" = "" ] ; then
EMAIL="contact@${first_domain}"
fi

View file

@ -2,7 +2,7 @@
echo "Certbot started, domains = $DOMAINS"
first_domain="$(echo -n $DOMAINS | cut -d ',' -f 1 | sed 's/*\.//g')"
first_domain="$(echo "$DOMAINS" | tr -d '\n' | cut -d ',' -f 1 | sed 's/*\.//g')"
if [ "$EMAIL" = "" ] ; then
EMAIL="contact@${first_domain}"
fi

View file

@ -2,7 +2,7 @@
echo "Certbot started, domains = $DOMAINS"
first_domain="$(echo -n $DOMAINS | cut -d ',' -f 1 | sed 's/*\.//g')"
first_domain="$(echo "$DOMAINS" | tr -d '\n' | cut -d ',' -f 1 | sed 's/*\.//g')"
if [ "$EMAIL" = "" ] ; then
EMAIL="contact@${first_domain}"
fi

View file

@ -2,7 +2,7 @@
echo "Certbot started, domains = $DOMAINS"
first_domain="$(echo -n $DOMAINS | cut -d ',' -f 1 | sed 's/*\.//g')"
first_domain="$(echo "$DOMAINS" | tr -d '\n' | cut -d ',' -f 1 | sed 's/*\.//g')"
if [ "$EMAIL" = "" ] ; then
EMAIL="contact@${first_domain}"
fi

View file

@ -2,7 +2,7 @@
echo "Certbot started, domains = $DOMAINS"
first_domain="$(echo -n $DOMAINS | cut -d ',' -f 1 | sed 's/*\.//g')"
first_domain="$(echo "$DOMAINS" | tr -d '\n' | cut -d ',' -f 1 | sed 's/*\.//g')"
if [ "$EMAIL" = "" ] ; then
EMAIL="contact@${first_domain}"
fi

View file

@ -1,6 +1,6 @@
#!/bin/bash
if [ $(id -u) -ne 0 ] ; then
if [ "$(id -u)" -ne 0 ] ; then
echo "❌ Run me as root"
exit 1
fi

View file

@ -1,6 +1,6 @@
#!/bin/bash
if [ $(id -u) -ne 0 ] ; then
if [ "$(id -u)" -ne 0 ] ; then
echo "❌ Run me as root"
exit 1
fi

View file

@ -1,6 +1,6 @@
#!/bin/bash
if [ $(id -u) -ne 0 ] ; then
if [ "$(id -u)" -ne 0 ] ; then
echo "❌ Run me as root"
exit 1
fi

View file

@ -1,6 +1,6 @@
#!/bin/bash
if [ $(id -u) -ne 0 ] ; then
if [ "$(id -u)" -ne 0 ] ; then
echo "❌ Run me as root"
exit 1
fi
@ -16,11 +16,11 @@ fi
curl https://ftp.drupal.org/files/projects/drupal-9.5.3.tar.gz -Lo /tmp/drupal.tar.gz
tar -xzf /tmp/drupal.tar.gz -C /tmp
current_dir="$(pwd)"
cd /tmp/drupal-*
cp -r * /var/www/html
cd /tmp/drupal-* || exit 1
cp -r ./* /var/www/html
chown -R $user:nginx /var/www/html
find /var/www/html -type f -exec chmod 0640 {} \;
find /var/www/html -type d -exec chmod 0750 {} \;
cd "$current_dir"
cd "$current_dir" || exit 1
cp -r ./bw-data/configs/* /etc/bunkerweb/configs
chown -R nginx:nginx /etc/bunkerweb/configs

View file

@ -1,6 +1,6 @@
#!/bin/bash
if [ $(id -u) -ne 0 ] ; then
if [ "$(id -u)" -ne 0 ] ; then
echo "❌ Run me as root"
exit 1
fi

View file

@ -1,6 +1,6 @@
#!/bin/bash
if [ $(id -u) -ne 0 ] ; then
if [ "$(id -u)" -ne 0 ] ; then
echo "❌ Run me as root"
exit 1
fi

View file

@ -1,6 +1,6 @@
#!/bin/bash
if [ $(id -u) -ne 0 ] ; then
if [ "$(id -u)" -ne 0 ] ; then
echo "❌ Run me as root"
exit 1
fi

View file

@ -1,6 +1,6 @@
#!/bin/bash
if [ $(id -u) -ne 0 ] ; then
if [ "$(id -u)" -ne 0 ] ; then
echo "❌ Run me as root"
exit 1
fi

View file

@ -1,6 +1,6 @@
#!/bin/bash
if [ $(id -u) -ne 0 ] ; then
if [ "$(id -u)" -ne 0 ] ; then
echo "❌ Run me as root"
exit 1
fi

View file

@ -1,6 +1,6 @@
#!/bin/bash
if [ $(id -u) -ne 0 ] ; then
if [ "$(id -u)" -ne 0 ] ; then
echo "❌ Run me as root"
exit 1
fi

View file

@ -1,6 +1,6 @@
#!/bin/bash
if [ $(id -u) -ne 0 ] ; then
if [ "$(id -u)" -ne 0 ] ; then
echo "❌ Run me as root"
exit 1
fi

View file

@ -1,6 +1,6 @@
#!/bin/bash
if [ $(id -u) -ne 0 ] ; then
if [ "$(id -u)" -ne 0 ] ; then
echo "❌ Run me as root"
exit 1
fi

View file

@ -1,6 +1,6 @@
#!/bin/bash
if [ $(id -u) -ne 0 ] ; then
if [ "$(id -u)" -ne 0 ] ; then
echo "❌ Run me as root"
exit 1
fi

View file

@ -1,6 +1,6 @@
#!/bin/bash
if [ $(id -u) -ne 0 ] ; then
if [ "$(id -u)" -ne 0 ] ; then
echo "❌ Run me as root"
exit 1
fi

View file

@ -1,6 +1,6 @@
#!/bin/bash
if [ $(id -u) -ne 0 ] ; then
if [ "$(id -u)" -ne 0 ] ; then
echo "❌ Run me as root"
exit 1
fi

View file

@ -1,6 +1,6 @@
#!/bin/bash
if [ $(id -u) -ne 0 ] ; then
if [ "$(id -u)" -ne 0 ] ; then
echo "❌ Run me as root"
exit 1
fi

View file

@ -1,6 +1,6 @@
#!/bin/bash
if [ $(id -u) -ne 0 ] ; then
if [ "$(id -u)" -ne 0 ] ; then
echo "❌ Run me as root"
exit 1
fi

View file

@ -1,6 +1,6 @@
#!/bin/bash
if [ $(id -u) -ne 0 ] ; then
if [ "$(id -u)" -ne 0 ] ; then
echo "❌ Run me as root"
exit 1
fi
@ -8,9 +8,9 @@ fi
DNF=$(which dnf)
APT=$(which apt)
if [ ! -z $DNF ] ; then
if [ -n "$DNF" ] ; then
dnf install -y haproxy
elif [ ! -z $APT ] ; then
elif [ -n "$APT" ] ; then
apt install -y haproxy
fi

View file

@ -1,6 +1,6 @@
#!/bin/bash
if [ $(id -u) -ne 0 ] ; then
if [ "$(id -u)" -ne 0 ] ; then
echo "❌ Run me as root"
exit 1
fi

View file

@ -1,30 +1,38 @@
#/bin/bash
#!/bin/bash
if [ $# -ne 1 ] ; then
echo "Missing version argument"
exit 1
fi
OLD_VERSION="$(cat src/VERSION | tr -d '\n' | sed 's/\./\\./g' | sed 's/\-/\\-/g')"
OLD_VERSION="$(tr -d '\n' < src/VERSION | sed 's/\./\\./g' | sed 's/\-/\\-/g')"
NEW_VERSION="$(echo -n "$1" | sed 's/\./\\./g' | sed 's/\-/\\-/g')"
# VERSION
echo -en "$NEW_VERSION" | sed 's/\\//g' > src/VERSION
echo -en "$NEW_VERSION" | sed 's/\\//g' | tee src/VERSION
# integrations
sed -i "s@${OLD_VERSION}@${NEW_VERSION}@g" misc/integrations/*.yml
# examples
shopt -s globstar
for example in examples/* ; do
sed -i "s@${OLD_VERSION}@${NEW_VERSION}@g" ${example}/*.yml
if [ -d "$test" ] ; then
sed -i "s@${OLD_VERSION}@${NEW_VERSION}@g" "$example/*.yml"
fi
done
shopt -u globstar
# docs
sed -i "s@${OLD_VERSION}@${NEW_VERSION}@g" docs/*.md
# README
sed -i "s@${OLD_VERSION}@${NEW_VERSION}@g" README.md
# tests
sed -i "s@${OLD_VERSION}@${NEW_VERSION}@g" tests/ui/docker-compose.yml
shopt -s globstar
for test in tests/core/* ; do
sed -i "s@${OLD_VERSION}@${NEW_VERSION}@g" ${test}/docker-compose.yml
if [ -d "$test" ] ; then
sed -i "s@${OLD_VERSION}@${NEW_VERSION}@g" "$test/docker-compose.yml"
fi
done
shopt -u globstar
# linux
sed -i "s@${OLD_VERSION}@${NEW_VERSION}@g" src/linux/scripts/*.sh
# db

View file

@ -1,9 +1,12 @@
#!/bin/bash
# shellcheck disable=SC1091
. /usr/share/bunkerweb/helpers/utils.sh
ascii_array=($(ls /usr/share/bunkerweb/misc/*.ascii))
cat ${ascii_array[$(($RANDOM % ${#ascii_array[@]}))]}
shopt -s nullglob
ascii_array=(/usr/share/bunkerweb/misc/*.ascii)
shopt -u nullglob
cat "${ascii_array[$((RANDOM % ${#ascii_array[@]}))]}"
log "ENTRYPOINT" "" "Starting BunkerWeb v$(cat /usr/share/bunkerweb/VERSION) ..."
@ -12,18 +15,23 @@ log "ENTRYPOINT" "" "Starting BunkerWeb v$(cat /usr/share/bunkerweb/VERSIO
# trap SIGTERM and SIGINT
function trap_exit() {
log "ENTRYPOINT" "" "Catched stop operation"
log "ENTRYPOINT" "" "Stopping nginx ..."
# shellcheck disable=SC2317
log "ENTRYPOINT" "" "Catched stop operation, stopping nginx ..."
# shellcheck disable=SC2317
nginx -s stop
}
trap "trap_exit" TERM INT QUIT
# trap SIGHUP
function trap_reload() {
# shellcheck disable=SC2317
log "ENTRYPOINT" "" "Catched reload operation"
# shellcheck disable=SC2317
if [ -f /var/run/bunkerweb/nginx.pid ] ; then
# shellcheck disable=SC2317
log "ENTRYPOINT" "" "Reloading nginx ..."
nginx -s reload
# shellcheck disable=SC2181,SC2317
if [ $? -eq 0 ] ; then
log "ENTRYPOINT" "" "Reload successful"
else

View file

@ -6,21 +6,24 @@ function git_secure_clone() {
folder="$(echo "$repo" | sed -E "s@https://github.com/.*/(.*)\.git@\1@")"
if [ ! -d "files/${folder}" ] ; then
output="$(git clone "$repo" "files/${folder}" 2>&1)"
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "❌ Error cloning $1"
echo "$output"
exit 1
fi
old_dir="$(pwd)"
cd "files/${folder}"
cd "files/${folder}" || return 1
output="$(git checkout "${commit}^{commit}" 2>&1)"
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "❌ Commit hash $commit is absent from repository $repo"
echo "$output"
exit 1
fi
cd "$old_dir"
cd "$old_dir" || return 1
output="$(rm -rf "files/${folder}/.git")"
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "❌ Can't delete .git from repository $repo"
echo "$output"
@ -33,7 +36,7 @@ function git_secure_clone() {
function do_and_check_cmd() {
if [ "$CHANGE_DIR" != "" ] ; then
cd "$CHANGE_DIR"
cd "$CHANGE_DIR" || return 1
fi
output=$("$@" 2>&1)
ret="$?"

View file

@ -1,8 +1,10 @@
#!/bin/bash
# shellcheck disable=SC1091
. /usr/share/bunkerweb/helpers/utils.sh
service="$1"
log "$1" "" "Setup and check /data folder ..."
log "$service" "" "Setup and check /data folder ..."
# Create folders if missing and check permissions
rwx_folders=("cache" "cache/letsencrypt" "lib")
@ -10,32 +12,36 @@ rx_folders=("configs" "configs/http" "configs/stream" "configs/server-http" "con
for folder in "${rwx_folders[@]}" ; do
if [ ! -d "/data/${folder}" ] ; then
mkdir -p "/data/${folder}"
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
log "$1" "❌" "Wrong permissions on /data (RWX needed for user nginx with uid 101 and gid 101)"
log "$service" "❌" "Wrong permissions on /data (RWX needed for user nginx with uid 101 and gid 101)"
exit 1
fi
elif [ ! -r "/data/${folder}" ] || [ ! -w "/data/${folder}" ] || [ ! -x "/data/${folder}" ] ; then
log "$1" "❌" "Wrong permissions on /data/${folder} (RWX needed for user nginx with uid 101 and gid 101)"
log "$service" "❌" "Wrong permissions on /data/${folder} (RWX needed for user nginx with uid 101 and gid 101)"
exit 1
fi
done
for folder in "${rx_folders[@]}" ; do
if [ ! -d "/data/${folder}" ] ; then
mkdir -p "/data/${folder}"
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
log "$1" "❌" "Wrong permissions on /data (RWX needed for user nginx with uid 101 and gid 101)"
log "$service" "❌" "Wrong permissions on /data (RWX needed for user nginx with uid 101 and gid 101)"
exit 1
fi
elif [ ! -r "/data/${folder}" ] || [ ! -x "/data/${folder}" ] ; then
log "$1" "❌" "Wrong permissions on /data/${folder} (RX needed for user nginx with uid 101 and gid 101)"
log "$service" "❌" "Wrong permissions on /data/${folder} (RX needed for user nginx with uid 101 and gid 101)"
exit 1
fi
done
# Check permissions on files
IFS=$'\n'
for file in $(find /data -type f) ; do
if [ ! -r "${file}" ] ; then
log "$1" "❌" "Wrong permissions on ${file} (at least R needed for user nginx with uid 101 and gid 101)"
shopt -s globstar
for file in /data/**/*; do
if [[ -f "$file" ]] && [[ ! -r "$file" ]] ; then
log "$service" "❌" "Wrong permissions on ${file} (at least R needed for user nginx with uid 101 and gid 101)"
exit 1
fi
done

View file

@ -5,6 +5,7 @@ if [ ! -f /var/run/bunkerweb/nginx.pid ] ; then
fi
check="$(curl -s -H "Host: healthcheck.bunkerweb.io" http://127.0.0.1:6000/healthz 2>&1)"
# shellcheck disable=SC2181
if [ $? -ne 0 ] || [ "$check" != "ok" ] ; then
exit 1
fi

View file

@ -36,7 +36,7 @@ function spaces_to_lua() {
function has_value() {
envs=$(find /etc/nginx -name "*.env")
for file in $envs ; do
if [ "$(grep "^${1}=${2}$" $file)" != "" ] ; then
if [ "$(grep "^${1}=${2}$" "$file")" != "" ] ; then
echo "$file"
fi
done

View file

@ -11,51 +11,51 @@ function do_and_check_cmd() {
return 0
}
jq -c .download[] src/deps/deps.json | while read download
jq -c .download[] src/deps/deps.json | while read -r download
do
url="$(echo $download | jq -r .url)"
id="$(echo $url | sed 's/.*\/\([^\/]*\)\.tar\.gz/\1/')"
name="$(echo $download | jq -r .name)"
sha512="$(echo $download | jq -r .sha512)"
url="$(echo "$download" | jq -r .url)"
id="$(echo "$url" | sed 's/.*\/\([^\/]*\)\.tar\.gz/\1/')"
name="$(echo "$download" | jq -r .name)"
sha512="$(echo "$download" | jq -r .sha512)"
echo " Downloading ${name} from ${url}"
echo " Downloading ${name} from $url"
if [ ! -d "src/deps/src/${id}" ] ; then
do_and_check_cmd wget -q -O "src/deps/src/${id}.tar.gz" "$url"
check="$(sha512sum "src/deps/src/${id}.tar.gz" | cut -d ' ' -f 1)"
if [ ! -d "src/deps/src/$id" ] ; then
do_and_check_cmd wget -q -O "src/deps/src/$id.tar.gz" "$url"
check="$(sha512sum "src/deps/src/$id.tar.gz" | cut -d ' ' -f 1)"
if [ "$check" != "$sha512" ] ; then
echo "❌️ Wrong hash from file $url (expected $sha512 got $check)"
exit 1
fi
if [ -f "src/deps/src/${id}.tar.gz" ] ; then
do_and_check_cmd tar -xvzf src/deps/src/${id}.tar.gz -C src/deps/src
do_and_check_cmd rm -f src/deps/src/${id}.tar.gz
if [ -f "src/deps/src/$id.tar.gz" ] ; then
do_and_check_cmd tar -xvzf src/deps/src/"$id".tar.gz -C src/deps/src
do_and_check_cmd rm -f src/deps/src/"$id".tar.gz
fi
else
echo "⚠️ Skipping download of $url because target directory is already present"
fi
done
jq -c .git_repository[] src/deps/deps.json | while read repo
jq -c .git_repository[] src/deps/deps.json | while read -r repo
do
id="$(echo $repo | jq -r .id)"
name="$(echo $repo | jq -r .name)"
url="$(echo $repo | jq -r .url)"
commit="$(echo $repo | jq -r .commit)"
post_install="$(echo $repo | jq -r .post_install)"
id="$(echo "$repo" | jq -r .id)"
name="$(echo "$repo" | jq -r .name)"
url="$(echo "$repo" | jq -r .url)"
commit="$(echo "$repo" | jq -r .commit)"
post_install="$(echo "$repo" | jq -r .post_install)"
echo " Clone ${name} from ${url} at commit/version ${commit}"
echo " Clone ${name} from $url at commit/version $commit"
if [ ! -d "src/deps/src/${id}" ] ; then
do_and_check_cmd git subtree add --prefix src/deps/src/${id} ${url} ${commit} --squash
if [ ! -d "src/deps/src/$id" ] ; then
do_and_check_cmd git subtree add --prefix "src/deps/src/$id" "$url" "$commit" --squash
else
echo "⚠️ Skipping clone of $url because target directory is already present"
echo " Updating ${name} from ${url} at commit/version ${commit}"
do_and_check_cmd git subtree pull --prefix src/deps/src/${id} ${url} ${commit} --squash
echo " Updating ${name} from $url at commit/version $commit"
do_and_check_cmd git subtree pull --prefix "src/deps/src/$id" "$url" "$commit" --squash
fi
if [ -d "src/deps/src/${id}/.git" ] ; then
do_and_check_cmd rm -rf "src/deps/src/${id}/.git"
if [ -d "src/deps/src/$id/.git" ] ; then
do_and_check_cmd rm -rf "src/deps/src/$id/.git"
fi
if [ "$post_install" != "null" ] ; then

View file

@ -2,7 +2,7 @@
function do_and_check_cmd() {
if [ "$CHANGE_DIR" != "" ] ; then
cd "$CHANGE_DIR"
cd "$CHANGE_DIR" || return 1
fi
output=$("$@" 2>&1)
ret="$?"
@ -11,152 +11,180 @@ function do_and_check_cmd() {
echo "$output"
exit $ret
fi
#echo $output
return 0
}
NTASK=$(nproc)
NTASK="$(nproc)"
# Compiling and installing lua
echo " Compiling and installing lua-5.1.5"
CHANGE_DIR="/tmp/bunkerweb/deps/src/lua-5.1.5" do_and_check_cmd make -j $NTASK linux
CHANGE_DIR="/tmp/bunkerweb/deps/src/lua-5.1.5" do_and_check_cmd make INSTALL_TOP=/usr/share/bunkerweb/deps install
export CHANGE_DIR="/tmp/bunkerweb/deps/src/lua-5.1.5"
do_and_check_cmd make -j "$NTASK" linux
do_and_check_cmd make INSTALL_TOP=/usr/share/bunkerweb/deps install
# Compiling and installing libmaxminddb
echo " Compiling and installing libmaxminddb"
# TODO : temp fix run it twice...
cd /tmp/bunkerweb/deps/src/libmaxminddb && ./bootstrap > /dev/null 2>&1
CHANGE_DIR="/tmp/bunkerweb/deps/src/libmaxminddb" do_and_check_cmd ./bootstrap
CHANGE_DIR="/tmp/bunkerweb/deps/src/libmaxminddb" do_and_check_cmd ./configure --prefix=/usr/share/bunkerweb/deps --disable-tests
CHANGE_DIR="/tmp/bunkerweb/deps/src/libmaxminddb" do_and_check_cmd make -j $NTASK
CHANGE_DIR="/tmp/bunkerweb/deps/src/libmaxminddb" do_and_check_cmd make install
export CHANGE_DIR="/tmp/bunkerweb/deps/src/libmaxminddb"
do_and_check_cmd ./bootstrap
do_and_check_cmd ./configure --prefix=/usr/share/bunkerweb/deps --disable-tests
do_and_check_cmd make -j "$NTASK"
do_and_check_cmd make install
# Compiling and installing zlib
echo " Compiling and installing zlib"
CHANGE_DIR="/tmp/bunkerweb/deps/src/zlib" do_and_check_cmd ./configure --prefix=/usr/share/bunkerweb/deps --libdir=/usr/share/bunkerweb/deps/lib/lua
CHANGE_DIR="/tmp/bunkerweb/deps/src/zlib" do_and_check_cmd make -j $NTASK
CHANGE_DIR="/tmp/bunkerweb/deps/src/zlib" do_and_check_cmd make install
export CHANGE_DIR="/tmp/bunkerweb/deps/src/zlib"
do_and_check_cmd ./configure --prefix=/usr/share/bunkerweb/deps --libdir=/usr/share/bunkerweb/deps/lib/lua
do_and_check_cmd make -j "$NTASK"
do_and_check_cmd make install
# Compiling and installing ModSecurity
echo " Compiling and installing ModSecurity"
# temp fix : Debian run it twice
# TODO : patch it in clone.sh
do_and_check_cmd mv /tmp/bunkerweb/deps/src/libinjection /tmp/bunkerweb/deps/src/modsecurity/others/libinjection
cd /tmp/bunkerweb/deps/src/modsecurity && ./build.sh > /dev/null 2>&1
CHANGE_DIR="/tmp/bunkerweb/deps/src/modsecurity" do_and_check_cmd sh build.sh
CHANGE_DIR="/tmp/bunkerweb/deps/src/modsecurity" do_and_check_cmd ./configure --disable-dependency-tracking --disable-static --disable-examples --disable-doxygen-doc --disable-doxygen-html --disable-valgrind-memcheck --disable-valgrind-helgrind --prefix=/usr/share/bunkerweb/deps --with-maxmind=/usr/share/bunkerweb/deps
CHANGE_DIR="/tmp/bunkerweb/deps/src/modsecurity" do_and_check_cmd make -j $NTASK
CHANGE_DIR="/tmp/bunkerweb/deps/src/modsecurity" do_and_check_cmd make install-strip
export CHANGE_DIR="/tmp/bunkerweb/deps/src/modsecurity"
do_and_check_cmd ./build.sh
do_and_check_cmd sh build.sh
do_and_check_cmd ./configure --disable-dependency-tracking --disable-static --disable-examples --disable-doxygen-doc --disable-doxygen-html --disable-valgrind-memcheck --disable-valgrind-helgrind --prefix=/usr/share/bunkerweb/deps --with-maxmind=/usr/share/bunkerweb/deps
do_and_check_cmd make -j "$NTASK"
do_and_check_cmd make install-strip
# Compiling and installing luajit
echo " Compiling and installing luajit"
CHANGE_DIR="/tmp/bunkerweb/deps/src/luajit" do_and_check_cmd make -j $NTASK
CHANGE_DIR="/tmp/bunkerweb/deps/src/luajit" do_and_check_cmd make PREFIX=/usr/share/bunkerweb/deps install
export CHANGE_DIR="/tmp/bunkerweb/deps/src/luajit"
do_and_check_cmd make -j "$NTASK"
do_and_check_cmd make PREFIX=/usr/share/bunkerweb/deps install
# Installing lua-resty-core
echo " Installing openresty/lua-resty-core"
CHANGE_DIR="/tmp/bunkerweb/deps/src/lua-resty-core" do_and_check_cmd make PREFIX=/usr/share/bunkerweb/deps install
export CHANGE_DIR="/tmp/bunkerweb/deps/src/lua-resty-core"
do_and_check_cmd make PREFIX=/usr/share/bunkerweb/deps install
# Installing lua-resty-lrucache
echo " Installing lua-resty-lrucache"
CHANGE_DIR="/tmp/bunkerweb/deps/src/lua-resty-lrucache" do_and_check_cmd make PREFIX=/usr/share/bunkerweb/deps install
export CHANGE_DIR="/tmp/bunkerweb/deps/src/lua-resty-lrucache"
do_and_check_cmd make PREFIX=/usr/share/bunkerweb/deps install
# Installing lua-resty-dns
echo " Installing lua-resty-dns"
CHANGE_DIR="/tmp/bunkerweb/deps/src/lua-resty-dns" do_and_check_cmd make PREFIX=/usr/share/bunkerweb/deps install
export CHANGE_DIR="/tmp/bunkerweb/deps/src/lua-resty-dns"
do_and_check_cmd make PREFIX=/usr/share/bunkerweb/deps install
# Installing lua-resty-session
echo " Installing lua-resty-session"
do_and_check_cmd mv /tmp/bunkerweb/deps/src/lua-resty-session/lib/resty/* /usr/share/bunkerweb/deps/lib/lua/resty/
export CHANGE_DIR="/tmp/bunkerweb/deps/src/lua-resty-session"
do_and_check_cmd bash -c "mv lib/resty/* /usr/share/bunkerweb/deps/lib/lua/resty/"
# Installing lua-resty-random
echo " Installing lua-resty-random"
CHANGE_DIR="/tmp/bunkerweb/deps/src/lua-resty-random" do_and_check_cmd make PREFIX=/usr/share/bunkerweb/deps install
export CHANGE_DIR="/tmp/bunkerweb/deps/src/lua-resty-random"
do_and_check_cmd make PREFIX=/usr/share/bunkerweb/deps install
# Installing lua-resty-string
echo " Installing lua-resty-string"
CHANGE_DIR="/tmp/bunkerweb/deps/src/lua-resty-string" do_and_check_cmd make PREFIX=/usr/share/bunkerweb/deps install
export CHANGE_DIR="/tmp/bunkerweb/deps/src/lua-resty-string"
do_and_check_cmd make PREFIX=/usr/share/bunkerweb/deps install
# Compiling and installing lua-cjson
echo " Compiling and installing lua-cjson"
CHANGE_DIR="/tmp/bunkerweb/deps/src/lua-cjson" do_and_check_cmd make LUA_INCLUDE_DIR=/usr/share/bunkerweb/deps/include -j $NTASK
CHANGE_DIR="/tmp/bunkerweb/deps/src/lua-cjson" do_and_check_cmd make PREFIX=/usr/share/bunkerweb/deps LUA_CMODULE_DIR=/usr/share/bunkerweb/deps/lib/lua LUA_MODULE_DIR=/usr/share/bunkerweb/deps/lib/lua install
CHANGE_DIR="/tmp/bunkerweb/deps/src/lua-cjson" do_and_check_cmd make PREFIX=/usr/share/bunkerweb/deps LUA_CMODULE_DIR=/usr/share/bunkerweb/deps/lib/lua LUA_MODULE_DIR=/usr/share/bunkerweb/deps/lib/lua install-extra
export CHANGE_DIR="/tmp/bunkerweb/deps/src/lua-cjson"
do_and_check_cmd make LUA_INCLUDE_DIR=/usr/share/bunkerweb/deps/include -j "$NTASK"
do_and_check_cmd make PREFIX=/usr/share/bunkerweb/deps LUA_CMODULE_DIR=/usr/share/bunkerweb/deps/lib/lua LUA_MODULE_DIR=/usr/share/bunkerweb/deps/lib/lua install
do_and_check_cmd make PREFIX=/usr/share/bunkerweb/deps LUA_CMODULE_DIR=/usr/share/bunkerweb/deps/lib/lua LUA_MODULE_DIR=/usr/share/bunkerweb/deps/lib/lua install-extra
# Compiling and installing lua-gd
echo " Compiling and installing lua-gd"
CHANGE_DIR="/tmp/bunkerweb/deps/src/lua-gd" do_and_check_cmd make "CFLAGS=-O3 -Wall -fPIC -fomit-frame-pointer -I/usr/share/bunkerweb/deps/include -DVERSION=\\\"2.0.33r3\\\"" "LFLAGS=-shared -L/usr/share/bunkerweb/deps/lib -llua -lgd -Wl,-rpath=/usr/share/bunkerweb/deps/lib" LUABIN=/usr/share/bunkerweb/deps/bin/lua -j $NTASK
CHANGE_DIR="/tmp/bunkerweb/deps/src/lua-gd" do_and_check_cmd make INSTALL_PATH=/usr/share/bunkerweb/deps/lib/lua install
export CHANGE_DIR="/tmp/bunkerweb/deps/src/lua-gd"
do_and_check_cmd make "CFLAGS=-O3 -Wall -fPIC -fomit-frame-pointer -I/usr/share/bunkerweb/deps/include -DVERSION=\\\"2.0.33r3\\\"" "LFLAGS=-shared -L/usr/share/bunkerweb/deps/lib -llua -lgd -Wl,-rpath=/usr/share/bunkerweb/deps/lib" LUABIN=/usr/share/bunkerweb/deps/bin/lua -j "$NTASK"
do_and_check_cmd make INSTALL_PATH=/usr/share/bunkerweb/deps/lib/lua install
# Download and install lua-resty-http
echo " Installing lua-resty-http"
CHANGE_DIR="/tmp/bunkerweb/deps/src/lua-resty-http" do_and_check_cmd make PREFIX=/usr/share/bunkerweb/deps install
export CHANGE_DIR="/tmp/bunkerweb/deps/src/lua-resty-http"
do_and_check_cmd make PREFIX=/usr/share/bunkerweb/deps install
# Download and install lualogging
echo " Installing lualogging"
do_and_check_cmd mv /tmp/bunkerweb/deps/src/lualogging/src/* /usr/share/bunkerweb/deps/lib/lua/
export CHANGE_DIR="/tmp/bunkerweb/deps/src/lualogging"
do_and_check_cmd bash -c "mv src/* /usr/share/bunkerweb/deps/lib/lua/"
# Compiling and installing luasocket
echo " Compiling and installing luasocket"
CHANGE_DIR="/tmp/bunkerweb/deps/src/luasocket" do_and_check_cmd make LUAINC_linux=/usr/share/bunkerweb/deps/include -j $NTASK
CHANGE_DIR="/tmp/bunkerweb/deps/src/luasocket" do_and_check_cmd make prefix=/usr/share/bunkerweb/deps CDIR_linux=lib/lua LDIR_linux=lib/lua install
export CHANGE_DIR="/tmp/bunkerweb/deps/src/luasocket"
do_and_check_cmd make LUAINC_linux=/usr/share/bunkerweb/deps/include -j "$NTASK"
do_and_check_cmd make prefix=/usr/share/bunkerweb/deps CDIR_linux=lib/lua LDIR_linux=lib/lua install
# Compiling and installing luasec
echo " Compiling and installing luasec"
CHANGE_DIR="/tmp/bunkerweb/deps/src/luasec" do_and_check_cmd make INC_PATH=-I/usr/share/bunkerweb/deps/include linux -j $NTASK
CHANGE_DIR="/tmp/bunkerweb/deps/src/luasec" do_and_check_cmd make LUACPATH=/usr/share/bunkerweb/deps/lib/lua LUAPATH=/usr/share/bunkerweb/deps/lib/lua install
export CHANGE_DIR="/tmp/bunkerweb/deps/src/luasec"
do_and_check_cmd make INC_PATH=-I/usr/share/bunkerweb/deps/include linux -j "$NTASK"
do_and_check_cmd make LUACPATH=/usr/share/bunkerweb/deps/lib/lua LUAPATH=/usr/share/bunkerweb/deps/lib/lua install
# Installing lua-resty-ipmatcher
echo " Installing lua-resty-ipmatcher"
CHANGE_DIR="/tmp/bunkerweb/deps/src/lua-resty-ipmatcher" do_and_check_cmd make INST_PREFIX=/usr/share/bunkerweb/deps INST_LIBDIR=/usr/share/bunkerweb/deps/lib/lua INST_LUADIR=/usr/share/bunkerweb/deps/lib/lua install
export CHANGE_DIR="/tmp/bunkerweb/deps/src/lua-resty-ipmatcher"
do_and_check_cmd make INST_PREFIX=/usr/share/bunkerweb/deps INST_LIBDIR=/usr/share/bunkerweb/deps/lib/lua INST_LUADIR=/usr/share/bunkerweb/deps/lib/lua install
# Installing lua-resty-redis
echo " Installing lua-resty-redis"
CHANGE_DIR="/tmp/bunkerweb/deps/src/lua-resty-redis" do_and_check_cmd make PREFIX=/usr/share/bunkerweb/deps LUA_LIB_DIR=/usr/share/bunkerweb/deps/lib/lua install
export CHANGE_DIR="/tmp/bunkerweb/deps/src/lua-resty-redis"
do_and_check_cmd make PREFIX=/usr/share/bunkerweb/deps LUA_LIB_DIR=/usr/share/bunkerweb/deps/lib/lua install
# Installing lua-resty-upload
echo " Installing lua-resty-upload"
CHANGE_DIR="/tmp/bunkerweb/deps/src/lua-resty-upload" do_and_check_cmd make PREFIX=/usr/share/bunkerweb/deps LUA_LIB_DIR=/usr/share/bunkerweb/deps/lib/lua install
export CHANGE_DIR="/tmp/bunkerweb/deps/src/lua-resty-upload"
do_and_check_cmd make PREFIX=/usr/share/bunkerweb/deps LUA_LIB_DIR=/usr/share/bunkerweb/deps/lib/lua install
# Installing lujit-geoip
echo " Installing luajit-geoip"
do_and_check_cmd mv /tmp/bunkerweb/deps/src/luajit-geoip/geoip /usr/share/bunkerweb/deps/lib/lua/
export CHANGE_DIR="/tmp/bunkerweb/deps/src/luajit-geoip"
do_and_check_cmd bash -c "mv geoip /usr/share/bunkerweb/deps/lib/lua/"
# Installing lbase64
echo " Installing lbase64"
do_and_check_cmd mv /tmp/bunkerweb/deps/src/lbase64/base64.lua /usr/share/bunkerweb/deps/lib/lua/
export CHANGE_DIR="/tmp/bunkerweb/deps/src/lbase64"
do_and_check_cmd bash -c "mv base64.lua /usr/share/bunkerweb/deps/lib/lua/"
# Installing lua-resty-env
echo " Installing lua-resty-env"
do_and_check_cmd mv /tmp/bunkerweb/deps/src/lua-resty-env/src/resty/env.lua /usr/share/bunkerweb/deps/lib/lua/resty/
export CHANGE_DIR="/tmp/bunkerweb/deps/src/lua-resty-env"
do_and_check_cmd bash -c "mv src/resty/env.lua /usr/share/bunkerweb/deps/lib/lua/resty/"
# Installing lua-resty-mlcache
echo " Installing lua-resty-mlcache"
do_and_check_cmd mv /tmp/bunkerweb/deps/src/lua-resty-mlcache/lib/resty/* /usr/share/bunkerweb/deps/lib/lua/resty/
export CHANGE_DIR="/tmp/bunkerweb/deps/src/lua-resty-mlcache"
do_and_check_cmd bash -c "mv lib/resty/* /usr/share/bunkerweb/deps/lib/lua/resty/"
# Installing lua-resty-template
echo " Installing lua-resty-template"
do_and_check_cmd mv /tmp/bunkerweb/deps/src/lua-resty-template/lib/resty/* /usr/share/bunkerweb/deps/lib/lua/resty/
export CHANGE_DIR="/tmp/bunkerweb/deps/src/lua-resty-template"
do_and_check_cmd bash -c "mv lib/resty/* /usr/share/bunkerweb/deps/lib/lua/resty/"
# Installing lua-resty-lock
echo " Installing lua-resty-lock"
CHANGE_DIR="/tmp/bunkerweb/deps/src/lua-resty-lock" do_and_check_cmd make PREFIX=/usr/share/bunkerweb/deps LUA_LIB_DIR=/usr/share/bunkerweb/deps/lib/lua install
export CHANGE_DIR="/tmp/bunkerweb/deps/src/lua-resty-lock"
do_and_check_cmd make PREFIX=/usr/share/bunkerweb/deps LUA_LIB_DIR=/usr/share/bunkerweb/deps/lib/lua install
# Installing lua-resty-openssl
echo " Installing lua-resty-openssl"
CHANGE_DIR="/tmp/bunkerweb/deps/src/lua-resty-openssl" do_and_check_cmd make LUA_LIB_DIR=/usr/share/bunkerweb/deps/lib/lua install
do_and_check_cmd mv /tmp/bunkerweb/deps/src/lua-resty-openssl/lib/resty/openssl.lua /usr/share/bunkerweb/deps/lib/lua/resty/
export CHANGE_DIR="/tmp/bunkerweb/deps/src/lua-resty-openssl"
do_and_check_cmd make LUA_LIB_DIR=/usr/share/bunkerweb/deps/lib/lua install
do_and_check_cmd bash -c "mv lib/resty/openssl.lua /usr/share/bunkerweb/deps/lib/lua/resty/"
# Installing lua-ffi-zlib
echo " Installing lua-ffi-zlib"
do_and_check_cmd mv /tmp/bunkerweb/deps/src/lua-ffi-zlib/lib/ffi-zlib.lua /usr/share/bunkerweb/deps/lib/lua/
export CHANGE_DIR="/tmp/bunkerweb/deps/src/lua-ffi-zlib"
do_and_check_cmd bash -c "mv lib/ffi-zlib.lua /usr/share/bunkerweb/deps/lib/lua/"
# Installing lua-resty-signal
echo " Installing lua-resty-signal"
CHANGE_DIR="/tmp/bunkerweb/deps/src/lua-resty-signal" do_and_check_cmd make PREFIX=/usr/share/bunkerweb/deps -j $NTASK
CHANGE_DIR="/tmp/bunkerweb/deps/src/lua-resty-signal" do_and_check_cmd make PREFIX=/usr/share/bunkerweb/deps LUA_LIB_DIR=/usr/share/bunkerweb/deps/lib/lua install
export CHANGE_DIR="/tmp/bunkerweb/deps/src/lua-resty-signal"
do_and_check_cmd make PREFIX=/usr/share/bunkerweb/deps -j "$NTASK"
do_and_check_cmd make PREFIX=/usr/share/bunkerweb/deps LUA_LIB_DIR=/usr/share/bunkerweb/deps/lib/lua install
do_and_check_cmd mv /tmp/bunkerweb/deps/misc/ngx_http_modsecurity_access.c /tmp/bunkerweb/deps/src/modsecurity-nginx/src/
export CHANGE_DIR="/tmp/bunkerweb/deps/misc"
do_and_check_cmd bash -c "mv ngx_http_modsecurity_access.c /tmp/bunkerweb/deps/src/modsecurity-nginx/src/"
# Compile dynamic modules
echo " Compiling and installing dynamic modules"
@ -168,14 +196,20 @@ if [ "$OS" = "fedora" ] ; then
CONFARGS="$(echo -n "$CONFARGS" | sed "s/--with-ld-opt='.*'/--with-ld-opt=-lpcre/" | sed "s/--with-cc-opt='.*'//")"
fi
CHANGE_DIR="/tmp/bunkerweb/deps/src/nginx" do_and_check_cmd mv auto/configure ./
export CHANGE_DIR="/tmp/bunkerweb/deps/src/nginx"
do_and_check_cmd mv auto/configure ./
echo '#!/bin/bash' > "/tmp/bunkerweb/deps/src/nginx/configure-fix.sh"
echo "./configure $CONFARGS --add-dynamic-module=/tmp/bunkerweb/deps/src/headers-more-nginx-module --add-dynamic-module=/tmp/bunkerweb/deps/src/nginx_cookie_flag_module --add-dynamic-module=/tmp/bunkerweb/deps/src/lua-nginx-module --add-dynamic-module=/tmp/bunkerweb/deps/src/ngx_brotli --add-dynamic-module=/tmp/bunkerweb/deps/src/ngx_devel_kit --add-dynamic-module=/tmp/bunkerweb/deps/src/stream-lua-nginx-module" --add-dynamic-module=/tmp/bunkerweb/deps/src/modsecurity-nginx >> "/tmp/bunkerweb/deps/src/nginx/configure-fix.sh"
do_and_check_cmd chmod +x "/tmp/bunkerweb/deps/src/nginx/configure-fix.sh"
CHANGE_DIR="/tmp/bunkerweb/deps/src/nginx" LUAJIT_LIB="/usr/share/bunkerweb/deps/lib -Wl,-rpath,/usr/share/bunkerweb/deps/lib" LUAJIT_INC="/usr/share/bunkerweb/deps/include/luajit-2.1" MODSECURITY_LIB="/usr/share/bunkerweb/deps/lib" MODSECURITY_INC="/usr/share/bunkerweb/deps/include" do_and_check_cmd ./configure-fix.sh
CHANGE_DIR="/tmp/bunkerweb/deps/src/nginx" do_and_check_cmd make -j $NTASK modules
do_and_check_cmd chmod +x "configure-fix.sh"
export LUAJIT_LIB="/usr/share/bunkerweb/deps/lib -Wl,-rpath,/usr/share/bunkerweb/deps/lib"
export LUAJIT_INC="/usr/share/bunkerweb/deps/include/luajit-2.1"
export MODSECURITY_LIB="/usr/share/bunkerweb/deps/lib"
export MODSECURITY_INC="/usr/share/bunkerweb/deps/include"
do_and_check_cmd ./configure-fix.sh
do_and_check_cmd make -j "$NTASK" modules
do_and_check_cmd mkdir /usr/share/bunkerweb/modules
CHANGE_DIR="/tmp/bunkerweb/deps/src/nginx" do_and_check_cmd mv ./objs/*.so /usr/share/bunkerweb/modules/
do_and_check_cmd bash -c "mv ./objs/*.so /usr/share/bunkerweb/modules/"
# Dependencies are installed
echo " Dependencies for BunkerWeb successfully compiled and installed !"

View file

@ -5,6 +5,7 @@ echo "Updating python dependencies"
echo "Creating virtual environment"
# shellcheck disable=SC1091
python3 -m venv tmp_venv && source tmp_venv/bin/activate
pip install --force-reinstall --no-cache-dir --require-hashes -r requirements-deps.txt
@ -12,25 +13,25 @@ function update_python_deps() {
file=$1
echo "Updating $file"
cd $(dirname $file)
cd "$(dirname "$file")" || return
if [[ $file == *.in ]]; then
mv $(basename $file) $(basename ${file/%.in}.txt)
mv "$(basename "$file")" "$(basename "${file/%.in}.txt")"
fi
echo "all" | pip-upgrade $(basename ${file/%.in}.txt)
echo "all" | pip-upgrade "$(basename "${file/%.in}.txt")"
if [[ $file == *.in ]]; then
mv $(basename ${file/%.in}.txt) $(basename $file)
mv "$(basename "${file/%.in}.txt")" "$(basename "$file")"
echo "Generating hashes for $file ..."
pip-compile --generate-hashes --allow-unsafe --resolver=backtracking $(basename $file)
pip-compile --generate-hashes --allow-unsafe --resolver=backtracking "$(basename "$file")"
else
echo "No need to generate hashes for $file"
fi
echo " "
cd -
cd - || return
}
update_python_deps requirements-deps.in
@ -41,10 +42,12 @@ echo "Updating python requirements files"
files=("requirements.in" "../../docs/requirements.in" "../../misc/requirements-ansible.in" "../common/db/requirements.in" "../common/gen/requirements.in" "../scheduler/requirements.in" "../ui/requirements.in")
for file in $(find ../../tests -type f -iname "requirements.in")
shopt -s globstar
for file in ../../tests/**/requirements*.in
do
files+=("$file")
done
shopt -u globstar
for file in "${files[@]}"
do

View file

@ -1,6 +1,6 @@
#!/bin/bash
VERSION="$(cat /usr/share/bunkerweb/VERSION | tr -d '\n')"
VERSION="$(tr -d '\n' < /usr/share/bunkerweb/VERSION)"
ARCH="$(uname -m)"
sed -i "s/%VERSION%/${VERSION}/g" .fpm
sed -i "s/%ARCH%/${ARCH}/g" .fpm

View file

@ -2,7 +2,7 @@
function do_and_check_cmd() {
if [ "$CHANGE_DIR" != "" ] ; then
cd "$CHANGE_DIR"
cd "$CHANGE_DIR" || return 1
fi
output=$("$@" 2>&1)
ret="$?"
@ -11,8 +11,6 @@ function do_and_check_cmd() {
echo "$output"
exit $ret
fi
#echo $output
return 0
}
# Check args
@ -37,7 +35,7 @@ do_and_check_cmd mkdir "$package_dir"
# Generate package
version="$3"
if [ -f "src/VERSION" ] ; then
version="$(cat src/VERSION | tr -d '\n')"
version="$(tr -d '\n' < src/VERSION)"
fi
type="deb"
if [ "$linux" = "fedora" ] || [ "$linux" = "centos" ] || [ "$linux" = "rhel" ] ; then

View file

@ -27,8 +27,8 @@ function remove_systemd_service {
echo "checking service $service with $service_file file "
if [ -f "$service_file" ]; then
echo " Remove $service service"
do_and_check_cmd systemctl stop $service
do_and_check_cmd systemctl disable $service
do_and_check_cmd systemctl stop "$service"
do_and_check_cmd systemctl disable "$service"
do_and_check_cmd rm -f "$service_file"
reload_systemd
else
@ -107,7 +107,7 @@ function purge() {
}
# Check if we are root
if [ $(id -u) -ne 0 ] ; then
if [ "$(id -u)" -ne 0 ] ; then
echo "❌ Run me as root"
exit 1
fi

View file

@ -27,8 +27,8 @@ function remove_systemd_service {
echo "checking service $service with $service_file file "
if [ -f "$service_file" ]; then
echo " Remove $service service"
do_and_check_cmd systemctl stop $service
do_and_check_cmd systemctl disable $service
do_and_check_cmd systemctl stop "$service"
do_and_check_cmd systemctl disable "$service"
do_and_check_cmd rm -f "$service_file"
reload_systemd
else
@ -107,7 +107,7 @@ function purge() {
}
# Check if we are root
if [ $(id -u) -ne 0 ] ; then
if [ "$(id -u)" -ne 0 ] ; then
echo "❌ Run me as root"
exit 1
fi
@ -132,7 +132,7 @@ elif [ "$1" = "1" ]; then
echo "Package is being upgraded"
# Check the version of the package and if it's inferior to 1.5.2, we need to copy the variables.env file
VERSION=$(rpm -q --queryformat '%{VERSION}' bunkerweb)
if [ "$VERSION" <= "1.5.2" ]; then
if [ "$VERSION" != "1.5.2" ]; then
echo " Copy /etc/bunkerweb/variables.env to /var/tmp/bunkerweb/variables.env"
do_and_check_cmd cp -f /opt/bunkerweb/variables.env /var/tmp/variables.env
do_and_check_cmd cp -f /opt/bunkerweb/ui.env /var/tmp/ui.env
@ -141,8 +141,7 @@ elif [ "$1" = "1" ]; then
cp -f /etc/bunkerweb/ui.env /var/tmp/ui.env
cp -f /var/lib/bunkerweb/db.sqlite3 /var/tmp/db.sqlite3
exit 0
fi
else
echo "Error"
exit 0
exit 1
fi

View file

@ -17,6 +17,7 @@ function do_and_check_cmd() {
# Check the os running
if [ -f /etc/os-release ]; then
# shellcheck disable=SC1091
. /etc/os-release
OS=$NAME
if [[ "$OS" == "Ubuntu" || "$OS" == "Debian" ]]; then

View file

@ -12,7 +12,7 @@ fi
# Function to start the UI
start() {
echo "Starting UI"
export $(cat /etc/bunkerweb/ui.env)
export "$(cat /etc/bunkerweb/ui.env)"
python3 -m gunicorn \
--config /usr/share/bunkerweb/ui/gunicorn.conf.py \
--pythonpath /usr/share/bunkerweb/deps/python/,/usr/share/bunkerweb/ui/ \
@ -28,8 +28,8 @@ start() {
stop() {
echo "Stopping UI service..."
if [ -f "/var/run/bunkerweb/ui.pid" ]; then
pid=$(cat /var/run/bunkerweb/ui.pid)
kill -s TERM $pid
pid="$(cat /var/run/bunkerweb/ui.pid)"
kill -s TERM "$pid"
else
echo "UI service is not running or the pid file doesn't exist."
fi

View file

@ -34,7 +34,7 @@ do_and_check_cmd systemctl start bunkerweb
if [ -f /var/tmp/variables.env ]; then
echo "Old environment file found!"
echo "Copying old line from environment file to new one..."
while read line; do
while read -r line; do
echo "$line" >> /etc/bunkerweb/variables.env
done < /var/tmp/variables.env
# Remove old environment files
@ -51,7 +51,7 @@ fi
if [ -f /var/tmp/ui.env ]; then
echo "Old ui environment file found!"
echo "Copying old line from ui environment file to new one..."
while read line; do
while read -r line; do
echo "$line" >> /etc/bunkerweb/ui.env
done < /var/tmp/ui.env
# Remove old environment files

View file

@ -1,6 +1,7 @@
#!/bin/bash
# Source the utils helper script
# shellcheck disable=SC1091
source /usr/share/bunkerweb/helpers/utils.sh
# Set the PYTHONPATH
@ -17,27 +18,31 @@ function display_help() {
function stop_nginx() {
pgrep nginx > /dev/null 2>&1
# shellcheck disable=SC2181
if [ $? -eq 0 ] ; then
log "SYSTEMCTL" " " "Stopping nginx..."
nginx -s stop
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
log "SYSTEMCTL" "❌" "Error while sending stop signal to nginx"
log "SYSTEMCTL" " " "Stopping nginx (force)..."
kill -TERM $(cat /var/run/bunkerweb/nginx.pid)
kill -TERM "$(cat /var/run/bunkerweb/nginx.pid)"
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
log "SYSTEMCTL" "❌" "Error while sending term signal to nginx"
fi
fi
fi
count=0
while [ 1 ] ; do
while true ; do
pgrep nginx > /dev/null 2>&1
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
break
fi
log "SYSTEMCTL" " " "Waiting for nginx to stop..."
sleep 1
count=$(($count + 1))
count=$((count + 1))
if [ $count -ge 20 ] ; then
break
fi
@ -54,6 +59,7 @@ function stop_scheduler() {
scheduler_pid=$(cat "/var/run/bunkerweb/scheduler.pid")
log "SYSTEMCTL" " " "Stopping scheduler..."
kill -SIGINT "$scheduler_pid"
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
log "SYSTEMCTL" "❌" "Error while sending stop signal to scheduler"
exit 1
@ -65,7 +71,7 @@ function stop_scheduler() {
count=0
while [ -f "/var/run/bunkerweb/scheduler.pid" ] ; do
sleep 1
count=$(($count + 1))
count=$((count + 1))
if [ $count -ge 10 ] ; then
break
fi
@ -139,6 +145,7 @@ function start() {
fi
sudo -E -u nginx -g nginx /bin/bash -c "echo -ne 'IS_LOADING=yes\nUSE_BUNKERNET=no\nSERVER_NAME=\nAPI_HTTP_PORT=${API_HTTP_PORT}\nAPI_SERVER_NAME=${API_SERVER_NAME}\nAPI_WHITELIST_IP=${API_WHITELIST_IP}\nUSE_REAL_IP=${USE_REAL_IP}\nUSE_PROXY_PROTOCOL=${USE_PROXY_PROTOCOL}\nREAL_IP_FROM=${REAL_IP_FROM}\nREAL_IP_HEADER=${REAL_IP_HEADER}\nHTTP_PORT=${HTTP_PORT}\nHTTPS_PORT=${HTTPS_PORT}\n' > /var/tmp/bunkerweb/tmp.env"
sudo -E -u nginx -g nginx /bin/bash -c "PYTHONPATH=/usr/share/bunkerweb/deps/python/ /usr/share/bunkerweb/gen/main.py --variables /var/tmp/bunkerweb/tmp.env --no-linux-reload"
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
log "SYSTEMCTL" "❌" "Error while generating config from /var/tmp/bunkerweb/tmp.env"
exit 1
@ -152,6 +159,7 @@ function start() {
# Start nginx
log "SYSTEMCTL" "" "Starting temp nginx ..."
nginx -e /var/log/bunkerweb/error.log
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
log "SYSTEMCTL" "❌" "Error while executing temp nginx"
exit 1
@ -159,10 +167,11 @@ function start() {
count=0
while [ $count -lt 10 ] ; do
check="$(curl -s -H "Host: healthcheck.bunkerweb.io" http://127.0.0.1:6000/healthz 2>&1)"
# shellcheck disable=SC2181
if [ $? -eq 0 ] && [ "$check" = "ok" ] ; then
break
fi
count=$(($count + 1))
count=$((count + 1))
sleep 1
log "SYSTEMCTL" "" "Waiting for nginx to start ..."
done
@ -175,7 +184,8 @@ function start() {
# Execute scheduler
log "SYSTEMCTL" " " "Executing scheduler ..."
sudo -E -u nginx -g nginx /bin/bash -c "PYTHONPATH=/usr/share/bunkerweb/deps/python/ /usr/share/bunkerweb/scheduler/main.py --variables /etc/bunkerweb/variables.env"
if [ "$?" -ne 0 ] ; then
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
log "SYSTEMCTL" "❌" "Scheduler failed"
exit 1
fi
@ -199,12 +209,12 @@ function reload()
PID_FILE_PATH="/var/run/bunkerweb/scheduler.pid"
if [ -f "$PID_FILE_PATH" ];
then
var=$(cat "$PID_FILE_PATH")
result=$(cat "$PID_FILE_PATH")
# Send signal to scheduler to reload
log "SYSTEMCTL" "" "Sending reload signal to scheduler ..."
kill -SIGHUP $var
result=$?
if [ $result -ne 0 ] ; then
kill -SIGHUP "$result"
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
log "SYSTEMCTL" "❌" "Your command exited with non-zero status $result"
exit 1
fi

View file

@ -1,12 +1,17 @@
#!/bin/bash
# shellcheck disable=SC1091
. /usr/share/bunkerweb/helpers/utils.sh
# trap SIGTERM and SIGINT
function trap_exit() {
# shellcheck disable=SC2317
log "ENTRYPOINT" " " "Catched stop operation"
# shellcheck disable=SC2317
if [ -f "/var/run/bunkerweb/scheduler.pid" ] ; then
# shellcheck disable=SC2317
log "ENTRYPOINT" " " "Stopping job scheduler ..."
# shellcheck disable=SC2317
kill -s TERM "$(cat /var/run/bunkerweb/scheduler.pid)"
fi
}
@ -33,7 +38,8 @@ if ! grep -q "Docker" /usr/share/bunkerweb/INTEGRATION ; then
# Init database
get_env > "/tmp/variables.env"
/usr/share/bunkerweb/gen/save_config.py --variables /tmp/variables.env --init
if [ "$?" -ne 0 ] ; then
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
log "ENTRYPOINT" "❌" "Scheduler generator failed"
exit 1
fi

View file

@ -15,11 +15,13 @@ echo "🤖 Building antibot stack for integration \"$integration\" ..."
# Starting stack
if [ "$integration" == "docker" ] ; then
docker compose pull bw-docker app1
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🤖 Pull failed ❌"
exit 1
fi
docker compose -f docker-compose.test.yml build
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🤖 Build failed ❌"
exit 1
@ -59,6 +61,7 @@ cleanup_stack () {
sudo truncate -s 0 /var/log/bunkerweb/error.log
fi
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🤖 Cleanup failed ❌"
exit 1
@ -95,12 +98,14 @@ do
echo "🤖 Starting stack ..."
if [ "$integration" == "docker" ] ; then
docker compose up -d
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🤖 Up failed, retrying ... ⚠️"
manual=1
cleanup_stack
manual=0
docker compose up -d
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🤖 Up failed ❌"
exit 1
@ -108,6 +113,7 @@ do
fi
else
sudo systemctl start bunkerweb
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🤖 Start failed ❌"
exit 1
@ -122,7 +128,7 @@ do
containers=("antibot-bw-1" "antibot-bw-scheduler-1")
healthy="true"
for container in "${containers[@]}" ; do
check="$(docker inspect --format "{{json .State.Health }}" $container | grep "healthy")"
check="$(docker inspect --format "{{json .State.Health }}" "$container" | grep "healthy")"
if [ "$check" = "" ] ; then
healthy="false"
break
@ -162,7 +168,7 @@ do
exit 1
fi
if ! [ -z "$(sudo journalctl -u bunkerweb --no-pager | grep "SYSTEMCTL - ❌")" ] ; then
if sudo journalctl -u bunkerweb --no-pager | grep -q "SYSTEMCTL - ❌ " ; then
echo "🤖 ⚠ Linux stack got an issue, restarting ..."
sudo journalctl --rotate
sudo journalctl --vacuum-time=1s
@ -175,7 +181,7 @@ do
healthy="true"
fi
done
if [ $retries -ge 5 ] ; then
if [ "$retries" -ge 5 ] ; then
echo "🤖 Linux stack could not be healthy ❌"
exit 1
fi
@ -189,6 +195,7 @@ do
python3 main.py
fi
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🤖 Test \"$test\" failed ❌"
echo "🛡️ Showing BunkerWeb and BunkerWeb Scheduler logs ..."

View file

@ -15,11 +15,13 @@ echo "🔐 Building authbasic stack for integration \"$integration\" ..."
# Starting stack
if [ "$integration" == "docker" ] ; then
docker compose pull bw-docker app1
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🔐 Pull failed ❌"
exit 1
fi
docker compose -f docker-compose.test.yml build
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🔐 Build failed ❌"
exit 1
@ -67,6 +69,7 @@ cleanup_stack () {
sudo truncate -s 0 /var/log/bunkerweb/error.log
fi
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🔐 Cleanup failed ❌"
exit 1
@ -122,12 +125,14 @@ do
echo "🔐 Starting stack ..."
if [ "$integration" == "docker" ] ; then
docker compose up -d
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🔐 Up failed, retrying ... ⚠️"
manual=1
cleanup_stack
manual=0
docker compose up -d
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🔐 Up failed ❌"
exit 1
@ -135,6 +140,7 @@ do
fi
else
sudo systemctl start bunkerweb
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🔐 Start failed ❌"
exit 1
@ -149,7 +155,7 @@ do
containers=("authbasic-bw-1" "authbasic-bw-scheduler-1")
healthy="true"
for container in "${containers[@]}" ; do
check="$(docker inspect --format "{{json .State.Health }}" $container | grep "healthy")"
check="$(docker inspect --format "{{json .State.Health }}" "$container" | grep "healthy")"
if [ "$check" = "" ] ; then
healthy="false"
break
@ -189,7 +195,7 @@ do
exit 1
fi
if ! [ -z "$(sudo journalctl -u bunkerweb --no-pager | grep "SYSTEMCTL - ❌")" ] ; then
if sudo journalctl -u bunkerweb --no-pager | grep -q "SYSTEMCTL - ❌ " ; then
echo "🔐 ⚠ Linux stack got an issue, restarting ..."
sudo journalctl --rotate
sudo journalctl --vacuum-time=1s
@ -202,7 +208,7 @@ do
healthy="true"
fi
done
if [ $retries -ge 5 ] ; then
if [ "$retries" -ge 5 ] ; then
echo "🔐 Linux stack could not be healthy ❌"
exit 1
fi
@ -216,6 +222,7 @@ do
python3 main.py
fi
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🔐 Test \"$test\" failed ❌"
echo "🛡️ Showing BunkerWeb and BunkerWeb Scheduler logs ..."

View file

@ -15,11 +15,13 @@ echo "📟 Building badbehavior stack for integration \"$integration\" ..."
# Starting stack
if [ "$integration" == "docker" ] ; then
docker compose pull bw-docker
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "📟 Pull failed ❌"
exit 1
fi
docker compose -f docker-compose.test.yml build
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "📟 Build failed ❌"
exit 1
@ -73,6 +75,7 @@ cleanup_stack () {
sudo truncate -s 0 /var/log/bunkerweb/error.log
fi
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "📟 Cleanup failed ❌"
exit 1
@ -145,12 +148,14 @@ do
echo "📟 Starting stack ..."
if [ "$integration" == "docker" ] ; then
docker compose up -d
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "📟 Up failed, retrying ... ⚠️"
manual=1
cleanup_stack
manual=0
docker compose up -d
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "📟 Up failed ❌"
exit 1
@ -158,6 +163,7 @@ do
fi
else
sudo systemctl start bunkerweb
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "📟 Start failed ❌"
exit 1
@ -172,7 +178,7 @@ do
containers=("badbehavior-bw-1" "badbehavior-bw-scheduler-1")
healthy="true"
for container in "${containers[@]}" ; do
check="$(docker inspect --format "{{json .State.Health }}" $container | grep "healthy")"
check="$(docker inspect --format "{{json .State.Health }}" "$container" | grep "healthy")"
if [ "$check" = "" ] ; then
healthy="false"
break
@ -212,7 +218,7 @@ do
exit 1
fi
if ! [ -z "$(sudo journalctl -u bunkerweb --no-pager | grep "SYSTEMCTL - ❌")" ] ; then
if sudo journalctl -u bunkerweb --no-pager | grep -q "SYSTEMCTL - ❌ " ; then
echo "📟 ⚠ Linux stack got an issue, restarting ..."
sudo journalctl --rotate
sudo journalctl --vacuum-time=1s
@ -225,7 +231,7 @@ do
healthy="true"
fi
done
if [ $retries -ge 5 ] ; then
if [ "$retries" -ge 5 ] ; then
echo "📟 Linux stack could not be healthy ❌"
exit 1
fi
@ -239,6 +245,7 @@ do
sudo -E python3 main.py
fi
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "📟 Test \"$test\" failed ❌"
echo "🛡️ Showing BunkerWeb and BunkerWeb Scheduler logs ..."

View file

@ -15,6 +15,7 @@ echo "🏴 Building blacklist stack for integration \"$integration\" ..."
# Starting stack
if [ "$integration" == "docker" ] ; then
docker compose pull bw-docker
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🏴 Pull failed ❌"
exit 1
@ -22,6 +23,7 @@ if [ "$integration" == "docker" ] ; then
echo "🏴 Building custom api image ..."
docker compose build blacklist-api
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🏴 Build failed ❌"
exit 1
@ -29,6 +31,7 @@ if [ "$integration" == "docker" ] ; then
echo "🏴 Building tests images ..."
docker compose -f docker-compose.test.yml build
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🏴 Build failed ❌"
exit 1
@ -157,6 +160,7 @@ cleanup_stack () {
sudo truncate -s 0 /var/log/bunkerweb/error.log
fi
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🏴 Cleanup failed ❌"
exit 1
@ -173,6 +177,7 @@ if [ "$integration" == "docker" ] ; then
rm -rf init/output
mkdir -p init/output
docker compose -f docker-compose.init.yml up --build
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🏴 Init failed ❌"
exit 1
@ -186,6 +191,7 @@ if [ "$integration" == "docker" ] ; then
else
echo "🏴 Starting init ..."
python3 init/main.py
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🏴 Init failed ❌"
exit 1
@ -451,12 +457,14 @@ do
echo "🏴 Starting stack ..."
if [ "$integration" == "docker" ] ; then
docker compose up -d
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🏴 Up failed, retrying ... ⚠️"
manual=1
cleanup_stack
manual=0
docker compose up -d
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🏴 Up failed ❌"
exit 1
@ -464,6 +472,7 @@ do
fi
else
sudo systemctl start bunkerweb
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🏴 Start failed ❌"
exit 1
@ -478,7 +487,7 @@ do
containers=("blacklist-bw-1" "blacklist-bw-scheduler-1")
healthy="true"
for container in "${containers[@]}" ; do
check="$(docker inspect --format "{{json .State.Health }}" $container | grep "healthy")"
check="$(docker inspect --format "{{json .State.Health }}" "$container" | grep "healthy")"
if [ "$check" = "" ] ; then
healthy="false"
break
@ -518,7 +527,7 @@ do
exit 1
fi
if ! [ -z "$(sudo journalctl -u bunkerweb --no-pager | grep "SYSTEMCTL - ❌")" ] ; then
if sudo journalctl -u bunkerweb --no-pager | grep -q "SYSTEMCTL - ❌ " ; then
echo "🏴 ⚠ Linux stack got an issue, restarting ..."
sudo journalctl --rotate
sudo journalctl --vacuum-time=1s
@ -531,7 +540,7 @@ do
healthy="true"
fi
done
if [ $retries -ge 5 ] ; then
if [ "$retries" -ge 5 ] ; then
echo "🏴 Linux stack could not be healthy ❌"
exit 1
fi
@ -555,6 +564,7 @@ do
python3 main.py
fi
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🏴 Test \"$test\" failed ❌"
echo "🛡️ Showing BunkerWeb, BunkerWeb Scheduler and Custom API logs ..."

View file

@ -15,11 +15,13 @@ echo "📦 Building brotli stack for integration \"$integration\" ..."
# Starting stack
if [ "$integration" == "docker" ] ; then
docker compose pull bw-docker app1
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "📦 Pull failed ❌"
exit 1
fi
docker compose -f docker-compose.test.yml build
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "📦 Build failed ❌"
exit 1
@ -55,6 +57,7 @@ cleanup_stack () {
sudo truncate -s 0 /var/log/bunkerweb/error.log
fi
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "📦 Cleanup failed ❌"
exit 1
@ -83,12 +86,14 @@ do
echo "📦 Starting stack ..."
if [ "$integration" == "docker" ] ; then
docker compose up -d
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "📦 Up failed, retrying ... ⚠️"
manual=1
cleanup_stack
manual=0
docker compose up -d
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "📦 Up failed ❌"
exit 1
@ -96,6 +101,7 @@ do
fi
else
sudo systemctl start bunkerweb
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "📦 Start failed ❌"
exit 1
@ -110,7 +116,7 @@ do
containers=("brotli-bw-1" "brotli-bw-scheduler-1")
healthy="true"
for container in "${containers[@]}" ; do
check="$(docker inspect --format "{{json .State.Health }}" $container | grep "healthy")"
check="$(docker inspect --format "{{json .State.Health }}" "$container" | grep "healthy")"
if [ "$check" = "" ] ; then
healthy="false"
break
@ -150,7 +156,7 @@ do
exit 1
fi
if ! [ -z "$(sudo journalctl -u bunkerweb --no-pager | grep "SYSTEMCTL - ❌")" ] ; then
if sudo journalctl -u bunkerweb --no-pager | grep -q "SYSTEMCTL - ❌ " ; then
echo "📦 ⚠ Linux stack got an issue, restarting ..."
sudo journalctl --rotate
sudo journalctl --vacuum-time=1s
@ -163,7 +169,7 @@ do
healthy="true"
fi
done
if [ $retries -ge 5 ] ; then
if [ "$retries" -ge 5 ] ; then
echo "📦 Linux stack could not be healthy ❌"
exit 1
fi
@ -177,6 +183,7 @@ do
python3 main.py
fi
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "📦 Test \"$test\" failed ❌"
echo "🛡️ Showing BunkerWeb and BunkerWeb Scheduler logs ..."

View file

@ -15,6 +15,7 @@ echo "🕸️ Building bunkernet stack for integration \"$integration\" ..."
# Starting stack
if [ "$integration" == "docker" ] ; then
docker compose pull bw-docker
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🕸️ Pull failed ❌"
exit 1
@ -22,6 +23,7 @@ if [ "$integration" == "docker" ] ; then
echo "🕸️ Building custom api image ..."
docker compose build bunkernet-api
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🕸️ Build failed ❌"
exit 1
@ -29,6 +31,7 @@ if [ "$integration" == "docker" ] ; then
echo "🕸️ Building tests images ..."
docker compose -f docker-compose.test.yml build
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🕸️ Build failed ❌"
exit 1
@ -71,6 +74,7 @@ cleanup_stack () {
sudo truncate -s 0 /var/log/bunkerweb/error.log
fi
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🕸️ Cleanup failed ❌"
exit 1
@ -99,12 +103,14 @@ do
echo "🕸️ Starting stack ..."
if [ "$integration" == "docker" ] ; then
docker compose up -d
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🕸️ Up failed, retrying ... ⚠️"
manual=1
cleanup_stack
manual=0
docker compose up -d
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🕸️ Up failed ❌"
exit 1
@ -112,6 +118,7 @@ do
fi
else
sudo systemctl start bunkerweb
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🕸️ Start failed ❌"
exit 1
@ -126,7 +133,7 @@ do
containers=("bunkernet-bw-1" "bunkernet-bw-scheduler-1")
healthy="true"
for container in "${containers[@]}" ; do
check="$(docker inspect --format "{{json .State.Health }}" $container | grep "healthy")"
check="$(docker inspect --format "{{json .State.Health }}" "$container" | grep "healthy")"
if [ "$check" = "" ] ; then
healthy="false"
break
@ -166,7 +173,7 @@ do
exit 1
fi
if ! [ -z "$(sudo journalctl -u bunkerweb --no-pager | grep "SYSTEMCTL - ❌")" ] ; then
if sudo journalctl -u bunkerweb --no-pager | grep -q "SYSTEMCTL - ❌ " ; then
echo "🕸️ ⚠ Linux stack got an issue, restarting ..."
sudo journalctl --rotate
sudo journalctl --vacuum-time=1s
@ -179,7 +186,7 @@ do
healthy="true"
fi
done
if [ $retries -ge 5 ] ; then
if [ "$retries" -ge 5 ] ; then
echo "🕸️ Linux stack could not be healthy ❌"
exit 1
fi
@ -193,6 +200,7 @@ do
python3 main.py
fi
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🕸️ Test \"$test\" failed ❌"
echo "🛡️ Showing BunkerWeb, BunkerWeb Scheduler and Custom API logs ..."

View file

@ -15,11 +15,13 @@ echo "⌨️ Building bwcli stack for integration \"$integration\" ..."
# Starting stack
if [ "$integration" == "docker" ] ; then
docker compose pull bw-docker
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "⌨️ Pull failed ❌"
exit 1
fi
docker compose -f docker-compose.test.yml build
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "⌨️ Build failed ❌"
exit 1
@ -31,6 +33,7 @@ else
echo "⌨️ Installing Redis ..."
sudo apt install --no-install-recommends -y redis
redis-server --daemonize yes
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "⌨️ Redis start failed ❌"
exit 1
@ -54,6 +57,7 @@ cleanup_stack () {
sudo truncate -s 0 /var/log/bunkerweb/error.log
fi
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "⌨️ Cleanup failed ❌"
exit 1
@ -70,12 +74,12 @@ echo "⌨️ Running bwcli tests ..."
echo "⌨️ Starting stack ..."
if [ "$integration" == "docker" ] ; then
docker compose up -d
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "⌨️ Up failed, retrying ... ⚠️"
manual=1
cleanup_stack
manual=0
docker compose up -d
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "⌨️ Up failed ❌"
exit 1
@ -83,6 +87,7 @@ if [ "$integration" == "docker" ] ; then
fi
else
sudo systemctl start bunkerweb
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "⌨️ Start failed ❌"
exit 1
@ -97,7 +102,7 @@ if [ "$integration" == "docker" ] ; then
containers=("bwcli-bw-1" "bwcli-bw-scheduler-1")
healthy="true"
for container in "${containers[@]}" ; do
check="$(docker inspect --format "{{json .State.Health }}" $container | grep "healthy")"
check="$(docker inspect --format "{{json .State.Health }}" "$container" | grep "healthy")"
if [ "$check" = "" ] ; then
healthy="false"
break
@ -137,20 +142,18 @@ else
exit 1
fi
if ! [ -z "$(sudo journalctl -u bunkerweb --no-pager | grep "SYSTEMCTL - ❌")" ] ; then
if sudo journalctl -u bunkerweb --no-pager | grep -q "SYSTEMCTL - ❌ " ; then
echo "⌨️ ⚠ Linux stack got an issue, restarting ..."
sudo journalctl --rotate
sudo journalctl --vacuum-time=1s
manual=1
cleanup_stack
manual=0
sudo systemctl start bunkerweb
retries=$((retries+1))
else
healthy="true"
fi
done
if [ $retries -ge 5 ] ; then
if [ "$retries" -ge 5 ] ; then
echo "⌨️ Linux stack could not be healthy ❌"
exit 1
fi
@ -164,6 +167,7 @@ else
sudo python3 linux.py
fi
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "⌨️ Test bwcli failed ❌"
echo "🛡️ Showing BunkerWeb and BunkerWeb Scheduler logs ..."

View file

@ -15,11 +15,13 @@ echo "📝 Building clientcache stack for integration \"$integration\" ..."
# Starting stack
if [ "$integration" == "docker" ] ; then
docker compose pull bw-docker
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "📝 Pull failed ❌"
exit 1
fi
docker compose -f docker-compose.test.yml build
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "📝 Build failed ❌"
exit 1
@ -68,6 +70,7 @@ cleanup_stack () {
sudo truncate -s 0 /var/log/bunkerweb/error.log
fi
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "📝 Cleanup failed ❌"
exit 1
@ -126,12 +129,14 @@ do
echo "📝 Starting stack ..."
if [ "$integration" == "docker" ] ; then
docker compose up -d
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "📝 Up failed, retrying ... ⚠️"
manual=1
cleanup_stack
manual=0
docker compose up -d
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "📝 Up failed ❌"
exit 1
@ -139,6 +144,7 @@ do
fi
else
sudo systemctl start bunkerweb
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "📝 Start failed ❌"
exit 1
@ -153,7 +159,7 @@ do
containers=("clientcache-bw-1" "clientcache-bw-scheduler-1")
healthy="true"
for container in "${containers[@]}" ; do
check="$(docker inspect --format "{{json .State.Health }}" $container | grep "healthy")"
check="$(docker inspect --format "{{json .State.Health }}" "$container" | grep "healthy")"
if [ "$check" = "" ] ; then
healthy="false"
break
@ -193,7 +199,7 @@ do
exit 1
fi
if ! [ -z "$(sudo journalctl -u bunkerweb --no-pager | grep "SYSTEMCTL - ❌")" ] ; then
if sudo journalctl -u bunkerweb --no-pager | grep -q "SYSTEMCTL - ❌ " ; then
echo "📝 ⚠ Linux stack got an issue, restarting ..."
sudo journalctl --rotate
sudo journalctl --vacuum-time=1s
@ -206,7 +212,7 @@ do
healthy="true"
fi
done
if [ $retries -ge 5 ] ; then
if [ "$retries" -ge 5 ] ; then
echo "📝 Linux stack could not be healthy ❌"
exit 1
fi
@ -220,6 +226,7 @@ do
python3 main.py
fi
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "📝 Test \"$test\" failed ❌"
echo "🛡️ Showing BunkerWeb and BunkerWeb Scheduler logs ..."

View file

@ -1,6 +1,6 @@
#!/bin/bash
if [ $(id -u) -ne 0 ] ; then
if [ "$(id -u)" -ne 0 ] ; then
echo "❌ Run me as root"
exit 1
fi

View file

@ -15,11 +15,13 @@ echo "🛰️ Building cors stack for integration \"$integration\" ..."
# Starting stack
if [ "$integration" == "docker" ] ; then
docker compose pull bw-docker app1
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🛰️ Pull failed ❌"
exit 1
fi
docker compose -f docker-compose.test.yml build
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🛰️ Build failed ❌"
exit 1
@ -89,6 +91,7 @@ cleanup_stack () {
sudo truncate -s 0 /var/log/bunkerweb/error.log
fi
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🛰️ Cleanup failed ❌"
exit 1
@ -103,6 +106,7 @@ trap cleanup_stack EXIT
if [ "$integration" == "docker" ] ; then
echo "🛰️ Initializing workspace ..."
docker compose -f docker-compose.init.yml up --build
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🛰️ Build failed ❌"
exit 1
@ -163,12 +167,14 @@ do
echo "🛰️ Starting stack ..."
if [ "$integration" == "docker" ] ; then
docker compose up -d
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🛰️ Up failed, retrying ... ⚠️"
manual=1
cleanup_stack
manual=0
docker compose up -d
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🛰️ Up failed ❌"
exit 1
@ -176,6 +182,7 @@ do
fi
else
sudo systemctl start bunkerweb
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🛰️ Start failed ❌"
exit 1
@ -190,7 +197,7 @@ do
containers=("cors-bw-1" "cors-bw-scheduler-1")
healthy="true"
for container in "${containers[@]}" ; do
check="$(docker inspect --format "{{json .State.Health }}" $container | grep "healthy")"
check="$(docker inspect --format "{{json .State.Health }}" "$container" | grep "healthy")"
if [ "$check" = "" ] ; then
healthy="false"
break
@ -230,7 +237,7 @@ do
exit 1
fi
if ! [ -z "$(sudo journalctl -u bunkerweb --no-pager | grep "SYSTEMCTL - ❌")" ] ; then
if sudo journalctl -u bunkerweb --no-pager | grep -q "SYSTEMCTL - ❌ " ; then
echo "🛰️ ⚠ Linux stack got an issue, restarting ..."
sudo journalctl --rotate
sudo journalctl --vacuum-time=1s
@ -243,7 +250,7 @@ do
healthy="true"
fi
done
if [ $retries -ge 5 ] ; then
if [ "$retries" -ge 5 ] ; then
echo "🛰️ Linux stack could not be healthy ❌"
exit 1
fi
@ -257,6 +264,7 @@ do
python3 main.py
fi
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🛰️ Test \"$test\" failed ❌"
echo "🛡️ Showing BunkerWeb and BunkerWeb Scheduler logs ..."

View file

@ -15,11 +15,13 @@ echo "🌍 Building country stack for integration \"$integration\" ..."
# Starting stack
if [ "$integration" == "docker" ] ; then
docker compose pull bw-docker
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🌍 Pull failed ❌"
exit 1
fi
docker compose -f docker-compose.test.yml build
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🌍 Build failed ❌"
exit 1
@ -64,6 +66,7 @@ cleanup_stack () {
sudo truncate -s 0 /var/log/bunkerweb/error.log
fi
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🌍 Cleanup failed ❌"
exit 1
@ -103,12 +106,14 @@ do
echo "🌍 Starting stack ..."
if [ "$integration" == "docker" ] ; then
docker compose up -d
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🌍 Up failed, retrying ... ⚠️"
manual=1
cleanup_stack
manual=0
docker compose up -d
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🌍 Up failed ❌"
exit 1
@ -116,6 +121,7 @@ do
fi
else
sudo systemctl start bunkerweb
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🌍 Start failed ❌"
exit 1
@ -130,7 +136,7 @@ do
containers=("country-bw-1" "country-bw-scheduler-1")
healthy="true"
for container in "${containers[@]}" ; do
check="$(docker inspect --format "{{json .State.Health }}" $container | grep "healthy")"
check="$(docker inspect --format "{{json .State.Health }}" "$container" | grep "healthy")"
if [ "$check" = "" ] ; then
healthy="false"
break
@ -170,7 +176,7 @@ do
exit 1
fi
if ! [ -z "$(sudo journalctl -u bunkerweb --no-pager | grep "SYSTEMCTL - ❌")" ] ; then
if sudo journalctl -u bunkerweb --no-pager | grep -q "SYSTEMCTL - ❌ " ; then
echo "🌍 ⚠ Linux stack got an issue, restarting ..."
sudo journalctl --rotate
sudo journalctl --vacuum-time=1s
@ -183,7 +189,7 @@ do
healthy="true"
fi
done
if [ $retries -ge 5 ] ; then
if [ "$retries" -ge 5 ] ; then
echo "🌍 Linux stack could not be healthy ❌"
exit 1
fi
@ -199,6 +205,7 @@ do
python3 main.py
fi
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🌍 Test \"$test\" failed for the FR country ❌"
echo "🛡️ Showing BunkerWeb and BunkerWeb Scheduler logs ..."
@ -226,6 +233,7 @@ do
python3 main.py
fi
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🌍 Test \"$test\" failed for the US country ❌"
echo "🛡️ Showing BunkerWeb and BunkerWeb Scheduler logs ..."

View file

@ -15,11 +15,13 @@ echo "🔏 Building customcert stack for integration \"$integration\" ..."
# Starting stack
if [ "$integration" == "docker" ] ; then
docker compose pull bw-docker
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🔏 Pull failed ❌"
exit 1
fi
docker compose -f docker-compose.test.yml build
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🔏 Build failed ❌"
exit 1
@ -61,6 +63,7 @@ cleanup_stack () {
sudo truncate -s 0 /var/log/bunkerweb/error.log
fi
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🔏 Cleanup failed ❌"
exit 1
@ -77,6 +80,7 @@ if [ "$integration" == "docker" ] ; then
rm -rf init/certs
mkdir -p init/certs
docker compose -f docker-compose.init.yml up --build
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🔏 Build failed ❌"
exit 1
@ -90,6 +94,7 @@ if [ "$integration" == "docker" ] ; then
else
echo "🔏 Generating certificate for www.example.com ..."
openssl req -nodes -x509 -newkey rsa:4096 -keyout /tmp/privatekey.key -out /tmp/certificate.pem -days 365 -subj /CN=www.example.com/
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🔏 Certificate generation failed ❌"
exit 1
@ -114,12 +119,14 @@ do
echo "🔏 Starting stack ..."
if [ "$integration" == "docker" ] ; then
docker compose up -d
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🔏 Up failed, retrying ... ⚠️"
manual=1
cleanup_stack
manual=0
docker compose up -d
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🔏 Up failed ❌"
exit 1
@ -127,6 +134,7 @@ do
fi
else
sudo systemctl start bunkerweb
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🔏 Start failed ❌"
exit 1
@ -141,7 +149,7 @@ do
containers=("customcert-bw-1" "customcert-bw-scheduler-1")
healthy="true"
for container in "${containers[@]}" ; do
check="$(docker inspect --format "{{json .State.Health }}" $container | grep "healthy")"
check="$(docker inspect --format "{{json .State.Health }}" "$container" | grep "healthy")"
if [ "$check" = "" ] ; then
healthy="false"
break
@ -181,7 +189,7 @@ do
exit 1
fi
if ! [ -z "$(sudo journalctl -u bunkerweb --no-pager | grep "SYSTEMCTL - ❌")" ] ; then
if sudo journalctl -u bunkerweb --no-pager | grep -q "SYSTEMCTL - ❌ " ; then
echo "🔏 ⚠ Linux stack got an issue, restarting ..."
sudo journalctl --rotate
sudo journalctl --vacuum-time=1s
@ -194,7 +202,7 @@ do
healthy="true"
fi
done
if [ $retries -ge 5 ] ; then
if [ "$retries" -ge 5 ] ; then
echo "🔏 Linux stack could not be healthy ❌"
exit 1
fi
@ -208,6 +216,7 @@ do
python3 main.py
fi
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🔏 Test \"$test\" failed ❌"
echo "🛡️ Showing BunkerWeb and BunkerWeb Scheduler logs ..."

View file

@ -15,21 +15,25 @@ echo "💾 Building db stack for integration \"$integration\" ..."
# Starting stack
if [ "$integration" == "docker" ] ; then
docker compose pull bw-docker app1
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "💾 Pull failed ❌"
exit 1
fi
docker compose -f docker-compose.mariadb.yml pull bw-db
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "💾 Pull failed ❌"
exit 1
fi
docker compose -f docker-compose.mysql.yml pull bw-db
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "💾 Pull failed ❌"
exit 1
fi
docker compose -f docker-compose.postgres.yml pull bw-db
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "💾 Pull failed ❌"
exit 1
@ -128,6 +132,7 @@ cleanup_stack () {
sudo truncate -s 0 /var/log/bunkerweb/error.log
fi
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "💾 Cleanup failed ❌"
exit 1
@ -146,12 +151,14 @@ if [ "$integration" == "docker" ] ; then
echo "💾 Starting stack ..."
docker compose up -d
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "💾 Up failed, retrying ... ⚠️"
manual=1
cleanup_stack
manual=0
docker compose up -d
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "💾 Up failed ❌"
exit 1
@ -161,6 +168,7 @@ if [ "$integration" == "docker" ] ; then
rm -rf init/plugins init/bunkerweb
mkdir -p init/plugins init/bunkerweb
docker compose -f docker-compose.init.yml up --build
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "💾 Build failed ❌"
exit 1
@ -183,6 +191,7 @@ if [ "$integration" == "docker" ] ; then
manual=0
docker compose -f docker-compose.test.yml build
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "💾 Build failed ❌"
exit 1
@ -265,12 +274,14 @@ do
echo "💾 Starting mariadb ..."
docker compose -f docker-compose.mariadb.yml up -d
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "💾 Up failed, retrying ... ⚠️"
manual=1
cleanup_stack
manual=0
docker compose -f docker-compose.mariadb.yml up -d
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "💾 Up failed ❌"
exit 1
@ -283,12 +294,14 @@ do
echo "💾 Starting mysql ..."
docker compose -f docker-compose.mysql.yml up -d
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "💾 Up failed, retrying ... ⚠️"
manual=1
cleanup_stack
manual=0
docker compose -f docker-compose.mysql.yml up -d
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "💾 Up failed ❌"
exit 1
@ -301,12 +314,14 @@ do
echo "💾 Starting postgres ..."
docker compose -f docker-compose.postgres.yml up -d
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "💾 Up failed, retrying ... ⚠️"
manual=1
cleanup_stack
manual=0
docker compose -f docker-compose.postgres.yml up -d
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "💾 Up failed ❌"
exit 1
@ -317,6 +332,7 @@ do
echo "💾 Starting stack ..."
if [ "$integration" == "docker" ] ; then
docker compose up -d
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "💾 Up failed, retrying ... ⚠️"
manual=1
@ -342,6 +358,7 @@ do
fi
manual=0
docker compose up -d
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "💾 Up failed ❌"
exit 1
@ -349,6 +366,7 @@ do
fi
else
sudo systemctl start bunkerweb
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "💾 Start failed ❌"
exit 1
@ -363,7 +381,7 @@ do
containers=("db-bw-1" "db-bw-scheduler-1")
healthy="true"
for container in "${containers[@]}" ; do
check="$(docker inspect --format "{{json .State.Health }}" $container | grep "healthy")"
check="$(docker inspect --format "{{json .State.Health }}" "$container" | grep "healthy")"
if [ "$check" = "" ] ; then
healthy="false"
break
@ -405,7 +423,7 @@ do
exit 1
fi
if ! [ -z "$(sudo journalctl -u bunkerweb --no-pager | grep "SYSTEMCTL - ❌")" ] ; then
if sudo journalctl -u bunkerweb --no-pager | grep -q "SYSTEMCTL - ❌ " ; then
echo "💾 ⚠ Linux stack got an issue, restarting ..."
sudo journalctl --rotate
sudo journalctl --vacuum-time=1s
@ -418,7 +436,7 @@ do
healthy="true"
fi
done
if [ $retries -ge 5 ] ; then
if [ "$retries" -ge 5 ] ; then
echo "💾 Linux stack could not be healthy ❌"
exit 1
fi
@ -432,6 +450,7 @@ do
sudo -E python3 main.py
fi
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "💾 Test \"$test\" failed ❌"
echo "🛡️ Showing BunkerWeb and BunkerWeb Scheduler logs ..."
@ -460,6 +479,7 @@ do
docker network rm bw-docker
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "💾 Network removal failed ❌"
exit 1

View file

@ -15,11 +15,13 @@ echo "🚫 Building dnsbl stack for integration \"$integration\" ..."
# Starting stack
if [ "$integration" == "docker" ] ; then
docker compose pull bw-docker
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🚫 Pull failed ❌"
exit 1
fi
docker compose -f docker-compose.test.yml build
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🚫 Build failed ❌"
exit 1
@ -68,6 +70,7 @@ cleanup_stack () {
sudo truncate -s 0 /var/log/bunkerweb/error.log
fi
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🚫 Cleanup failed ❌"
exit 1
@ -84,6 +87,7 @@ if [ "$integration" == "docker" ] ; then
rm -rf init/output
mkdir -p init/output
docker compose -f docker-compose.init.yml up --build
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🚫 Build failed ❌"
exit 1
@ -92,9 +96,10 @@ if [ "$integration" == "docker" ] ; then
exit 1
fi
content=($(cat init/output/dnsbl_ip.txt))
content=("$(cat init/output/dnsbl_ip.txt)")
else
python3 init/main.py
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🚫 Initialization failed ❌"
exit 1
@ -103,7 +108,7 @@ else
exit 1
fi
content=($(cat dnsbl_ip.txt))
content=("$(cat dnsbl_ip.txt)")
fi
ip=${content[0]}
@ -150,12 +155,14 @@ do
echo "🚫 Starting stack ..."
if [ "$integration" == "docker" ] ; then
docker compose up -d
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🚫 Up failed, retrying ... ⚠️"
manual=1
cleanup_stack
manual=0
docker compose up -d
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🚫 Up failed ❌"
exit 1
@ -163,6 +170,7 @@ do
fi
else
sudo systemctl start bunkerweb
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🚫 Start failed ❌"
exit 1
@ -177,7 +185,7 @@ do
containers=("dnsbl-bw-1" "dnsbl-bw-scheduler-1")
healthy="true"
for container in "${containers[@]}" ; do
check="$(docker inspect --format "{{json .State.Health }}" $container | grep "healthy")"
check="$(docker inspect --format "{{json .State.Health }}" "$container" | grep "healthy")"
if [ "$check" = "" ] ; then
healthy="false"
break
@ -217,7 +225,7 @@ do
exit 1
fi
if ! [ -z "$(sudo journalctl -u bunkerweb --no-pager | grep "SYSTEMCTL - ❌")" ] ; then
if sudo journalctl -u bunkerweb --no-pager | grep -q "SYSTEMCTL - ❌ " ; then
echo "🚫 ⚠ Linux stack got an issue, restarting ..."
sudo journalctl --rotate
sudo journalctl --vacuum-time=1s
@ -233,12 +241,12 @@ do
manual=0
sleep 10
sudo systemctl start bunkerweb
retries=$((retries+0.2))
retries=$(echo "$retries+0.2" | bc)
else
healthy="true"
fi
done
if [ $retries -ge 5 ] ; then
if [ "$retries" -ge 5 ] ; then
echo "🚫 Linux stack could not be healthy ❌"
exit 1
fi
@ -252,6 +260,7 @@ do
sudo -E python3 main.py
fi
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🚫 Test \"$test\" failed ❌"
echo "🛡️ Showing BunkerWeb and BunkerWeb Scheduler logs ..."

View file

@ -15,11 +15,13 @@ echo "⭕ Building errors stack for integration \"$integration\" ..."
# Starting stack
if [ "$integration" == "docker" ] ; then
docker compose pull bw-docker
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "⭕ Pull failed ❌"
exit 1
fi
docker compose -f docker-compose.test.yml build
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "⭕ Build failed ❌"
exit 1
@ -61,6 +63,7 @@ cleanup_stack () {
sudo truncate -s 0 /var/log/bunkerweb/error.log
fi
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "⭕ Cleanup failed ❌"
exit 1
@ -100,12 +103,14 @@ do
echo "⭕ Starting stack ..."
if [ "$integration" == "docker" ] ; then
docker compose up -d
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "⭕ Up failed, retrying ... ⚠️"
manual=1
cleanup_stack
manual=0
docker compose up -d
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "⭕ Up failed ❌"
exit 1
@ -113,6 +118,7 @@ do
fi
else
sudo systemctl start bunkerweb
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "⭕ Start failed ❌"
exit 1
@ -127,7 +133,7 @@ do
containers=("errors-bw-1" "errors-bw-scheduler-1")
healthy="true"
for container in "${containers[@]}" ; do
check="$(docker inspect --format "{{json .State.Health }}" $container | grep "healthy")"
check="$(docker inspect --format "{{json .State.Health }}" "$container" | grep "healthy")"
if [ "$check" = "" ] ; then
healthy="false"
break
@ -167,7 +173,7 @@ do
exit 1
fi
if ! [ -z "$(sudo journalctl -u bunkerweb --no-pager | grep "SYSTEMCTL - ❌")" ] ; then
if sudo journalctl -u bunkerweb --no-pager | grep -q "SYSTEMCTL - ❌ " ; then
echo "⭕ ⚠ Linux stack got an issue, restarting ..."
sudo journalctl --rotate
sudo journalctl --vacuum-time=1s
@ -180,7 +186,7 @@ do
healthy="true"
fi
done
if [ $retries -ge 5 ] ; then
if [ "$retries" -ge 5 ] ; then
echo "⭕ Linux stack could not be healthy ❌"
exit 1
fi
@ -194,6 +200,7 @@ do
python3 main.py
fi
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "⭕ Test \"$test\" failed ❌"
echo "🛡️ Showing BunkerWeb and BunkerWeb Scheduler logs ..."

View file

@ -15,6 +15,7 @@ echo "🏁 Building greylist stack for integration \"$integration\" ..."
# Starting stack
if [ "$integration" == "docker" ] ; then
docker compose pull bw-docker
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🏁 Pull failed ❌"
exit 1
@ -22,6 +23,7 @@ if [ "$integration" == "docker" ] ; then
echo "🏁 Building custom api image ..."
docker compose build greylist-api
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🏁 Build failed ❌"
exit 1
@ -29,6 +31,7 @@ if [ "$integration" == "docker" ] ; then
echo "🏁 Building tests images ..."
docker compose -f docker-compose.test.yml build
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🏁 Build failed ❌"
exit 1
@ -115,6 +118,7 @@ cleanup_stack () {
sudo truncate -s 0 /var/log/bunkerweb/error.log
fi
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🏁 Cleanup failed ❌"
exit 1
@ -131,6 +135,7 @@ if [ "$integration" == "docker" ] ; then
rm -rf init/output
mkdir -p init/output
docker compose -f docker-compose.init.yml up --build
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🏁 Init failed ❌"
exit 1
@ -144,6 +149,7 @@ if [ "$integration" == "docker" ] ; then
else
echo "🏁 Starting init ..."
python3 init/main.py
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🏁 Init failed ❌"
exit 1
@ -291,12 +297,14 @@ do
echo "🏁 Starting stack ..."
if [ "$integration" == "docker" ] ; then
docker compose up -d
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🏁 Up failed, retrying ... ⚠️"
manual=1
cleanup_stack
manual=0
docker compose up -d
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🏁 Up failed ❌"
exit 1
@ -304,6 +312,7 @@ do
fi
else
sudo systemctl start bunkerweb
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🏁 Start failed ❌"
exit 1
@ -318,7 +327,7 @@ do
containers=("greylist-bw-1" "greylist-bw-scheduler-1")
healthy="true"
for container in "${containers[@]}" ; do
check="$(docker inspect --format "{{json .State.Health }}" $container | grep "healthy")"
check="$(docker inspect --format "{{json .State.Health }}" "$container" | grep "healthy")"
if [ "$check" = "" ] ; then
healthy="false"
break
@ -358,7 +367,7 @@ do
exit 1
fi
if ! [ -z "$(sudo journalctl -u bunkerweb --no-pager | grep "SYSTEMCTL - ❌")" ] ; then
if sudo journalctl -u bunkerweb --no-pager | grep -q "SYSTEMCTL - ❌ " ; then
echo "🏁 ⚠ Linux stack got an issue, restarting ..."
sudo journalctl --rotate
sudo journalctl --vacuum-time=1s
@ -371,7 +380,7 @@ do
healthy="true"
fi
done
if [ $retries -ge 5 ] ; then
if [ "$retries" -ge 5 ] ; then
echo "🏁 Linux stack could not be healthy ❌"
exit 1
fi
@ -389,6 +398,7 @@ do
python3 main.py
fi
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🏁 Test \"$test\" failed for global tests ❌"
echo "🛡️ Showing BunkerWeb, BunkerWeb Scheduler and Custom API logs ..."
@ -420,6 +430,7 @@ do
python3 main.py
fi
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🏁 Test \"$test\" failed for local tests ❌"
echo "🛡️ Showing BunkerWeb, BunkerWeb Scheduler and Custom API logs ..."

View file

@ -15,11 +15,13 @@ echo "🗜️ Building gzip stack for integration \"$integration\" ..."
# Starting stack
if [ "$integration" == "docker" ] ; then
docker compose pull bw-docker app1
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🗜️ Pull failed ❌"
exit 1
fi
docker compose -f docker-compose.test.yml build
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🗜️ Build failed ❌"
exit 1
@ -55,6 +57,7 @@ cleanup_stack () {
sudo truncate -s 0 /var/log/bunkerweb/error.log
fi
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🗜️ Cleanup failed ❌"
exit 1
@ -83,12 +86,14 @@ do
echo "🗜️ Starting stack ..."
if [ "$integration" == "docker" ] ; then
docker compose up -d
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🗜️ Up failed, retrying ... ⚠️"
manual=1
cleanup_stack
manual=0
docker compose up -d
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🗜️ Up failed ❌"
exit 1
@ -96,6 +101,7 @@ do
fi
else
sudo systemctl start bunkerweb
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🗜️ Start failed ❌"
exit 1
@ -110,7 +116,7 @@ do
containers=("gzip-bw-1" "gzip-bw-scheduler-1")
healthy="true"
for container in "${containers[@]}" ; do
check="$(docker inspect --format "{{json .State.Health }}" $container | grep "healthy")"
check="$(docker inspect --format "{{json .State.Health }}" "$container" | grep "healthy")"
if [ "$check" = "" ] ; then
healthy="false"
break
@ -150,7 +156,7 @@ do
exit 1
fi
if ! [ -z "$(sudo journalctl -u bunkerweb --no-pager | grep "SYSTEMCTL - ❌")" ] ; then
if sudo journalctl -u bunkerweb --no-pager | grep -q "SYSTEMCTL - ❌ " ; then
echo "🗜️ ⚠ Linux stack got an issue, restarting ..."
sudo journalctl --rotate
sudo journalctl --vacuum-time=1s
@ -163,7 +169,7 @@ do
healthy="true"
fi
done
if [ $retries -ge 5 ] ; then
if [ "$retries" -ge 5 ] ; then
echo "🗜️ Linux stack could not be healthy ❌"
exit 1
fi
@ -177,6 +183,7 @@ do
python3 main.py
fi
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🗜️ Test \"$test\" failed ❌"
echo "🛡️ Showing BunkerWeb and BunkerWeb Scheduler logs ..."

View file

@ -15,11 +15,13 @@ echo "🎛️ Building headers stack for integration \"$integration\" ..."
# Starting stack
if [ "$integration" == "docker" ] ; then
docker compose pull bw-docker bw-php
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🎛️ Pull failed ❌"
exit 1
fi
docker compose -f docker-compose.test.yml build
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🎛️ Build failed ❌"
exit 1
@ -122,6 +124,7 @@ cleanup_stack () {
sudo truncate -s 0 /var/log/bunkerweb/error.log
fi
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🎛️ Cleanup failed ❌"
exit 1
@ -247,12 +250,14 @@ do
echo "🎛️ Starting stack ..."
if [ "$integration" == "docker" ] ; then
docker compose up -d
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🎛️ Up failed, retrying ... ⚠️"
manual=1
cleanup_stack
manual=0
docker compose up -d
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🎛️ Up failed ❌"
exit 1
@ -260,6 +265,7 @@ do
fi
else
sudo systemctl start bunkerweb
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🎛️ Start failed ❌"
exit 1
@ -274,7 +280,7 @@ do
containers=("headers-bw-1" "headers-bw-scheduler-1")
healthy="true"
for container in "${containers[@]}" ; do
check="$(docker inspect --format "{{json .State.Health }}" $container | grep "healthy")"
check="$(docker inspect --format "{{json .State.Health }}" "$container" | grep "healthy")"
if [ "$check" = "" ] ; then
healthy="false"
break
@ -314,7 +320,7 @@ do
exit 1
fi
if ! [ -z "$(sudo journalctl -u bunkerweb --no-pager | grep "SYSTEMCTL - ❌")" ] ; then
if sudo journalctl -u bunkerweb --no-pager | grep -q "SYSTEMCTL - ❌ " ; then
echo "🎛️ ⚠ Linux stack got an issue, restarting ..."
sudo journalctl --rotate
sudo journalctl --vacuum-time=1s
@ -327,7 +333,7 @@ do
healthy="true"
fi
done
if [ $retries -ge 5 ] ; then
if [ "$retries" -ge 5 ] ; then
echo "🎛️ Linux stack could not be healthy ❌"
exit 1
fi
@ -341,6 +347,7 @@ do
python3 main.py
fi
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🎛️ Test \"$test\" failed ❌"
echo "🛡️ Showing BunkerWeb and BunkerWeb Scheduler logs ..."

View file

@ -15,11 +15,13 @@ echo "💉 Building inject stack for integration \"$integration\" ..."
# Starting stack
if [ "$integration" == "docker" ] ; then
docker compose pull bw-docker
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "💉 Pull failed ❌"
exit 1
fi
docker compose -f docker-compose.test.yml build
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "💉 Build failed ❌"
exit 1
@ -40,6 +42,7 @@ cleanup_stack () {
sudo truncate -s 0 /var/log/bunkerweb/error.log
fi
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "💉 Cleanup failed ❌"
exit 1
@ -56,12 +59,12 @@ echo "💉 Running tests while injecting TEST into the HTML page ..."
echo "💉 Starting stack ..."
if [ "$integration" == "docker" ] ; then
docker compose up -d
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "💉 Up failed, retrying ... ⚠️"
manual=1
cleanup_stack
manual=0
docker compose up -d
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "💉 Up failed ❌"
exit 1
@ -69,6 +72,7 @@ if [ "$integration" == "docker" ] ; then
fi
else
sudo systemctl start bunkerweb
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "💉 Start failed ❌"
exit 1
@ -83,7 +87,7 @@ if [ "$integration" == "docker" ] ; then
containers=("inject-bw-1" "inject-bw-scheduler-1")
healthy="true"
for container in "${containers[@]}" ; do
check="$(docker inspect --format "{{json .State.Health }}" $container | grep "healthy")"
check="$(docker inspect --format "{{json .State.Health }}" "$container" | grep "healthy")"
if [ "$check" = "" ] ; then
healthy="false"
break
@ -123,20 +127,18 @@ else
exit 1
fi
if ! [ -z "$(sudo journalctl -u bunkerweb --no-pager | grep "SYSTEMCTL - ❌")" ] ; then
if sudo journalctl -u bunkerweb --no-pager | grep -q "SYSTEMCTL - ❌ " ; then
echo "💉 ⚠ Linux stack got an issue, restarting ..."
sudo journalctl --rotate
sudo journalctl --vacuum-time=1s
manual=1
cleanup_stack
manual=0
sudo systemctl start bunkerweb
retries=$((retries+1))
else
healthy="true"
fi
done
if [ $retries -ge 5 ] ; then
if [ "$retries" -ge 5 ] ; then
echo "💉 Linux stack could not be healthy ❌"
exit 1
fi
@ -150,6 +152,7 @@ else
python3 main.py
fi
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "💉 Test \"inject\" failed ❌"
echo "🛡️ Showing BunkerWeb and BunkerWeb Scheduler logs ..."

View file

@ -15,11 +15,13 @@ echo "🎚️ Building limit stack for integration \"$integration\" ..."
# Starting stack
if [ "$integration" == "docker" ] ; then
docker compose pull bw-docker
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🎚️ Pull failed ❌"
exit 1
fi
docker compose -f docker-compose.test.yml build
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🎚️ Build failed ❌"
exit 1
@ -96,6 +98,7 @@ cleanup_stack () {
sudo truncate -s 0 /var/log/bunkerweb/error.log
fi
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🎚️ Cleanup failed ❌"
exit 1
@ -157,12 +160,14 @@ do
echo "🎚️ Starting stack ..."
if [ "$integration" == "docker" ] ; then
docker compose up -d
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🎚️ Up failed, retrying ... ⚠️"
manual=1
cleanup_stack
manual=0
docker compose up -d
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🎚️ Up failed ❌"
exit 1
@ -170,6 +175,7 @@ do
fi
else
sudo systemctl start bunkerweb
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🎚️ Start failed ❌"
exit 1
@ -184,7 +190,7 @@ do
containers=("limit-bw-1" "limit-bw-scheduler-1")
healthy="true"
for container in "${containers[@]}" ; do
check="$(docker inspect --format "{{json .State.Health }}" $container | grep "healthy")"
check="$(docker inspect --format "{{json .State.Health }}" "$container" | grep "healthy")"
if [ "$check" = "" ] ; then
healthy="false"
break
@ -224,7 +230,7 @@ do
exit 1
fi
if ! [ -z "$(sudo journalctl -u bunkerweb --no-pager | grep "SYSTEMCTL - ❌")" ] ; then
if sudo journalctl -u bunkerweb --no-pager | grep -q "SYSTEMCTL - ❌ " ; then
echo "🎚️ ⚠ Linux stack got an issue, restarting ..."
sudo journalctl --rotate
sudo journalctl --vacuum-time=1s
@ -237,7 +243,7 @@ do
healthy="true"
fi
done
if [ $retries -ge 5 ] ; then
if [ "$retries" -ge 5 ] ; then
echo "🎚️ Linux stack could not be healthy ❌"
exit 1
fi
@ -251,6 +257,7 @@ do
python3 main.py
fi
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🎚️ Test \"$test\" failed ❌"
echo "🛡️ Showing BunkerWeb and BunkerWeb Scheduler logs ..."

View file

@ -15,11 +15,13 @@ echo "🗃️ Building misc stack for integration \"$integration\" ..."
# Starting stack
if [ "$integration" == "docker" ] ; then
docker compose pull bw-docker
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🗃️ Pull failed ❌"
exit 1
fi
docker compose -f docker-compose.test.yml build
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🗃️ Build failed ❌"
exit 1
@ -92,6 +94,7 @@ cleanup_stack () {
sudo truncate -s 0 /var/log/bunkerweb/error.log
fi
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🗃️ Cleanup failed ❌"
exit 1
@ -165,12 +168,14 @@ do
echo "🗃️ Starting stack ..."
if [ "$integration" == "docker" ] ; then
docker compose up -d
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🗃️ Up failed, retrying ... ⚠️"
manual=1
cleanup_stack
manual=0
docker compose up -d
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🗃️ Up failed ❌"
exit 1
@ -178,6 +183,7 @@ do
fi
else
sudo systemctl start bunkerweb
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🗃️ Start failed ❌"
exit 1
@ -192,7 +198,7 @@ do
containers=("misc-bw-1" "misc-bw-scheduler-1")
healthy="true"
for container in "${containers[@]}" ; do
check="$(docker inspect --format "{{json .State.Health }}" $container | grep "healthy")"
check="$(docker inspect --format "{{json .State.Health }}" "$container" | grep "healthy")"
if [ "$check" = "" ] ; then
healthy="false"
break
@ -232,7 +238,7 @@ do
exit 1
fi
if ! [ -z "$(sudo journalctl -u bunkerweb --no-pager | grep "SYSTEMCTL - ❌")" ] ; then
if sudo journalctl -u bunkerweb --no-pager | grep -q "SYSTEMCTL - ❌ " ; then
echo "🗃️ ⚠ Linux stack got an issue, restarting ..."
sudo journalctl --rotate
sudo journalctl --vacuum-time=1s
@ -245,7 +251,7 @@ do
healthy="true"
fi
done
if [ $retries -ge 5 ] ; then
if [ "$retries" -ge 5 ] ; then
echo "🗃️ Linux stack could not be healthy ❌"
exit 1
fi
@ -259,6 +265,7 @@ do
python3 main.py
fi
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🗃️ Test \"$test\" failed ❌"
echo "🛡️ Showing BunkerWeb and BunkerWeb Scheduler logs ..."

View file

@ -15,11 +15,13 @@ echo "👮 Building modsecurity stack for integration \"$integration\" ..."
# Starting stack
if [ "$integration" == "docker" ] ; then
docker compose pull bw-docker
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "👮 Pull failed ❌"
exit 1
fi
docker compose -f docker-compose.test.yml build
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "👮 Build failed ❌"
exit 1
@ -62,6 +64,7 @@ cleanup_stack () {
sudo truncate -s 0 /var/log/bunkerweb/error.log
fi
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "👮 Cleanup failed ❌"
exit 1
@ -101,12 +104,14 @@ do
echo "👮 Starting stack ..."
if [ "$integration" == "docker" ] ; then
docker compose up -d
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "👮 Up failed, retrying ... ⚠️"
manual=1
cleanup_stack
manual=0
docker compose up -d
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "👮 Up failed ❌"
exit 1
@ -114,6 +119,7 @@ do
fi
else
sudo systemctl start bunkerweb
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "👮 Start failed ❌"
exit 1
@ -128,7 +134,7 @@ do
containers=("modsecurity-bw-1" "modsecurity-bw-scheduler-1")
healthy="true"
for container in "${containers[@]}" ; do
check="$(docker inspect --format "{{json .State.Health }}" $container | grep "healthy")"
check="$(docker inspect --format "{{json .State.Health }}" "$container" | grep "healthy")"
if [ "$check" = "" ] ; then
healthy="false"
break
@ -168,7 +174,7 @@ do
exit 1
fi
if ! [ -z "$(sudo journalctl -u bunkerweb --no-pager | grep "SYSTEMCTL - ❌")" ] ; then
if sudo journalctl -u bunkerweb --no-pager | grep -q "SYSTEMCTL - ❌ " ; then
echo "👮 ⚠ Linux stack got an issue, restarting ..."
sudo journalctl --rotate
sudo journalctl --vacuum-time=1s
@ -181,7 +187,7 @@ do
healthy="true"
fi
done
if [ $retries -ge 5 ] ; then
if [ "$retries" -ge 5 ] ; then
echo "👮 Linux stack could not be healthy ❌"
exit 1
fi
@ -195,6 +201,7 @@ do
python3 main.py
fi
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "👮 Test \"$test\" failed ❌"
echo "🛡️ Showing BunkerWeb and BunkerWeb Scheduler logs ..."

View file

@ -15,11 +15,13 @@ echo "↩️ Building redirect stack for integration \"$integration\" ..."
# Starting stack
if [ "$integration" == "docker" ] ; then
docker compose pull bw-docker app1
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "↩️ Pull failed ❌"
exit 1
fi
docker compose -f docker-compose.test.yml build
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "↩️ Build failed ❌"
exit 1
@ -59,6 +61,7 @@ cleanup_stack () {
sudo truncate -s 0 /var/log/bunkerweb/error.log
fi
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "↩️ Cleanup failed ❌"
exit 1
@ -93,12 +96,14 @@ do
echo "↩️ Starting stack ..."
if [ "$integration" == "docker" ] ; then
docker compose up -d
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "↩️ Up failed, retrying ... ⚠️"
manual=1
cleanup_stack
manual=0
docker compose up -d
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "↩️ Up failed ❌"
exit 1
@ -106,6 +111,7 @@ do
fi
else
sudo systemctl start bunkerweb
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "↩️ Start failed ❌"
exit 1
@ -120,7 +126,7 @@ do
containers=("redirect-bw-1" "redirect-bw-scheduler-1")
healthy="true"
for container in "${containers[@]}" ; do
check="$(docker inspect --format "{{json .State.Health }}" $container | grep "healthy")"
check="$(docker inspect --format "{{json .State.Health }}" "$container" | grep "healthy")"
if [ "$check" = "" ] ; then
healthy="false"
break
@ -160,7 +166,7 @@ do
exit 1
fi
if ! [ -z "$(sudo journalctl -u bunkerweb --no-pager | grep "SYSTEMCTL - ❌")" ] ; then
if sudo journalctl -u bunkerweb --no-pager | grep -q "SYSTEMCTL - ❌ " ; then
echo "↩️ ⚠ Linux stack got an issue, restarting ..."
sudo journalctl --rotate
sudo journalctl --vacuum-time=1s
@ -173,7 +179,7 @@ do
healthy="true"
fi
done
if [ $retries -ge 5 ] ; then
if [ "$retries" -ge 5 ] ; then
echo "↩️ Linux stack could not be healthy ❌"
exit 1
fi
@ -187,6 +193,7 @@ do
python3 main.py
fi
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "↩️ Test \"$test\" failed ❌"
echo "🛡️ Showing BunkerWeb and BunkerWeb Scheduler logs ..."

View file

@ -15,6 +15,7 @@ echo "🧰 Building redis stack for integration \"$integration\" ..."
# Starting stack
if [ "$integration" == "docker" ] ; then
docker compose pull bw-docker
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🧰 Pull failed ❌"
exit 1
@ -22,6 +23,7 @@ if [ "$integration" == "docker" ] ; then
echo "🧰 Building custom redis image ..."
docker compose build bw-redis
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🧰 Build failed ❌"
exit 1
@ -29,6 +31,7 @@ if [ "$integration" == "docker" ] ; then
echo "🧰 Building tests images ..."
docker compose -f docker-compose.test.yml build
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🧰 Build failed ❌"
exit 1
@ -48,6 +51,7 @@ else
echo "🧰 Installing Redis ..."
sudo apt install --no-install-recommends -y redis
redis-server --daemonize yes
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🧰 Redis start failed ❌"
exit 1
@ -120,6 +124,7 @@ cleanup_stack () {
sudo truncate -s 0 /var/log/bunkerweb/error.log
fi
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🧰 Cleanup failed ❌"
exit 1
@ -173,6 +178,7 @@ do
echo "🧰 Stoping redis ..."
sudo killall redis-server
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🧰 Redis stop failed ❌"
exit 1
@ -180,6 +186,7 @@ do
echo "🧰 Redis stopped ✅"
echo "🧰 Starting redis with tweaked settings ..."
redis-server --tls-port 6380 --port 0 --tls-cert-file tls/redis.pem --tls-key-file tls/redis.key --tls-ca-cert-file tls/ca.crt --tls-auth-clients no --daemonize yes
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🧰 Redis start failed ❌"
exit 1
@ -191,12 +198,14 @@ do
echo "🧰 Starting stack ..."
if [ "$integration" == "docker" ] ; then
docker compose up -d
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🧰 Up failed, retrying ... ⚠️"
manual=1
cleanup_stack
manual=0
docker compose up -d
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🧰 Up failed ❌"
exit 1
@ -204,6 +213,7 @@ do
fi
else
sudo systemctl start bunkerweb
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🧰 Start failed ❌"
exit 1
@ -218,7 +228,7 @@ do
containers=("redis-bw-1" "redis-bw-scheduler-1")
healthy="true"
for container in "${containers[@]}" ; do
check="$(docker inspect --format "{{json .State.Health }}" $container | grep "healthy")"
check="$(docker inspect --format "{{json .State.Health }}" "$container" | grep "healthy")"
if [ "$check" = "" ] ; then
healthy="false"
break
@ -258,7 +268,7 @@ do
exit 1
fi
if ! [ -z "$(sudo journalctl -u bunkerweb --no-pager | grep "SYSTEMCTL - ❌")" ] ; then
if sudo journalctl -u bunkerweb --no-pager | grep -q "SYSTEMCTL - ❌ " ; then
echo "🧰 ⚠ Linux stack got an issue, restarting ..."
sudo journalctl --rotate
sudo journalctl --vacuum-time=1s
@ -271,7 +281,7 @@ do
healthy="true"
fi
done
if [ $retries -ge 5 ] ; then
if [ "$retries" -ge 5 ] ; then
echo "🧰 Linux stack could not be healthy ❌"
exit 1
fi
@ -285,6 +295,7 @@ do
python3 main.py
fi
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🧰 Test \"$test\" failed ❌"
echo "🛡️ Showing BunkerWeb and BunkerWeb Scheduler logs ..."

View file

@ -15,11 +15,13 @@ echo "🕵️ Building reversescan stack for integration \"$integration\" ..."
# Starting stack
if [ "$integration" == "docker" ] ; then
docker compose pull bw-docker
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🕵️ Pull failed ❌"
exit 1
fi
docker compose -f docker-compose.test.yml build
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🕵️ Build failed ❌"
exit 1
@ -61,6 +63,7 @@ cleanup_stack () {
sudo truncate -s 0 /var/log/bunkerweb/error.log
fi
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🕵️ Cleanup failed ❌"
exit 1
@ -97,12 +100,14 @@ do
echo "🕵️ Starting stack ..."
if [ "$integration" == "docker" ] ; then
docker compose up -d
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🕵️ Up failed, retrying ... ⚠️"
manual=1
cleanup_stack
manual=0
docker compose up -d
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🕵️ Up failed ❌"
exit 1
@ -110,6 +115,7 @@ do
fi
else
sudo systemctl start bunkerweb
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🕵️ Start failed ❌"
exit 1
@ -124,7 +130,7 @@ do
containers=("reversescan-bw-1" "reversescan-bw-scheduler-1")
healthy="true"
for container in "${containers[@]}" ; do
check="$(docker inspect --format "{{json .State.Health }}" $container | grep "healthy")"
check="$(docker inspect --format "{{json .State.Health }}" "$container" | grep "healthy")"
if [ "$check" = "" ] ; then
healthy="false"
break
@ -164,7 +170,7 @@ do
exit 1
fi
if ! [ -z "$(sudo journalctl -u bunkerweb --no-pager | grep "SYSTEMCTL - ❌")" ] ; then
if sudo journalctl -u bunkerweb --no-pager | grep -q "SYSTEMCTL - ❌ " ; then
echo "🕵️ ⚠ Linux stack got an issue, restarting ..."
sudo journalctl --rotate
sudo journalctl --vacuum-time=1s
@ -177,7 +183,7 @@ do
healthy="true"
fi
done
if [ $retries -ge 5 ] ; then
if [ "$retries" -ge 5 ] ; then
echo "🕵️ Linux stack could not be healthy ❌"
exit 1
fi
@ -191,6 +197,7 @@ do
python3 main.py
fi
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🕵️ Test \"$test\" failed ❌"
echo "🛡️ Showing BunkerWeb and BunkerWeb Scheduler logs ..."

View file

@ -15,11 +15,13 @@ echo "🔑 Building selfsigned stack for integration \"$integration\" ..."
# Starting stack
if [ "$integration" == "docker" ] ; then
docker compose pull bw-docker
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🔑 Pull failed ❌"
exit 1
fi
docker compose -f docker-compose.test.yml build
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🔑 Build failed ❌"
exit 1
@ -63,6 +65,7 @@ cleanup_stack () {
sudo truncate -s 0 /var/log/bunkerweb/error.log
fi
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🔑 Cleanup failed ❌"
exit 1
@ -103,12 +106,14 @@ do
echo "🔑 Starting stack ..."
if [ "$integration" == "docker" ] ; then
docker compose up -d
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🔑 Up failed, retrying ... ⚠️"
manual=1
cleanup_stack
manual=0
docker compose up -d
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🔑 Up failed ❌"
exit 1
@ -116,6 +121,7 @@ do
fi
else
sudo systemctl start bunkerweb
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🔑 Start failed ❌"
exit 1
@ -130,7 +136,7 @@ do
containers=("selfsigned-bw-1" "selfsigned-bw-scheduler-1")
healthy="true"
for container in "${containers[@]}" ; do
check="$(docker inspect --format "{{json .State.Health }}" $container | grep "healthy")"
check="$(docker inspect --format "{{json .State.Health }}" "$container" | grep "healthy")"
if [ "$check" = "" ] ; then
healthy="false"
break
@ -170,7 +176,7 @@ do
exit 1
fi
if ! [ -z "$(sudo journalctl -u bunkerweb --no-pager | grep "SYSTEMCTL - ❌")" ] ; then
if sudo journalctl -u bunkerweb --no-pager | grep -q "SYSTEMCTL - ❌ " ; then
echo "🔑 ⚠ Linux stack got an issue, restarting ..."
sudo journalctl --rotate
sudo journalctl --vacuum-time=1s
@ -183,7 +189,7 @@ do
healthy="true"
fi
done
if [ $retries -ge 5 ] ; then
if [ "$retries" -ge 5 ] ; then
echo "🔑 Linux stack could not be healthy ❌"
exit 1
fi
@ -197,6 +203,7 @@ do
python3 main.py
fi
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🔑 Test \"$test\" failed ❌"
echo "🛡️ Showing BunkerWeb and BunkerWeb Scheduler logs ..."

View file

@ -15,11 +15,13 @@ echo "🧳 Building sessions stack for integration \"$integration\" ..."
# Starting stack
if [ "$integration" == "docker" ] ; then
docker compose pull bw-docker
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🧳 Pull failed ❌"
exit 1
fi
docker compose -f docker-compose.test.yml build
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🧳 Build failed ❌"
exit 1
@ -61,6 +63,7 @@ cleanup_stack () {
sudo truncate -s 0 /var/log/bunkerweb/error.log
fi
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🧳 Cleanup failed ❌"
exit 1
@ -100,12 +103,14 @@ do
echo "🧳 Starting stack ..."
if [ "$integration" == "docker" ] ; then
docker compose up -d
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🧳 Up failed, retrying ... ⚠️"
manual=1
cleanup_stack
manual=0
docker compose up -d
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🧳 Up failed ❌"
exit 1
@ -113,6 +118,7 @@ do
fi
else
sudo systemctl start bunkerweb
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🧳 Start failed ❌"
exit 1
@ -127,7 +133,7 @@ do
containers=("sessions-bw-1" "sessions-bw-scheduler-1")
healthy="true"
for container in "${containers[@]}" ; do
check="$(docker inspect --format "{{json .State.Health }}" $container | grep "healthy")"
check="$(docker inspect --format "{{json .State.Health }}" "$container" | grep "healthy")"
if [ "$check" = "" ] ; then
healthy="false"
break
@ -167,7 +173,7 @@ do
exit 1
fi
if ! [ -z "$(sudo journalctl -u bunkerweb --no-pager | grep "SYSTEMCTL - ❌")" ] ; then
if sudo journalctl -u bunkerweb --no-pager | grep -q "SYSTEMCTL - ❌ " ; then
echo "🧳 ⚠ Linux stack got an issue, restarting ..."
sudo journalctl --rotate
sudo journalctl --vacuum-time=1s
@ -180,7 +186,7 @@ do
healthy="true"
fi
done
if [ $retries -ge 5 ] ; then
if [ "$retries" -ge 5 ] ; then
echo "🧳 Linux stack could not be healthy ❌"
exit 1
fi
@ -194,6 +200,7 @@ do
python3 main.py
fi
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🧳 Test \"$test\" failed ❌"
echo "🛡️ Showing BunkerWeb and BunkerWeb Scheduler logs ..."

View file

@ -15,6 +15,7 @@ echo "🏳️ Building whitelist stack for integration \"$integration\" ..."
# Starting stack
if [ "$integration" == "docker" ] ; then
docker compose pull bw-docker
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🏳️ Pull failed ❌"
exit 1
@ -22,6 +23,7 @@ if [ "$integration" == "docker" ] ; then
echo "🏳️ Building custom api image ..."
docker compose build whitelist-api
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🏳️ Build failed ❌"
exit 1
@ -29,6 +31,7 @@ if [ "$integration" == "docker" ] ; then
echo "🏳️ Building tests images ..."
docker compose -f docker-compose.test.yml build
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🏳️ Build failed ❌"
exit 1
@ -118,6 +121,7 @@ cleanup_stack () {
sudo truncate -s 0 /var/log/bunkerweb/error.log
fi
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🏳️ Cleanup failed ❌"
exit 1
@ -134,6 +138,7 @@ if [ "$integration" == "docker" ] ; then
rm -rf init/output
mkdir -p init/output
docker compose -f docker-compose.init.yml up --build
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🏳️ Init failed ❌"
exit 1
@ -147,6 +152,7 @@ if [ "$integration" == "docker" ] ; then
else
echo "🏳️ Starting init ..."
python3 init/main.py
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🏳️ Init failed ❌"
exit 1
@ -295,12 +301,14 @@ do
echo "🏳️ Starting stack ..."
if [ "$integration" == "docker" ] ; then
docker compose up -d
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🏳️ Up failed, retrying ... ⚠️"
manual=1
cleanup_stack
manual=0
docker compose up -d
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🏳️ Up failed ❌"
exit 1
@ -308,6 +316,7 @@ do
fi
else
sudo systemctl start bunkerweb
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🏳️ Start failed ❌"
exit 1
@ -322,7 +331,7 @@ do
containers=("whitelist-bw-1" "whitelist-bw-scheduler-1")
healthy="true"
for container in "${containers[@]}" ; do
check="$(docker inspect --format "{{json .State.Health }}" $container | grep "healthy")"
check="$(docker inspect --format "{{json .State.Health }}" "$container" | grep "healthy")"
if [ "$check" = "" ] ; then
healthy="false"
break
@ -362,7 +371,7 @@ do
exit 1
fi
if ! [ -z "$(sudo journalctl -u bunkerweb --no-pager | grep "SYSTEMCTL - ❌")" ] ; then
if sudo journalctl -u bunkerweb --no-pager | grep -q "SYSTEMCTL - ❌ " ; then
echo "🏳️ ⚠ Linux stack got an issue, restarting ..."
sudo journalctl --rotate
sudo journalctl --vacuum-time=1s
@ -375,7 +384,7 @@ do
healthy="true"
fi
done
if [ $retries -ge 5 ] ; then
if [ "$retries" -ge 5 ] ; then
echo "🏳️ Linux stack could not be healthy ❌"
exit 1
fi
@ -393,6 +402,7 @@ do
python3 main.py
fi
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🏳️ Test \"$test\" failed for global tests ❌"
echo "🛡️ Showing BunkerWeb, BunkerWeb Scheduler and Custom API logs ..."
@ -424,6 +434,7 @@ do
python3 main.py
fi
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🏳️ Test \"$test\" failed for local tests ❌"
echo "🛡️ Showing BunkerWeb, BunkerWeb Scheduler and Custom API logs ..."

View file

@ -4,6 +4,7 @@
echo "${CICD_SECRETS}" > /opt/.env
echo "export TF_VAR_k8s_ip=${K8S_IP}" >> /opt/.env
chmod +x /opt/.env
# shellcheck disable=SC1091
. /opt/.env
# create terraform env
@ -12,10 +13,11 @@ cp ./tests/terraform/providers.tf "/tmp/$1"
cp -r ./tests/terraform/templates "/tmp/$1"
cp "./tests/terraform/${1}.tf" "/tmp/$1"
old_dir="$(pwd)"
cd "/tmp/$1"
cd "/tmp/$1" || exit 1
# terraform init
terraform init
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "terraform init failed"
exit 1
@ -23,6 +25,7 @@ fi
# terraform apply
terraform apply -auto-approve
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "terraform apply failed"
terraform destroy -auto-approve
@ -31,12 +34,13 @@ fi
# run ansible playbook
if [ -f "/tmp/${1}_inventory" ] ; then
cd "${old_dir}/tests/ansible"
cd "${old_dir}/tests/ansible" || exit 1
export ANSIBLE_HOST_KEY_CHECKING=False
ansible-playbook -i "/tmp/${1}_inventory" "${1}_playbook"
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "ansible-playbook failed"
cd "/tmp/$1"
cd "/tmp/$1" || exit 1
terraform destroy -auto-approve
exit 3
fi

View file

@ -2,7 +2,7 @@
function do_and_check_cmd() {
if [ "$CHANGE_DIR" != "" ] ; then
cd "$CHANGE_DIR"
cd "$CHANGE_DIR" || return 1
fi
output=$("$@" 2>&1)
ret="$?"
@ -11,14 +11,12 @@ function do_and_check_cmd() {
echo "$output"
exit $ret
fi
#echo $output
return 0
}
function gen_package() {
mode="$1"
linux="$2"
version="$(cat VERSION | tr -d '\n')"
version="$(tr -d '\n' < VERSION)"
if [ "$linux" = "fedora" ] || [ "$linux" = "centos" ] || [ "$linux" = "rhel" ] ; then
type="rpm"
else
@ -48,7 +46,7 @@ fi
do_and_check_cmd mkdir /tmp/packages
# Remove old packages
find /opt/packages/ -type f | xargs rm
find /opt/packages/ -type f -exec rm -f {} \;
# Generate packages
# echo "Building ubuntu package ..."

View file

@ -1,15 +1,16 @@
#!/bin/bash
# Small code to build and run the tests on Linux with docker
# Check if the package already exists in /tmp/$DISTRO/bunkerweb.deb or /tmp/$DISTRO/bunkerweb.rpm
# Always remove the package before building it
function checkPackage() {
if [ ! -z "$DISTRO" ]; then
if [ -n "$DISTRO" ]; then
if [ -f "/tmp/$DISTRO/bunkerweb.deb" ]; then
sudo rm -rf /tmp/$DISTRO/bunkerweb.deb
sudo rm -rf /tmp/"$DISTRO"/bunkerweb.deb
fi
if [ -f "/tmp/$DISTRO/bunkerweb.rpm" ]; then
sudo rm -rf /tmp/$DISTRO/bunkerweb.rpm
sudo rm -rf /tmp/"$DISTRO"/bunkerweb.rpm
fi
fi
}
@ -17,7 +18,7 @@ function checkPackage() {
# Build the package using the dockerfile
function buildPackage() {
if [ ! -z "$DISTRO" ]; then
if [ -n "$DISTRO" ]; then
if [ "$DISTRO" = "ubuntu" ]; then
sudo docker build -t linux-ubuntu -f src/linux/Dockerfile-ubuntu .
fi
@ -36,7 +37,7 @@ function buildPackage() {
# Create the container and copy the package to the host
function createContainer() {
if [ ! -z "$DISTRO" ]; then
if [ -n "$DISTRO" ]; then
if [ "$DISTRO" = "ubuntu" ]; then
sudo docker run -v /tmp/ubuntu:/data linux-ubuntu
fi
@ -56,7 +57,7 @@ function createContainer() {
function retrieveDistro() {
echo "Which distro do you want to use? (ubuntu, debian, centos, fedora)"
read DISTRO
read -r DISTRO
}
# Main function

View file

@ -3,10 +3,12 @@
# drop and export secrets
echo "${CICD_SECRETS}" > /opt/.env
chmod +x /opt/.env
# shellcheck disable=SC1091
. /opt/.env
# go to terraform env
cd "/tmp/$1"
cd "/tmp/$1" || exit 1
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "terraform env is absent"
exit 1

View file

@ -22,6 +22,7 @@ cleanup_stack () {
sudo truncate -s 0 /var/log/bunkerweb/error.log
fi
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🌐 Cleanup failed ❌"
exit 1
@ -41,6 +42,7 @@ if [ "$integration" = "docker" ] ; then
# Start stack
docker-compose pull bw-docker-proxy app1
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "❌ Pull failed"
exit 1
@ -48,10 +50,12 @@ if [ "$integration" = "docker" ] ; then
echo "🌐 Starting stack ..."
docker compose up -d
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🌐 Up failed, retrying ... ⚠️"
cleanup_stack
docker compose up -d
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "🌐 Up failed ❌"
exit 1
@ -72,7 +76,7 @@ if [ "$integration" == "docker" ] ; then
containers=("ui-bw-1" "ui-bw-scheduler-1" "ui-bw-ui-1")
healthy="true"
for container in "${containers[@]}" ; do
check="$(docker inspect --format "{{json .State.Health }}" $container | grep "healthy")"
check="$(docker inspect --format "{{json .State.Health }}" "$container" | grep "healthy")"
if [ "$check" = "" ] ; then
echo "⚠️ Container $container is not healthy yet ..."
healthy="false"
@ -116,7 +120,7 @@ else
exit 1
fi
if ! [ -z "$(sudo journalctl -u bunkerweb --no-pager | grep "SYSTEMCTL - ❌")" ] ; then
if sudo journalctl -u bunkerweb --no-pager | grep -q "SYSTEMCTL - ❌ " ; then
echo "🌐 ⚠ Linux stack got an issue, restarting ..."
sudo journalctl --rotate
sudo journalctl --vacuum-time=1s
@ -136,6 +140,7 @@ fi
# Start tests
if [ "$integration" == "docker" ] ; then
docker-compose -f docker-compose.test.yml build
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "❌ Build failed"
exit 1
@ -146,6 +151,7 @@ else
python3 main.py
fi
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
if [ "$integration" == "docker" ] ; then
docker compose logs