Bash - New Vagrant Box with Latest WordPress

#!/bin/bash # Create a new Vagrant Box from # https://github.com/ideasonpurpose/basic-wordpress-vagrant # # Make sure you follow the reqs on GitHub before running `vagrant up`. # # ./new_vagrant.sh $NAME ################################################################# # https://codepad.co/snippet/x9TwyHwH - @jgraup - Jesse Graupmann ################################################################# # Welcome! echo echo "Welcome!" echo "Let's make a new Vagrant Box. We just need a name to get started." echo if [ -z "$1" ]; then echo -e "What is the name of the Vagrant Box you would like to create?\n" read wname; # ask for user input else wname=$1 # use the argument passed fi # Remove spaces from name dirname=${wname//[[:blank:]]/}.dev # Check with user echo -e "Do you want to create http://$dirname at $PWD/$dirname?\n"; echo PS3='Please enter your choice: ' options=("Yes" "No" "Quit") select opt in "${options[@]}" do case $opt in "Yes") # let's keep going break ;; "No") echo "Restarting Menu..." exec $0 #restart exit 1 break ;; "Quit") echo "Exiting..." exit 1 break ;; *) echo invalid option;; esac done echo echo -e "\nNow let's make that project!" mkdir -p $PWD/$dirname # Vagrant Environment remote_master="https://github.com/ideasonpurpose/basic-wordpress-vagrant/archive/v0.0.10.zip" vagrant_master_zip=$PWD/basic-wordpress-vagrant.zip # Download Latest Environment - overwrite file for latest # curl -L -o $vagrant_master_zip $remote_master wget -v -O $vagrant_master_zip $remote_master tar -zxvf $vagrant_master_zip -C $PWD/$dirname --strip-components=1 # Latest WordPress # curl -L -o "./wordpress.latest.tar.gz" "https://wordpress.org/latest.tar.gz" wget -v -O "./wordpress.latest.tar.gz" "https://wordpress.org/latest.tar.gz" tar -zxvf "./wordpress.latest.tar.gz" -C $PWD/$dirname/site --strip-components=1 final=$PWD/$dirname; echo "Done!"; echo echo "Start Vagrant with 'vagrant up' in 'cd $final'" echo echo "Open the browswer with 'open http://$dirname'" echo read -p "You want to vagrant up now? y/n " -n 1 -r; echo # newline; if [[ $REPLY =~ ^[Yy]$ ]] then cd $final; vagrant up; # Enjoy! else exit 1 fi
https://github.com/ideasonpurpose/basic-wordpress-vagrant - Up and running with a fresh WordPress install in about ~a minute~ and includes WP-CLI.

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.