deploy.sh 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #!/bin/bash
  2. drupal_mail=dio@ca.ne
  3. drupal_password=porcoddio
  4. drupal_path=/var/www/d8/
  5. drupal_db_name=www
  6. drupal_db_user=www
  7. drupal_hostname=www.example.com
  8. drupal_db_password=$(pwgen -B 16 1)
  9. . $(dirname $0)/../testingtoolchain/out.sh
  10. conf=$(dirname $0)/../config.sh
  11. [[ -f "$conf" ]] && . "$conf"
  12. set -e
  13. set -u
  14. progress "setting up MariaDB"
  15. pgrep -x mysqld || /etc/init.d/mysql start
  16. for try in {1..20}; do # elegante!
  17. if [[ -S /var/run/mysqld/mysqld.sock ]]; then
  18. break
  19. else
  20. sleep 0.2
  21. fi
  22. done
  23. if ! mysql -u root <<<'show databases;' | fgrep -v ${drupal_db_name}
  24. then
  25. #mysqladmin create "${drupal_db_name}"
  26. mysql -u root <<EOF
  27. CREATE USER '${drupal_db_user}'@'127.0.0.1' IDENTIFIED BY '${drupal_db_password}';
  28. GRANT ALL PRIVILEGES ON ${drupal_db_name}.* TO '${drupal_db_user}'@'127.0.0.1';
  29. EOF
  30. fi
  31. ok "MariaDB ready"
  32. progress "Drush system-wide config"
  33. mkdir -p /etc/drush/
  34. cat <<EOF > /etc/drush/aliases.drushrc.php
  35. <?php
  36. \$aliases['www'] = array(
  37. 'root' => '${drupal_path}',
  38. 'uri' => 'http://${drupal_hostname}',
  39. );
  40. EOF
  41. ok "Drush configurated"
  42. progress "Download and install drupal8 'base'"
  43. if [[ ! -d ${drupal_path} ]]; then
  44. mkdir -p "$(dirname ${drupal_path})"
  45. cd "$(dirname ${drupal_path})"
  46. drush dl drupal --drupal-project-rename=$(basename ${drupal_path})
  47. fi
  48. cd "${drupal_path}"
  49. note "Ci mette TANTO ma veramente!"
  50. drush --yes site-install --locale=it \
  51. --account-mail=${drupal_mail} \
  52. --account-name=techbloc-admin \
  53. --account-pass=${drupal_password} \
  54. --db-su=root \
  55. --db-url="mysql://${drupal_db_user}:${drupal_db_password}@localhost/${drupal_db_name}" \
  56. standard
  57. ok "Drupal is functional at ${drupal_path}"