Last active
November 15, 2017 14:52
-
-
Save acafourek/75c6b8c26810c2094ffa8932949b1f53 to your computer and use it in GitHub Desktop.
AS VVV init script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Provision WordPress Stable | |
DOMAIN=`get_primary_host "${VVV_SITE_NAME}".test` | |
DOMAINS=`get_hosts "${DOMAIN}"` | |
SITE_TITLE=`get_config_value 'site_title' "${DOMAIN}"` | |
WP_VERSION=`get_config_value 'wp_version' 'latest'` | |
WP_TYPE=`get_config_value 'wp_type' "single"` | |
DB_NAME=`get_config_value 'db_name' "${VVV_SITE_NAME}"` | |
DB_NAME=${DB_NAME//[\\\/\.\<\>\:\"\'\|\?\!\*-]/} | |
# Make a database, if we don't already have one | |
echo -e "\nCreating database '${DB_NAME}' (if it's not already there)" | |
mysql -u root --password=root -e "CREATE DATABASE IF NOT EXISTS ${DB_NAME}" | |
mysql -u root --password=root -e "GRANT ALL PRIVILEGES ON ${DB_NAME}.* TO wp@localhost IDENTIFIED BY 'wp';" | |
echo -e "\n DB operations done.\n\n" | |
# Nginx Logs | |
mkdir -p ${VVV_PATH_TO_SITE}/log | |
touch ${VVV_PATH_TO_SITE}/log/error.log | |
touch ${VVV_PATH_TO_SITE}/log/access.log | |
# Install and configure the latest stable version of WordPress | |
if [[ ! -f "${VVV_PATH_TO_SITE}/wordpress/wp-load.php" ]]; then | |
echo "Downloading WordPress..." | |
noroot wp core download --version="${WP_VERSION}" | |
fi | |
if [[ ! -f "${VVV_PATH_TO_SITE}/wordpress/wp-config.php" ]]; then | |
echo "Configuring WordPress Stable..." | |
noroot wp core config --dbname="${DB_NAME}" --dbuser=wp --dbpass=wp --quiet --extra-php <<PHP | |
define( 'WP_DEBUG', true ); | |
PHP | |
fi | |
if ! $(noroot wp core is-installed); then | |
echo "Installing WordPress Stable..." | |
if [ "${WP_TYPE}" = "subdomain" ]; then | |
INSTALL_COMMAND="multisite-install --subdomains" | |
elif [ "${WP_TYPE}" = "subdirectory" ]; then | |
INSTALL_COMMAND="multisite-install" | |
else | |
INSTALL_COMMAND="install" | |
fi | |
noroot wp core ${INSTALL_COMMAND} --url="${DOMAIN}" --quiet --title="${SITE_TITLE}" --admin_name=admin --admin_email="admin@local.test" --admin_password="password" | |
else | |
echo "Updating WordPress Stable..." | |
cd ${VVV_PATH_TO_SITE}/wordpress | |
noroot wp core update --version="${WP_VERSION}" | |
fi | |
cp -f "${VVV_PATH_TO_SITE}/provision/vvv-nginx.conf.tmpl" "${VVV_PATH_TO_SITE}/provision/vvv-nginx.conf" | |
sed -i "s#{{DOMAINS_HERE}}#${DOMAINS}#" "${VVV_PATH_TO_SITE}/provision/vvv-nginx.conf" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment