Skip to content

Instantly share code, notes, and snippets.

@asha23
Created October 10, 2016 15:38
Show Gist options
  • Save asha23/b44e81c64b631911cc2de9aa38b1e9ef to your computer and use it in GitHub Desktop.
Save asha23/b44e81c64b631911cc2de9aa38b1e9ef to your computer and use it in GitHub Desktop.
WP CLI bash script
#!/bin/bash -e
wpuser='awhiting'
clear
echo "================================================================="
echo "Quick Wordpress Installer"
echo "================================================================="
# accept user input for the databse name
echo "Database Name: "
read -e dbname
# accept the name of our website
echo "Site Name: "
read -e sitename
# add a simple yes/no confirmation before we proceed
echo "Run Install? (y/n)"
read -e run
# if the user didn't say no, then go ahead an install
if [ "$run" == n ] ; then
exit
else
# download the WordPress core files
wp core download
# create the wp-config file
wp core config --dbname=$dbname --dbuser=root --dbpass=root
# parse the current directory name
currentdirectory=${PWD##*/}
# generate random 12 character password
password=$(LC_CTYPE=C tr -dc A-Za-z0-9_\!\@\#\$\%\^\&\*\(\)-+= < /dev/urandom | head -c 12)
# create database, and install WordPress
wp db create
wp core install --url="http://localhost/$currentdirectory" --title="$sitename" --admin_user="$wpuser" --admin_password="$password" --admin_email="[email protected]"
# install the _s theme
wp theme install https://github.com/Automattic/_s/archive/master.zip --activate
clear
echo "================================================================="
echo "Installation is complete. Your username/password is listed below."
echo ""
echo "Username: $wpuser"
echo "Password: $password"
echo ""
echo "================================================================="
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment