** Work in progress **
#!/bin/bash
##############################
# DEFAULT WORDPRESS AND PLUGIN INSTALL SCRIPT
#
# 2013-04-03
# 1.0
# Add Plugins you want installed to "/Users/milotalonjennings/Dropbox/Sites/_default_wp_install/wp-content/plugins/"
# Opens wp-config.php in Sublime Text 2
# Opens .htaccess file in Sublime Text 2
# TODO: PUT A YES/NO PROMPT BEFORE RUNNING SCRIPT
#!!!!! EXITS UNLESS YOU MANUALLY COMMENT OUT THE LINE BELOW
#exit
################
# VARIABLES/ARGUMENTS
################
# information for install
domain_name="wptest.com"
db_name="wptest"
db_user="root"
db_pass="root"
site_dir="/Users/milotalonjennings/Dropbox/Sites"
# auto populated
www_root_dir="$domain_name"
################
# CLEANUP/FORMATTING
################
# make sure mysql user is 14 char or less
db_user=$(echo "$db_user" | cut -c -14)
################
# WORDPRESS
################
echo "** DOWNLOADING WORDPRESS **"
echo ""
# get latest wordpress source
mkdir $site_dir/stock_wordpress/
mkdir $site_dir/stock_wordpress/_latest/
cd $site_dir/stock_wordpress/_latest/
rm -rf wordpress
curl -L -o 'latest.tar.gz' http://wordpress.org/latest.tar.gz
tar -zxf latest.tar.gz wordpress
echo "** COPYING WORDPRESS FILES **"
echo ""
# copy latest source to target local www root folder
mkdir $site_dir/$www_root_dir
cp -R wordpress/* $site_dir/$www_root_dir
echo "** COPYING DEFAULT.COM PLUGINS **"
echo ""
# copy standard plugins from default installation
cp -R $site_dir/_default_wp_install/wp-content/plugins/* $site_dir/$www_root_dir/wp-content/plugins
echo "** CREATING WP-CONFIG.PHP FILE **"
echo ""
# review config file for default install
cd $site_dir/$www_root_dir
mv wp-config-sample.php wp-config.php
echo "** WP-CONFIG INFO TO USE **"
echo ""
echo "DB NAME: $db_name"
echo "DB USER: $db_user"
echo "DB PASS: $db_pass"
# Launch Sublime Text 2 to edit config file
subl wp-config.php
################
# MYSQL
################
# create sql commands for local database & user
qry_create_db="CREATE DATABASE \`$db_name\`;"
qry_grant_user="GRANT ALL ON \`$db_name\`.* TO '$db_user'@'localhost';"
qry_flush="FLUSH PRIVILEGES;"
# create sql statement
SQL="${qry_create_db}${qry_grant_user}${qry_flush}"
echo "** CREATING WORDPRESS DATABASE FROM ARGS **"
echo ""
echo $SQL
echo ""
# execute mysql commands
/Applications/MAMP/Library/bin/mysql -uroot -proot -e "$SQL"
################
# APACHE
################
# echo "** CONFIGURE APACHE **"
# echo ""
# # add to httpd_conf
# ~/Source/scripts/httpd_vhost.sh $domain_name >> /Applications/MAMP/conf/apache/httpd.conf
# echo "** RESTART APACHE **"
# echo ""
# # restart httpd service
# sudo /Applications/MAMP/bin/apache2/bin/apachectl restart
################
# LOCAL MACHINE
################
# echo "** CONFIGURE HOSTS FILE **"
# echo ""
# add domain mapping to local hosts file
#sudo echo "127.0.0.1 $domain_name #Added with amazing script" >> /etc/hosts
# subl /etc/hosts
echo "** CREATE SITE ENTRY IN MAMP PRO **"
echo "** SITE DOMAIN: $www_root_dir"
echo "** SITE DIRECTORY: $site_dir/$www_root_dir"
echo ""
echo "open /Applications/MAMP\ PRO/MAMP\ PRO.app/"