mirror of
https://github.com/bunkerity/bunkerized-nginx
synced 2023-12-13 21:30:18 +01:00
various fixes for linux and get ui tests exit code from container
This commit is contained in:
parent
1cf4a5665d
commit
19870f154c
4 changed files with 39 additions and 5 deletions
|
@ -25,6 +25,11 @@ function do_and_check_cmd() {
|
||||||
echo "Setting ownership for all necessary directories to nginx user and group..."
|
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
|
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
|
# Auto start BW service on boot and start it now
|
||||||
echo "Enabling and starting bunkerweb service..."
|
echo "Enabling and starting bunkerweb service..."
|
||||||
do_and_check_cmd systemctl enable bunkerweb
|
do_and_check_cmd systemctl enable bunkerweb
|
||||||
|
@ -80,4 +85,14 @@ else
|
||||||
echo "Old database file not found. Skipping copy..."
|
echo "Old database file not found. Skipping copy..."
|
||||||
fi
|
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 !"
|
echo "Postinstall successful !"
|
|
@ -28,7 +28,6 @@ function stop_nginx() {
|
||||||
while [ 1 ] ; do
|
while [ 1 ] ; do
|
||||||
pgrep nginx
|
pgrep nginx
|
||||||
if [ $? -ne 0 ] ; then
|
if [ $? -ne 0 ] ; then
|
||||||
log "SYSTEMCTL" "ℹ️ " "nginx is stopped"
|
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
log "SYSTEMCTL" "ℹ️ " "Waiting for nginx to stop..."
|
log "SYSTEMCTL" "ℹ️ " "Waiting for nginx to stop..."
|
||||||
|
@ -84,6 +83,9 @@ function start() {
|
||||||
# Setup and check /data folder
|
# Setup and check /data folder
|
||||||
/usr/share/bunkerweb/helpers/data.sh "ENTRYPOINT"
|
/usr/share/bunkerweb/helpers/data.sh "ENTRYPOINT"
|
||||||
|
|
||||||
|
# Stop scheduler if it's running
|
||||||
|
stop_scheduler
|
||||||
|
|
||||||
# Stop nginx if it's running
|
# Stop nginx if it's running
|
||||||
stop_nginx
|
stop_nginx
|
||||||
|
|
||||||
|
@ -96,11 +98,29 @@ function start() {
|
||||||
log "ENTRYPOINT" "❌" "Error while generating config from /var/tmp/bunkerweb/tmp.env"
|
log "ENTRYPOINT" "❌" "Error while generating config from /var/tmp/bunkerweb/tmp.env"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Start nginx
|
||||||
|
log "ENTRYPOINT" "ℹ️" "Starting nginx ..."
|
||||||
nginx
|
nginx
|
||||||
if [ $? -ne 0 ] ; then
|
if [ $? -ne 0 ] ; then
|
||||||
log "ENTRYPOINT" "❌" "Error while executing nginx"
|
log "ENTRYPOINT" "❌" "Error while executing nginx"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
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
|
# Create dummy variables.env
|
||||||
if [ ! -f /etc/bunkerweb/variables.env ]; then
|
if [ ! -f /etc/bunkerweb/variables.env ]; then
|
||||||
|
@ -119,7 +139,6 @@ function start() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Execute scheduler
|
# Execute scheduler
|
||||||
stop_scheduler
|
|
||||||
log "ENTRYPOINT" "ℹ️ " "Executing scheduler ..."
|
log "ENTRYPOINT" "ℹ️ " "Executing scheduler ..."
|
||||||
/usr/share/bunkerweb/scheduler/main.py --variables /etc/bunkerweb/variables.env
|
/usr/share/bunkerweb/scheduler/main.py --variables /etc/bunkerweb/variables.env
|
||||||
if [ "$?" -ne 0 ] ; then
|
if [ "$?" -ne 0 ] ; then
|
||||||
|
|
|
@ -388,7 +388,7 @@ if __name__ == "__main__":
|
||||||
# Reloading the nginx server.
|
# Reloading the nginx server.
|
||||||
proc = subprocess_run(
|
proc = subprocess_run(
|
||||||
# Reload nginx
|
# Reload nginx
|
||||||
["/etc/init.d/nginx", "reload"],
|
["/usr/sbin/nginx", "-s", "reload"],
|
||||||
stdin=DEVNULL,
|
stdin=DEVNULL,
|
||||||
stderr=STDOUT,
|
stderr=STDOUT,
|
||||||
env=deepcopy(env),
|
env=deepcopy(env),
|
||||||
|
@ -446,7 +446,7 @@ if __name__ == "__main__":
|
||||||
# Reloading the nginx server.
|
# Reloading the nginx server.
|
||||||
proc = subprocess_run(
|
proc = subprocess_run(
|
||||||
# Reload nginx
|
# Reload nginx
|
||||||
["/etc/init.d/nginx", "reload"],
|
["/usr/sbin/nginx", "-s", "reload"],
|
||||||
stdin=DEVNULL,
|
stdin=DEVNULL,
|
||||||
stderr=STDOUT,
|
stderr=STDOUT,
|
||||||
env=deepcopy(env),
|
env=deepcopy(env),
|
||||||
|
|
|
@ -49,7 +49,7 @@ if [ $? -ne 0 ] ; then
|
||||||
echo "❌ Build failed"
|
echo "❌ Build failed"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
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
|
||||||
exit $?
|
exit $?
|
Loading…
Reference in a new issue