Skip to content

Instantly share code, notes, and snippets.

Created April 21, 2017 13:39
Show Gist options
  • Save anonymous/0d09a5395fe5d9c4ffe3f9654c039c6d to your computer and use it in GitHub Desktop.
Save anonymous/0d09a5395fe5d9c4ffe3f9654c039c6d to your computer and use it in GitHub Desktop.

Revisions

  1. @invalid-email-address Anonymous created this gist Apr 21, 2017.
    57 changes: 57 additions & 0 deletions wpinstall.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,57 @@
    #!/bin/bash -e

    wpuser='exampleuser'

    clear

    echo "================================================================="
    echo "Awesome 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