various fixes for linux and get ui tests exit code from container

This commit is contained in:
bunkerity 2023-03-24 17:50:20 +01:00
parent 1cf4a5665d
commit 19870f154c
4 changed files with 39 additions and 5 deletions

View File

@ -25,6 +25,11 @@ function do_and_check_cmd() {
echo "Setting ownership for all necessary directories to nginx user and group..."
do_and_check_cmd chown -R nginx:nginx /usr/share/bunkerweb /var/cache/bunkerweb /var/lib/bunkerweb /etc/bunkerweb /var/tmp/bunkerweb
# Stop and disable nginx on boot
echo "Stop and disable nginx on boot..."
do_and_check_cmd systemctl stop bunkerweb
do_and_check_cmd systemctl disable bunkerweb
# Auto start BW service on boot and start it now
echo "Enabling and starting bunkerweb service..."
do_and_check_cmd systemctl enable bunkerweb
@ -80,4 +85,14 @@ else
echo "Old database file not found. Skipping copy..."
fi
# Create /var/www/html if needed
if [ ! -d /var/www/html ] ; then
echo "Creating /var/www/html directory ..."
do_and_check_cmd mkdir -p /var/www/html
do_and_check_cmd chmod 750 /var/www/html
do_and_check_cmd chown root:nginx /var/www/html
else
echo "/var/www/html directory already exists, skipping copy..."
fi
echo "Postinstall successful !"

View File

@ -28,7 +28,6 @@ function stop_nginx() {
while [ 1 ] ; do
pgrep nginx
if [ $? -ne 0 ] ; then
log "SYSTEMCTL" " " "nginx is stopped"
break
fi
log "SYSTEMCTL" " " "Waiting for nginx to stop..."
@ -84,6 +83,9 @@ function start() {
# Setup and check /data folder
/usr/share/bunkerweb/helpers/data.sh "ENTRYPOINT"
# Stop scheduler if it's running
stop_scheduler
# Stop nginx if it's running
stop_nginx
@ -96,11 +98,29 @@ function start() {
log "ENTRYPOINT" "❌" "Error while generating config from /var/tmp/bunkerweb/tmp.env"
exit 1
fi
# Start nginx
log "ENTRYPOINT" "" "Starting nginx ..."
nginx
if [ $? -ne 0 ] ; then
log "ENTRYPOINT" "❌" "Error while executing nginx"
exit 1
fi
count=0
while [ $count -lt 10 ] ; do
check="$(curl -s -H "Host: healthcheck.bunkerweb.io" http://127.0.0.1:6000/healthz 2>&1)"
if [ $? -eq 0 ] && [ "$check" = "ok" ] ; then
break
fi
count=$(($count + 1))
sleep 1
log "ENTRYPOINT" "" "Waiting for nginx to start ..."
done
if [ $count -ge 10 ] ; then
log "ENTRYPOINT" "❌" "nginx is not started"
exit 1
fi
log "ENTRYPOINT" "" "nginx started ..."
# Create dummy variables.env
if [ ! -f /etc/bunkerweb/variables.env ]; then
@ -119,7 +139,6 @@ function start() {
fi
# Execute scheduler
stop_scheduler
log "ENTRYPOINT" " " "Executing scheduler ..."
/usr/share/bunkerweb/scheduler/main.py --variables /etc/bunkerweb/variables.env
if [ "$?" -ne 0 ] ; then

View File

@ -388,7 +388,7 @@ if __name__ == "__main__":
# Reloading the nginx server.
proc = subprocess_run(
# Reload nginx
["/etc/init.d/nginx", "reload"],
["/usr/sbin/nginx", "-s", "reload"],
stdin=DEVNULL,
stderr=STDOUT,
env=deepcopy(env),
@ -446,7 +446,7 @@ if __name__ == "__main__":
# Reloading the nginx server.
proc = subprocess_run(
# Reload nginx
["/etc/init.d/nginx", "reload"],
["/usr/sbin/nginx", "-s", "reload"],
stdin=DEVNULL,
stderr=STDOUT,
env=deepcopy(env),

View File

@ -49,7 +49,7 @@ if [ $? -ne 0 ] ; then
echo "❌ Build failed"
exit 1
fi
docker-compose -f docker-compose.tests.yml up
docker-compose -f docker-compose.tests.yml up --abort-on-container-exit --exit-code-from ui-tests
# Exit
exit $?