Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash -e
- clear
- # based on the script by Christopher Geary - http://www.ltconsulting.co.uk/automated-wordpress-installation-with-bash-wp-cli/
- # New site username
- wpuser='webmaster'
- echo "================================================================="
- echo " Symbiosis WordPress Installer!"
- echo " try not to break things! "
- echo "================================================================="
- echo ""
- # accept user input for the MySQL password
- echo "MySQL root user password: "
- read -e rootpw
- # accept user input for the databse name
- echo "Database User and Database Name: "
- read -e dbname
- # accept the name of our website
- echo "Site Name: "
- read -e sitename
- # accept a comma separated list of pages
- echo "Add Pages: "
- read -e allpages
- # 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
- # Create the Database for the website
- # generate random 12 character password
- dbpass=$(LC_CTYPE=C tr -dc A-Za-z0-9_\!\@\#\$\%\^\&\*\(\)-+= < /dev/urandom | head -c 12)
- MYSQL_HISTFILE=/dev/null mysql -u root -p$rootpw
- CREATE DATABASE $dbname;
- show databases;
- create user $dbname;
- grant all on $dbname.* to '$dbname'@'localhost' identified by '$dbpass';
- quit;
- # download the WordPress core files (locale codes can be found here - http://wpcentral.io/internationalization/)
- wp core download --locale=en_GB
- # create the wp-config file with our standard setup
- wp core config --dbname=$dbname --dbuser=$dbname --dbpass=$dbpass --extra-php <<PHP
- define( 'WP_DEBUG', true );
- define( 'DISALLOW_FILE_EDIT', true );
- PHP
- # parse the current directory name
- currentdirectory=$pwd | cut -d/ -f3
- # generate random 12 character password
- password=$(LC_CTYPE=C tr -dc A-Za-z0-9_\!\@\#\$\%\^\&\*\(\)-+= < /dev/urandom | head -c 12)
- # copy password to clipboard
- echo $password | pbcopy
- # 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="user@example.org"
- # discourage search engines
- wp option update blog_public 0
- # show only 6 posts on an archive page
- wp option update posts_per_page 6
- # delete sample page, and create homepage
- wp post delete $(wp post list --post_type=page --posts_per_page=1 --post_status=publish --pagename="sample-page" --field=ID --format=ids)
- wp post create --post_type=page --post_title=Home --post_status=publish --post_author=$(wp user get $wpuser --field=ID --format=ids)
- # set homepage as front page
- wp option update show_on_front 'page'
- # set homepage to be the new page
- wp option update page_on_front $(wp post list --post_type=page --post_status=publish --posts_per_page=1 --pagename=home --field=ID --format=ids)
- # create all of the pages
- export IFS=","
- for page in $allpages; do
- wp post create --post_type=page --post_status=publish --post_author=$(wp user get $wpuser --field=ID --format=ids) --post_title="$(echo $page | sed -e 's/^ *//' -e 's/ *$//')"
- done
- # set pretty urls
- wp rewrite structure '/%postname%/' --hard
- wp rewrite flush --hard
- # delete akismet and hello dolly
- wp plugin delete akismet
- wp plugin delete hello
- # install lt-tables plugin
- wp plugin install https://github.com/ltconsulting/lt-tables/archive/master.zip --activate
- # install some plugins
- wp plugin install 404-to-Start --activate
- wp plugin install Advanced-Automatic-Updates --activate
- wp plugin install Anti-spam --activate
- # install the company starter theme
- wp theme install ~/Documents/lt-theme.zip --activate
- clear
- # create a navigation bar
- wp menu create "Main Navigation"
- # add pages to navigation
- export IFS=" "
- for pageid in $(wp post list --order="ASC" --orderby="date" --post_type=page --post_status=publish --posts_per_page=-1 --field=ID --format=ids); do
- wp menu item add-post main-navigation $pageid
- done
- # assign navigaiton to primary location
- wp menu location assign main-navigation primary
- clear
- echo "================================================================="
- echo "Installation is complete. Your username/password is listed below."
- echo ""
- echo "Username: $wpuser"
- echo "Password: $password"
- echo ""
- echo "================================================================="
- # Open the new website with Google Chrome
- /usr/bin/open -a "/Applications/Google Chrome.app" "http://localhost/$currentdirectory/wp-login.php"
- # Open the project in TextMate
- /Applications/TextMate.app/Contents/Resources/mate /Applications/MAMP/htdocs/$currentdirectory/wp-content/themes/lt-theme
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement