Skip to content

Instantly share code, notes, and snippets.

@bmadigan
Created January 4, 2016 18:28
Show Gist options
  • Save bmadigan/075a9efde6acc8602dc8 to your computer and use it in GitHub Desktop.
Save bmadigan/075a9efde6acc8602dc8 to your computer and use it in GitHub Desktop.
Shell Install WordPress
#!/bin/bash
function coloredEcho(){
local exp=$1;
local color=$2;
if ! [[ $color =~ '^[0-9]$' ]] ; then
case $(echo $color | tr '[:upper:]' '[:lower:]') in
black) color=0 ;;
red) color=1 ;;
green) color=2 ;;
yellow) color=3 ;;
blue) color=4 ;;
magenta) color=5 ;;
cyan) color=6 ;;
white|*) color=7 ;; # white or invalid color
esac
fi
tput setaf $color;
echo $exp;
tput sgr0;
}
###############################################################################
# WP Install Script Script v0.2.0
# By Brad Madigan ([email protected])
###############################################################################
mkdir -p tmp
echo "============================================"
echo "Cavera.ca WordPress Install Script"
echo "============================================"
echo ''
coloredEcho "Would you like to install the lastest version of WordPress in this directory?"
read -p "[y/N]" -n 1 -r
if [[ ! $REPLY =~ ^[Yy]$ ]]
then
exit 1
fi
echo ''
echo ''
coloredEcho 'Downloading and installing the latest version of WordPress...' green
echo ''
curl -L http://wordpress.org/latest.zip? -o tmp/WP.zip
unzip tmp/WP.zip
rm -rf tmp
# Copy file from wordpress folder into parent folder and remove
cd wordPress
cp -rf . ..
cd ..
rm -R wordpress
# Copy the wp-config
cp wp-config-sample.php wp-config.php
echo ''
coloredEcho "WordPress wp-config has been created!" magenta
#set WP salts
perl -i -pe'
BEGIN {
@chars = ("a" .. "z", "A" .. "Z", 0 .. 9);
push @chars, split //, "!@#$%^&*()-_ []{}<>~\`+=,.;:/?|";
sub salt { join "", map $chars[ rand @chars ], 1 .. 64 }
}
s/put your unique phrase here/salt()/ge
' wp-config.php
echo ''
coloredEcho "WordPress Salts have been created!" magenta
#create uploads folder and set permissions
mkdir wp-content/uploads
chmod 775 wp-content/uploads
echo ''
coloredEcho "Created an wp-content/uploads folder with proper permissions" magenta
###############################################################################
# Install Sage?
###############################################################################
coloredEcho "Would you like to install the Sage Starter Theme? (y/n)" white
read -e setupSage
if [ "$setupSage" == y ] ; then
echo ''
coloredEcho 'Downloading and installing Sage Theme...' green
echo ''
mkdir -p tmp
curl -L https://github.com/roots/sage/archive/master.zip? -o tmp/sage.zip
unzip tmp/sage.zip
rm -rf tmp
# move folder to themes
mv sage-master wp-content/themes/sage
echo ''
coloredEcho "Copied sage to wp-content/themes folder" magenta
fi
###############################################################################
# Script is done and give some instructions!
###############################################################################
echo ''
coloredEcho 'Next steps:' white
coloredEcho '=================================' yellow
coloredEcho ' - Setup Homestead Account' yellow
coloredEcho '$> Edit ~/.homestead/Homestead.yml' yellow
coloredEcho '=================================' yellow
coloredEcho 'Happy Coding!' white
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment