You are here

deploy-on-container.sh in Convert Media Tags to Markup 8

Same filename and directory in other branches
  1. 2.x docker-resources/scripts/deploy-on-container.sh
#!/bin/bash
#
# This script is run when the Drupal docker container is ready. It prepares
# an environment for development or testing, which contains a full Drupal
# 8 installation with a running website and our custom module.
#
set -e

echo "Will try to connect to MySQL container until it is up. This can take about 15 seconds."
OUTPUT="ERROR"
while [[ "$OUTPUT" == *"ERROR"* ]]
do
  OUTPUT=$(echo 'show databases'|{ mysql -h mysql -u root --password=drupal 2>&1 || true; })
  if [[ "$OUTPUT" == *"ERROR"* ]]; then
    echo "MySQL container is not available yet. Should not be long..."
    sleep 2
  else
    echo "MySQL is up! Moving on..."
  fi
done

OUTPUT=$(echo 'select * from users limit 1'|{ mysql --user=root --password=drupal --database=drupal --host=mysql 2>&1 || true; })
if [[ "$OUTPUT" == *"ERROR"* ]]; then
  echo "Installing Drupal because we did not find an entry in the users table."
  drush si -y --db-url=mysql://root:drupal@mysql/drupal
  drush en -y devel convert_media_tags_to_markup
else
  echo "Assuming Drupal is already running, because there is a users table with at least one entry."
fi
echo "Deployment of site OK; setting permissions for the file directory"
mkdir -p /var/www/html/sites/default/files
chown -R www-data:www-data /var/www/html/sites/default/files

File

docker-resources/scripts/deploy-on-container.sh
View source
  1. #!/bin/bash
  2. #
  3. # This script is run when the Drupal docker container is ready. It prepares
  4. # an environment for development or testing, which contains a full Drupal
  5. # 8 installation with a running website and our custom module.
  6. #
  7. set -e
  8. echo "Will try to connect to MySQL container until it is up. This can take about 15 seconds."
  9. OUTPUT="ERROR"
  10. while [[ "$OUTPUT" == *"ERROR"* ]]
  11. do
  12. OUTPUT=$(echo 'show databases'|{ mysql -h mysql -u root --password=drupal 2>&1 || true; })
  13. if [[ "$OUTPUT" == *"ERROR"* ]]; then
  14. echo "MySQL container is not available yet. Should not be long..."
  15. sleep 2
  16. else
  17. echo "MySQL is up! Moving on..."
  18. fi
  19. done
  20. OUTPUT=$(echo 'select * from users limit 1'|{ mysql --user=root --password=drupal --database=drupal --host=mysql 2>&1 || true; })
  21. if [[ "$OUTPUT" == *"ERROR"* ]]; then
  22. echo "Installing Drupal because we did not find an entry in the users table."
  23. drush si -y --db-url=mysql://root:drupal@mysql/drupal
  24. drush en -y devel convert_media_tags_to_markup
  25. else
  26. echo "Assuming Drupal is already running, because there is a users table with at least one entry."
  27. fi
  28. echo "Deployment of site OK; setting permissions for the file directory"
  29. mkdir -p /var/www/html/sites/default/files
  30. chown -R www-data:www-data /var/www/html/sites/default/files