Guest User

Untitled

a guest
Feb 26th, 2018
278
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.07 KB | None | 0 0
  1. #!/usr/bin/env bash
  2. # Provision WordPress Stable
  3.  
  4. DOMAIN=`get_primary_host "${VVV_SITE_NAME}".test`
  5. DOMAINS=`get_hosts "${DOMAIN}"`
  6. SITE_TITLE=`get_config_value 'site_title' "${DOMAIN}"`
  7. WP_VERSION=`get_config_value 'wp_version' 'latest'`
  8. WP_TYPE=`get_config_value 'wp_type' "single"`
  9. DB_NAME=`get_config_value 'db_name' "${VVV_SITE_NAME}"`
  10. DB_NAME=${DB_NAME//[\\\/\.\<\>\:\"\'\|\?\!\*-]/}
  11.  
  12. # Make a database, if we don't already have one
  13. echo -e "\nCreating database '${DB_NAME}' (if it's not already there)"
  14. mysql -u root --password=root -e "CREATE DATABASE IF NOT EXISTS ${DB_NAME}"
  15. mysql -u root --password=root -e "GRANT ALL PRIVILEGES ON ${DB_NAME}.* TO wp@localhost IDENTIFIED BY 'wp';"
  16. echo -e "\n DB operations done.\n\n"
  17.  
  18. # Nginx Logs
  19. mkdir -p ${VVV_PATH_TO_SITE}/log
  20. touch ${VVV_PATH_TO_SITE}/log/error.log
  21. touch ${VVV_PATH_TO_SITE}/log/access.log
  22.  
  23. # Install and configure the latest stable version of WordPress
  24. if [[ ! -f "${VVV_PATH_TO_SITE}/public_html/wp-load.php" ]]; then
  25. echo "Downloading WordPress..."
  26. noroot wp core download --version="${WP_VERSION}"
  27. fi
  28.  
  29. if [[ ! -f "${VVV_PATH_TO_SITE}/public_html/wp-config.php" ]]; then
  30. echo "Configuring WordPress Stable..."
  31. noroot wp core config --dbname="${DB_NAME}" --dbuser=wp --dbpass=wp --quiet --extra-php <<PHP
  32. define( 'WP_DEBUG', true );
  33. PHP
  34. fi
  35.  
  36. if ! $(noroot wp core is-installed); then
  37. echo "Installing WordPress Stable..."
  38.  
  39. if [ "${WP_TYPE}" = "subdomain" ]; then
  40. INSTALL_COMMAND="multisite-install --subdomains"
  41. elif [ "${WP_TYPE}" = "subdirectory" ]; then
  42. INSTALL_COMMAND="multisite-install"
  43. else
  44. INSTALL_COMMAND="install"
  45. fi
  46.  
  47. noroot wp core ${INSTALL_COMMAND} --url="${DOMAIN}" --quiet --title="${SITE_TITLE}" --admin_name=admin --admin_email="admin@local.test" --admin_password="password"
  48. else
  49. echo "Updating WordPress Stable..."
  50. cd ${VVV_PATH_TO_SITE}/public_html
  51. noroot wp core update --version="${WP_VERSION}"
  52. fi
  53.  
  54. cp -f "${VVV_PATH_TO_SITE}/provision/vvv-nginx.conf.tmpl" "${VVV_PATH_TO_SITE}/provision/vvv-nginx.conf"
  55. sed -i "s#{{DOMAINS_HERE}}#${DOMAINS}#" "${VVV_PATH_TO_SITE}/provision/vvv-nginx.conf"
Add Comment
Please, Sign In to add comment