wordpress/test
2023-02-25 01:13:50 +01:00

52 lines
961 B
Bash

#!/bin/bash
TMP=/tmp/wordpress
TIMEOUT=120
HPATH=$(pwd)
tear_down () {
echo "Clean"
cd $TMP
docker-compose stop
docker-compose down -v --remove-orphans
docker network prune -f
cd ..
rm -rf $TMP
cd $HPATH
}
[ -d $TMP ] && tear_down
mkdir $TMP
cat env.sample | sed "s/USER_GROUP.*$/USER_GROUP=`id -u`:`id -g`/" > $TMP/.env
cat docker-compose.yml | sed 's/registry.sindominio.net\/wordpress/wordpress/' > $TMP/docker-compose.yml
cd $TMP
mkdir db uploads
docker-compose down -v --remove-orphans
docker-compose up -d
# Wait for the web server to respond
cont=0
echo -n "Espera al servidor web "
while ! curl -s localhost:12001 > /dev/null; do
echo -n "."
cont=$((cont+1))
if [ "$cont" == $TIMEOUT ]; then
echo " no responde"
tear_down
exit 1
fi
sleep 1
done
echo " connectado"
STR=`curl -s localhost:12001 |grep "Hello world!"`
tear_down
if [[ "$STR" == "" ]]
then
echo "No encontre 'Hello world!' en la web del contenedor"
exit 1
fi