Last active
February 2, 2017 16:47
-
-
Save GlennTaylorDigital/84b84f6ca625cb8ae5cda9590004a25c to your computer and use it in GitHub Desktop.
Script used to install Bedrock (WordPress), FoundationPress and plugins...
This file contains hidden or 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
#!/bin/bash | |
echo "Running this script will help setup and obtain resources for your new WordPress website." | |
read -p "Do you wish to proceed with setup? (Y/N)" CONF_PROCEED | |
if [ "$CONF_PROCEED" == "Y" ] || [ "$CONF_PROCEED" == "y" ]; then | |
read -p "Which directory would you like us to install WordPress into?: " INSTALL_DIRECTORY | |
mkdir -p "$INSTALL_DIRECTORY" | |
echo "Copying Bedrock in to: $INSTALL_DIRECTORY" | |
composer create-project roots/bedrock "$INSTALL_DIRECTORY" | |
read -p "Would you like to configure your .env file? (Y/N)" ENVFILE | |
# Create .env file | |
if [ "$ENVFILE" == "Y" ] || [ "$ENVFILE" == "y" ]; then | |
# Remove existing .env file | |
rm -rf "$INSTALL_DIRECTORY/.env" | |
# Retrieve database name | |
echo "Please provide database name:" | |
read DATABASE_NAME | |
# Retrieve database user | |
read -p "Please provide database user [root]: " DATABASE_USER | |
DATABASE_USER=${DATABASE_USER:-"root"} | |
# Retrieve database password | |
read -p "Please provide database password [root]: " DATABASE_PASS | |
DATABASE_PASS=${DATABASE_PASS:-"root"} | |
# Retrieve database host | |
read -p "Please provide database host [localhost]: " DATABASE_HOST | |
DATABASE_HOST=${DATABASE_HOST:-"localhost"} | |
# Retrieve base URL | |
echo "Please provide WordPress base URL (do not include http:// or trailing /):" | |
read BASE_URL | |
echo "Writing .env file..." | |
# Write the script | |
echo "DB_NAME=$DATABASE_NAME | |
DB_USER=$DATABASE_USER | |
DB_PASSWORD=$DATABASE_PASS | |
DB_HOST=$DATABASE_HOST | |
WP_ENV=development | |
WP_HOME=http://$BASE_URL | |
WP_SITEURL=http://$BASE_URL/wp | |
AUTH_KEY='$(cat /dev/urandom | LC_CTYPE=C tr -dc 'a-zA-Z0-9-_!@#$%^&*()_+{}|:<>?=' | fold -w 64 | head -n 1)' | |
SECURE_AUTH_KEY='$(cat /dev/urandom | LC_CTYPE=C tr -dc 'a-zA-Z0-9-_!@#$%^&*()_+{}|:<>?=' | fold -w 64 | head -n 1)' | |
LOGGED_IN_KEY='$(cat /dev/urandom | LC_CTYPE=C tr -dc 'a-zA-Z0-9-_!@#$%^&*()_+{}|:<>?=' | fold -w 64 | head -n 1)' | |
NONCE_KEY='$(cat /dev/urandom | LC_CTYPE=C tr -dc 'a-zA-Z0-9-_!@#$%^&*()_+{}|:<>?=' | fold -w 64 | head -n 1)' | |
AUTH_SALT='$(cat /dev/urandom | LC_CTYPE=C tr -dc 'a-zA-Z0-9-_!@#$%^&*()_+{}|:<>?=' | fold -w 64 | head -n 1)' | |
SECURE_AUTH_SALT='$(cat /dev/urandom | LC_CTYPE=C tr -dc 'a-zA-Z0-9-_!@#$%^&*()_+{}|:<>?=' | fold -w 64 | head -n 1)' | |
LOGGED_IN_SALT='$(cat /dev/urandom | LC_CTYPE=C tr -dc 'a-zA-Z0-9-_!@#$%^&*()_+{}|:<>?=' | fold -w 64 | head -n 1)' | |
NONCE_SALT='$(cat /dev/urandom | LC_CTYPE=C tr -dc 'a-zA-Z0-9-_!@#$%^&*()_+{}|:<>?=' | fold -w 64 | head -n 1)'" > "$INSTALL_DIRECTORY/.env" | |
fi | |
# Check if user wants an entry in their hosts file | |
read -p "Would you like to create an entry in your hosts file? (Y/N)" HOSTS | |
# Append record to hosts file | |
if [ "$HOSTS" == "Y" ] || [ "$HOSTS" == "y" ]; then | |
read -p "Where is your hosts file located? [/etc/hosts]: " HOSTS_LOCATION | |
HOSTS_LOCATION=${HOSTS_LOCATION:-"/etc/hosts"} | |
echo "Writing hosts entry..." | |
sudo -- sh -c -e "echo '127.0.0.1 $BASE_URL' >> $HOSTS_LOCATION"; | |
fi | |
# Check if user requires foundationpress | |
read -p "Would you like to install FoundationPress? (Y/N)" FOUNDATIONPRESS | |
# Install FoundationPress | |
if [ "$FOUNDATIONPRESS" == "Y" ] || [ "$FOUNDATIONPRESS" == "y" ]; then | |
# Clone FoundationPress in to the themes directory | |
echo "Cloning FoundationPress..." | |
cd "$INSTALL_DIRECTORY/web/app/themes/" | |
git clone https://github.com/olefredrik/FoundationPress.git | |
# Find out what the theme should be called | |
echo "What should your theme be called?" | |
read THEMENAME | |
# Rename the theme directory and move in to theme directory | |
mv FoundationPress $THEMENAME | |
cd $THEMENAME | |
# Update style.css file | |
echo "Updating style.css" | |
sed -i.bak "/Theme URI:/d; /Github Theme URI:/d; /License:/d; /License URI:/d; s/Version:.*/Version: 1.0.0/g; s/FoundationPress/$THEMENAME/g" ./style.css | |
echo "Updating .gitignore" | |
sed -i.bak "/assets\/stylesheets\//d; /assets\/components\//d; /assets\/javascript\/vendor\//d; /assets\/javascript\/foundation.js/d; " ./.gitignore | |
read -p "Do you want to install NPM packages now? (Y/N)" NPMPACKAGES | |
if [ "$NPMPACKAGES" == "Y" ] || [ "$NPMPACKAGES" == "y" ]; then | |
echo "Installing NPM packages..." | |
npm install | |
fi | |
# Return to main directory | |
cd ../../../../ | |
echo "Removing submodule reference..." | |
rm -rf "web/app/themes/$THEMENAME/.git" | |
read -p "Would you like to install Advanced Custom Fields? (Y/N)" ACF | |
if [ "$ACF" == "Y" ] || [ "$ACF" == "y" ]; then | |
echo "Installing Advanced Custom Fields..." | |
composer require wpackagist-plugin/advanced-custom-fields | |
fi | |
read -p "Would you like to install Yoast SEO? (Y/N)" YOAST | |
if [ "$YOAST" == "Y" ] || [ "$YOAST" == "y" ]; then | |
echo "Installing Yoast SEO..." | |
composer require wpackagist-plugin/wordpress-seo | |
fi | |
read -p "Would you like to install W3 Total Cache? (Y/N)" W3TOTALCACHE | |
if [ "$W3TOTALCACHE" == "Y" ] || [ "$W3TOTALCACHE" == "y" ]; then | |
echo "Installing W3 Total Cache..." | |
composer require wpackagist-plugin/w3-total-cache | |
fi | |
fi | |
else | |
# Confirm cancellation | |
echo "Setup cancelled" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment