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
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

View File

@ -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"