linux - fix tests docker cp and pass single -c argument to su

This commit is contained in:
bunkerity 2021-06-22 21:56:10 +02:00
parent d0366fcc0d
commit 60057a17e3
No known key found for this signature in database
GPG Key ID: 3D80806F12602A7C
2 changed files with 8 additions and 8 deletions

View File

@ -4,7 +4,7 @@ function do_and_check_cmd() {
if [ "$CHANGE_DIR" != "" ] ; then if [ "$CHANGE_DIR" != "" ] ; then
cd "$CHANGE_DIR" cd "$CHANGE_DIR"
fi fi
output=$(su -s "/bin/bash" -c "$@" nginx 2>&1) output=$(su -s "/bin/bash" -c "$1" nginx 2>&1)
ret="$?" ret="$?"
if [ $ret -ne 0 ] ; then if [ $ret -ne 0 ] ; then
echo "[!] Error from command : $*" echo "[!] Error from command : $*"
@ -29,20 +29,20 @@ fi
# Run generator # Run generator
echo "[*] Generate configuration files" 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 # Run pre-jobs
echo "[*] 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 # Reload nginx if it's running
if [ -f "/tmp/nginx.pid" ] ; then if [ -f "/tmp/nginx.pid" ] ; then
echo "[*] Reload nginx" echo "[*] Reload nginx"
do_and_check_cmd nginx -s reload do_and_check_cmd "nginx -s reload"
# Otherwise start it # Otherwise start it
else else
echo "[*] Start nginx" echo "[*] Start nginx"
do_and_check_cmd nginx -g 'daemon off;' do_and_check_cmd "nginx -g 'daemon off;'"
fi fi
# Run post-jobs # Run post-jobs

View File

@ -55,7 +55,7 @@ if [ $? -ne 0 ] ; then
fi fi
echo "[*] Copy variables.env" 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 if [ $? -ne 0 ] ; then
echo "[!] docker cp failed" echo "[!] docker cp failed"
cleanup "$id" cleanup "$id"
@ -63,7 +63,7 @@ if [ $? -ne 0 ] ; then
fi fi
echo "[*] Copy index.html" 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 if [ $? -ne 0 ] ; then
echo "[!] docker cp failed" echo "[!] docker cp failed"
cleanup "$id" cleanup "$id"
@ -79,7 +79,7 @@ if [ $? -ne 0 ] || [ "$res" != "ok" ] ; then
fi fi
echo "[*] Exec curl" echo "[*] Exec curl"
res="$(curl -s http://localhost/") res="$(curl -s -H "User-Agent: LegitOne" http://localhost/")
if [ $? -ne 0 ] || [ "$res" != "ok" ] ; then if [ $? -ne 0 ] || [ "$res" != "ok" ] ; then
echo "[!] curl failed" echo "[!] curl failed"
cleanup "$id" cleanup "$id"