From 60057a17e31499a20c55d26dafe3e98e37732dab Mon Sep 17 00:00:00 2001 From: bunkerity Date: Tue, 22 Jun 2021 21:56:10 +0200 Subject: [PATCH] linux - fix tests docker cp and pass single -c argument to su --- helpers/bunkerized-nginx | 10 +++++----- tests/linux.sh | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/helpers/bunkerized-nginx b/helpers/bunkerized-nginx index a6a327f..99dc63a 100644 --- a/helpers/bunkerized-nginx +++ b/helpers/bunkerized-nginx @@ -4,7 +4,7 @@ function do_and_check_cmd() { if [ "$CHANGE_DIR" != "" ] ; then cd "$CHANGE_DIR" fi - output=$(su -s "/bin/bash" -c "$@" nginx 2>&1) + output=$(su -s "/bin/bash" -c "$1" nginx 2>&1) ret="$?" if [ $ret -ne 0 ] ; then echo "[!] Error from command : $*" @@ -29,20 +29,20 @@ fi # Run generator echo "[*] Generate configuration files" -do_and_check_cmd /opt/bunkerized-nginx/gen/main.py --settings /opt/bunkerized-nginx/settings.json --templates /opt/bunkerized-nginx/confs --output /etc/nginx --variables /opt/bunkerized-nginx/variables.env +do_and_check_cmd "/opt/bunkerized-nginx/gen/main.py --settings /opt/bunkerized-nginx/settings.json --templates /opt/bunkerized-nginx/confs --output /etc/nginx --variables /opt/bunkerized-nginx/variables.env" # Run pre-jobs echo "[*] Run pre-jobs" -do_and_check_cmd /opt/bunkerized-nginx/entrypoint/pre-jobs.sh +do_and_check_cmd "/opt/bunkerized-nginx/entrypoint/pre-jobs.sh" # Reload nginx if it's running if [ -f "/tmp/nginx.pid" ] ; then echo "[*] Reload nginx" - do_and_check_cmd nginx -s reload + do_and_check_cmd "nginx -s reload" # Otherwise start it else echo "[*] Start nginx" - do_and_check_cmd nginx -g 'daemon off;' + do_and_check_cmd "nginx -g 'daemon off;'" fi # Run post-jobs diff --git a/tests/linux.sh b/tests/linux.sh index 9813e06..625c864 100755 --- a/tests/linux.sh +++ b/tests/linux.sh @@ -55,7 +55,7 @@ if [ $? -ne 0 ] ; then fi echo "[*] Copy variables.env" -docker cp "tests/variables.env:$id" /opt/bunkerized-nginx/variables.env +docker cp "tests/variables.env" "$id:/opt/bunkerized-nginx" if [ $? -ne 0 ] ; then echo "[!] docker cp failed" cleanup "$id" @@ -63,7 +63,7 @@ if [ $? -ne 0 ] ; then fi echo "[*] Copy index.html" -docker cp "tests/index.html:$id" /opt/bunkerized-nginx/www +docker cp "tests/index.html" "$id:/opt/bunkerized-nginx/www" if [ $? -ne 0 ] ; then echo "[!] docker cp failed" cleanup "$id" @@ -79,7 +79,7 @@ if [ $? -ne 0 ] || [ "$res" != "ok" ] ; then fi echo "[*] Exec curl" -res="$(curl -s http://localhost/") +res="$(curl -s -H "User-Agent: LegitOne" http://localhost/") if [ $? -ne 0 ] || [ "$res" != "ok" ] ; then echo "[!] curl failed" cleanup "$id"