Skip to content

Instantly share code, notes, and snippets.

@ryanknights
Created February 26, 2016 19:52
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ryanknights/e4f499324b916ddaba48 to your computer and use it in GitHub Desktop.
Save ryanknights/e4f499324b916ddaba48 to your computer and use it in GitHub Desktop.
Clean Wordpress Install Bash Script
#!/bin/bash
WORDPRESS_URL="https://wordpress.org/latest.tar.gz"
# GET ALL USER INPUT
echo "Project folder name?"
read PROJECT_FOLDER_NAME
echo "Project Source Url (eg. /home/users/name/desktop/)?"
read PROJECT_SOURCE_URL
echo "Setup wp_config? (y/n)"
read SHOULD_SETUP_DB
if [ $SHOULD_SETUP_DB = 'y' ]
then
echo "DB Name"
read DB_NAME
echo "DB Username"
read DB_USERNAME
echo "DB Password"
read DB_PASSWORD
fi
#LETS START INSTALLING
echo "Sit back and relax :) ......"
# CREATE PROJECT DIRECTORIES
cd "$PROJECT_SOURCE_URL"
echo "Creating $PROJECT_FOLDER_NAME"
mkdir "$PROJECT_FOLDER_NAME"
cd "$PROJECT_FOLDER_NAME"
# DOWNLOAD WORDPRESS
echo "Downloading Wordpress"
curl -O $WORDPRESS_URL
# UNZIP WORDPRESS AND REMOVE ARCHIVE FILES
echo "Unzipping Wordpress"
tar -xzf latest.tar.gz
rm -f latest.tar.gz
mv wordpress public_html
cd public_html
if [ $SHOULD_SETUP_DB = 'y' ]
then
# SETUP WP CONFIG
echo "Create wp_config"
mv wp-config-sample.php wp-config.php
sed -i bak -e "s/database_name_here/$DB_NAME/" wp-config.php
sed -i bak -e "s/username_here/$DB_USERNAME/" wp-config.php
sed -i bak -e "s/password_here/$DB_PASSWORD/" wp-config.php
rm -f wp-config.phpbak
fi
# REMOVE DEFAULT PLUGINS AND INSTALL WORDPRESS_PLUGIN_URL
cd wp-content/plugins
echo "Removing default plugins"
rm hello.php
rm -rf akismet
# REMOVE DEFAULT THEMES AND INSTALL WORDPRESS_THEME_URL
cd ../themes
echo "Removing default themes"
rm -R -- */
echo "All done..."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment