#!/usr/bin/env bash
wpcli='wp'
default_username='better_admin_username'
default_password='default_admin_password'
install_email='your_email@your_domain.com'
# test for wp-cli
if hash wp 2>/dev/null; then
echo "Found WP-CLI..."
else
echo "Missing WP-CLI, going to try installing it..."
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
wpcli='php wp-cli.phar'
fi
# prompt for infoz
read -p "Site name: " sitename
read -p "Site description: " description
read -p "Site URL: " siteurl
read -p "DB name: " dbname
read -p "DB user: " dbuser
read -s -p "DB pass: " dbpass
# do the basic WP install
${wpcli} core download
${wpcli} core config --dbname=$dbname --dbuser=$dbuser --dbpass="$dbpass"
${wpcli} core install --url=$siteurl --title="$sitename" --admin_user="$default_username" --admin_password="$default_password" --admin_email="$install_email"
# configure settings
${wpcli} rewrite structure '/%category%/%postname%'
${wpcli} option update blogdescription "$description"
${wpcli} option update blog_public 0