Skip to content

Instantly share code, notes, and snippets.

@schlessera
Last active September 5, 2022 01:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save schlessera/04d347f400ce83c575af9522ec5b3fdc to your computer and use it in GitHub Desktop.
Save schlessera/04d347f400ce83c575af9522ec5b3fdc to your computer and use it in GitHub Desktop.
Site setup script example

Site setup script example

This script is an example of how a custom site setup automation could look like to improve personal developer productivity.

This script was originally assembled by @johnbillion for a workshop at WordCamp Torino 2018.

See https://github.com/johnbillion/wctrn-site-setup-script.

#!/usr/bin/env bash
# Configure the script to exit immediately if any command fails:
set -e
# Download WordPress core files if they're not already present:
if [ ! -f "wp-load.php" ]; then
wp core download
else
echo "WordPress files are already present."
fi
# Create a wp-config.php file if it's not already present:
if [ ! -f "wp-config.php" ]; then
echo "Please enter your database credentials:"
wp config create --prompt
fi
# Install WordPress if it isn't already:
if ! $(wp core is-installed); then
echo "Please enter your WordPress installation details:"
wp core install --prompt
else
echo "WordPress is already installed."
fi
# Install some of our favourite plugins all at once:
echo "Installing plugins..."
wp plugin install jetpack wp-super-cache contact-form-7 wordpress-seo user-switching
# Activate and configure a few plugins:
echo "Configuring plugins..."
wp plugin activate wordpress-seo
wp option patch update wpseo_titles metadesc-home-wpseo "My new website"
# Create a child theme that we can start working on:
wp theme list
echo "Please enter your child theme details:"
wp scaffold child-theme --prompt
# Install the wp-admin package:
if ! $(wp cli has-command admin); then
echo "Installing the admin package..."
wp package install wp-cli/admin-command
fi
# Let's go!
echo "Done!"
wp admin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment