You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

create.sh 1.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #! /bin/bash
  2. #
  3. set -o allexport;
  4. source .env;
  5. set +o allexport
  6. echo "Setting up docker volume and network...";
  7. docker volume create $PREFIX-web;
  8. docker volume create $PREFIX-db;
  9. docker network create $PREFIX;
  10. docker network connect $PREFIX traefik;
  11. docker-compose up -d web;
  12. while ! docker ps -q -f name=$PREFIX-web; do
  13. echo "Waiting for the web container to be up and running...";
  14. sleep 1;
  15. done
  16. docker-compose up -d db;
  17. while ! docker ps -q -f name=$PREFIX-db; do
  18. echo "Waiting for the db container to be up and running...";
  19. sleep 1;
  20. done
  21. while ! docker exec wptest-web /bin/sh -c "mysqladmin ping -h $PREFIX-db -P 3306 --protocol=tcp -u user -puser --silent" ; do
  22. echo "Waiting for the mysql server in the db container to be up and running...";
  23. sleep 1;
  24. done
  25. echo "Installing WordPress"
  26. docker exec --user www-data $PREFIX-web /bin/sh -c "
  27. wp core download \
  28. --locale=$WP_LOCALE \
  29. --path=/var/www/html \
  30. --version=$WP_VERSION";
  31. docker exec --user www-data $PREFIX-web /bin/sh -c '
  32. wp config create \
  33. --dbhost='"$PREFIX-db"' \
  34. --dbname='"$PREFIX"' \
  35. --dbpass='"$DB_USER_PASSWORD"' \
  36. --dbuser='"$DB_USER"' \
  37. --force \
  38. --path=/var/www/html \
  39. --skip-check \
  40. --extra-php <<PHP
  41. if (isset(\$_SERVER["HTTP_X_FORWARDED_PROTO"]) && \$_SERVER["HTTP_X_FORWARDED_PROTO"] == "https") \$_SERVER["HTTPS"]="on";
  42. PHP
  43. '
  44. docker exec --user www-data $PREFIX-web /bin/sh -c "
  45. wp core install \
  46. --admin_email=no@mail.com \
  47. --admin_password=admin \
  48. --admin_user=admin \
  49. --path=/var/www/html \
  50. --skip-email \
  51. --title=$PREFIX \
  52. --url=https://www.$PREFIX.localhost";
  53. docker exec --user www-data $PREFIX-web /bin/sh -c '
  54. wp theme install twentyseventeen \
  55. --activate \
  56. --path=/var/www/html';