From 71a5b23fb67207d90965ec4ae9ec3c438578af2a Mon Sep 17 00:00:00 2001 From: Nick Makris <> Date: Tue, 5 Feb 2019 12:18:49 -0600 Subject: [PATCH 01/16] Added break after config create --- new_wp.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/new_wp.sh b/new_wp.sh index d722f7c..f1706d0 100755 --- a/new_wp.sh +++ b/new_wp.sh @@ -59,6 +59,7 @@ define( 'WP_DEBUG', true); define( 'WP_DEBUG_LOG', true ); define( 'WP_DEBUG_DISPLAY', false ); PHP + wp db create if [ $? -eq 0 ] From 80a565260f609280b3994b27f9d1ebb5094a4893 Mon Sep 17 00:00:00 2001 From: Nick Makris <> Date: Tue, 5 Feb 2019 14:52:48 -0600 Subject: [PATCH 02/16] Moved scripts into respected folders so they each can have their own readme. --- clique/README.md | 67 +++++++++++++++++++++++++++++ clique_wp.sh => clique/clique_wp.sh | 36 +++++++++++++--- new_wp.sh => new_wp/new_wp.sh | 29 ++++++++----- 3 files changed, 115 insertions(+), 17 deletions(-) create mode 100644 clique/README.md rename clique_wp.sh => clique/clique_wp.sh (89%) rename new_wp.sh => new_wp/new_wp.sh (81%) diff --git a/clique/README.md b/clique/README.md new file mode 100644 index 0000000..51be2cf --- /dev/null +++ b/clique/README.md @@ -0,0 +1,67 @@ +# Clique Studios Local Backend WP Install + +## Prerequisites: +___ +* Install `valet` or `valet-plus` +* If running `valet`, install `wp-cli` +* `mkdir` a folder in your `/Sites/` folder, or whever you have `valet park` set with a sub-dir for the **`wp-boilerplate` [repository][1]** +* Check the following lines + * Line 15: For the correct /path/to/Sites_folder + * Line 18: That `wp-boilerplate` is the correct folder name where the WP-Boilerplate repository lives + * Line 19: The .TLD is the correct setup for your env. To check, run `valet domain` and see what it states. + * You can run `.app` as your domain, but you WILL need to create an SSL certificate for each folder you have parked, which this script does automatically. + +## Description +___ +The following below describes what this shell script does. + +* Asks for a few prompts for you to fill in : your password (for `valet`), the sitename, blog description *(optional)*, database name, database password, +* Fetches the latest wp-boilerplate from the repo, assuming you have a dedicated folder for the repository +* Copies the zip file from the wp-boilerplate repo, unpacks it and updates the wordpress core to the latest version +* Copies the `.sql` file from `dup-installer` and renames it. +* Deletes the `wp-config.php` file in the unpackaged folder +* Creates a new `wp-config.php` and creates a new `db` with a conditional if the db already exists, to allow one more change to try again. I could extend it to the typical Legend of Zelda 3 tries to defeat the boss, but shouldn’t need to, haha. +* Imports the `.sql` file to the database +* Next asks if you wanna create some top level pages (optional) +* Asks if you want to disable comments, which if yes, will disable pings and trackbacks +* Deletes the default wordpress “Hello World” post, the default Comment, and renames “Sample Page” to “Home” with the slug “home” +* Runs through a loop to create the pages listed above (if you entered any, otherwise it skips this) +* Since this is an import of a duplicator theme, it updates the `option` for the following `home`, siteurl`, `blogname`, and if you entered a description `blogdescription` +* Sets the `show_front_page` to `page` +* Sets the `page_on_front` to `Home` by ID 2 +* Runs a database search/replace to replace `http://wp-boilerplate.test:8080` with `https://you_folder_name.tls` + * Example: `https://wordpress_core.app` +* Flushes the rewrite permalinks +* Updates all the plugins +* Installs and activates classic-editor +* Activates WP-Accessibility +* Asks if you’re like to activate additional plugins: + * Gravity Forms + * Also installs @cho’s Gravity Forms WCAG 20 Form Fields + * Activate Sitemap (Which I want to make obsolete and replace with a shortcode I created on the PFI onboarding project, which offers more parameters, including a Classic Editor pop-up to choose your post type, include children pages and up to what depth, or if we move on to Gutenberg, a new block that will do the same thing. I wasn’t impressed by that plugin, and I wanted to give us more control over the markup and addition of classes, if not just a template we can override. May make into a plugin, may just be something I want to merge into the sage9 theme). + * Activate Yoast SEO, which will also download and install ACF Content Analysis for Yoast SEO +* Cleans up the `.zip file`, copied `.sql` file, `CLIQUE-CHANGELOG.txt` and `admin-creds-PLEASE-DELETE.txt`. The latter due to terminal informing you of the user name and password. +* Next valet will run `valet secure $dirName` where `$dirName` is grabbed by the initial shell execution via the set vairable `dirName=${PWD##*/}` + * I find it best to run local sites via SSL to mimic the live site to it’s truest form +* The final thing on screen will showcase the domain you can command click on to access the front-end, a link to access the back end, the login creds based on the repo, and a link to Duplicators cleanup files. + +Unfortunately since the repo file is `zip` and not `tar.gz` it take a little longer. + +This is my first complex automate as much as possible script, and when starting `SAWS` I was able to get everything setup in under 2 minutes. + +If you wanna try it, I suggest creating a `.custom_bash_scripts`dir on `$HOME` and adding that folder to your path. Then running `chmod 755 clique_wp.sh` followed by `source ~/.bash_profile` or `source ~/.bashrc` where ever you’re storing your `PATH` declarations. + +### [Download the Bash Script][2] + + +This will be my baby and maintenance will be on going, so PLEASE any issues you encounter OR any improvements you feel I would make, create tickets here: https://github.com/kupoback/shell_scripts/issues + +## @TODO List +___ + +* **@TODO**: Allow the addition of sub pages, but will need to rethink the logic on this + + + +[1]:https://bitbucket.org/clique_studios/wp-boilerplate/src/master/ +[2]:https://github.com/kupoback/shell_scripts/blob/master/clique_wp.sh \ No newline at end of file diff --git a/clique_wp.sh b/clique/clique_wp.sh similarity index 89% rename from clique_wp.sh rename to clique/clique_wp.sh index 1e77ec2..ebce13d 100755 --- a/clique_wp.sh +++ b/clique/clique_wp.sh @@ -16,6 +16,7 @@ folderPath=$HOME/Sites/ dirName=${PWD##*/} installPath=$folderPath/$dirName/ wpBoilerplate=$folderPath/wp-boilerplate/ +themeFolder=$folderPath/$dirName/wp-content/themes/ url="https://$dirName.app" # Inform the user that this is assuming they're using Valet-plus @@ -37,7 +38,11 @@ read siteName echo "" echo -e "Enter a blog description (optional)." -read $blogDescription +read blogDescription +echo "" + +echo -e "Enter the theme folder name, ommiting -theme" +read themeName echo "" # Set the database name @@ -105,9 +110,11 @@ fi # With the database created, we'll need to now import our .sql file echo -e "${VP_GREEN}Database created!${VP_WHITE}" echo "" -echo -e "${WP_YELLOW}Now updating URL's and importing the .sql file${VP_NONE}" +echo -e "${VP_CYAN}Now updating URL's and importing the .sql file${VP_NONE}" +echo "" wp db import import.sql +echo "" # Check to see if there were any errors importing the database # If so, we'll quit the script @@ -119,6 +126,11 @@ then exit 0 fi +# Change the theme folder name +echo -e "Now changing the theme folder name from ${VP_CYAN}${VP_BOLD}sage9-project-name-theme${VP_NONE}${VP_WHITE} to ${VP_CYAN}${VP_BOLD}$themeName-theme${VP_NONE}${VP_WHITE}" +echo "" +mv $themeFolder/sage9-project-name-theme $themeFolder/$themeName-theme + echo -e "You can choose to create top level pages you know you'll need here, otherwise just hit enter to skip this." echo -e "Please separate page names with a comma (,) and no space. The ${VP_CYAN}Homepage${VP_WHITE} is already created." echo -e "" @@ -126,8 +138,7 @@ echo -e "${VP_CYAN}Example:${VP_WHITE} About Us,Contact Us,Blog" read pageList # Do we want to disable comments? -echo -e "${VP_YELLOW}Disable comments? [y/n]${VP_NONE}${VP_WHITE}" -read disableComments +echo -e "${VP_YELLOW}Disable comments? [y/n]${VP_NONE}${VP_WHITE}"; read disableComments # Lets remove the default "Hellow World" post wp post delete 1 --force @@ -175,6 +186,9 @@ fi wp option update show_on_front 'page' wp option update page_on_front 2 +# Set the Timezone to Chicago +wp option update timezone_string "America/Chicago" + # Replace the old http://wp-boilerplate.test:8080 with the sitename echo -e "${VP_YELLOW}Replacing ${VP_UNDERLINE}${VP_WHITE}http://wp-boilerplate.test:8080${VP_NONE} ${VP_YELLOW}with ${VP_UNDERLINE}${VP_WHITE}$url${VP_NONE}" wp search-replace 'http://wp-boilerplate.test:8080' $url --all-tables --quiet @@ -188,11 +202,17 @@ wp db optimize --quiet echo -e "Updating plugins." wp plugin update --all -wp plugin install classic-editor --activate -wp plugin activate wp-accessibility +echo -e "${VP_YELLOW}Install Classic Editor? [y/n]${VP_NONE}${VP_WHITE}" +read classicEditor +if [ "$classicEditor" = 'y' ] +then + wp plugin install classic-editor --activate +fi echo -e "Activate additional default plugins? [y/n]" -if [ "$disableComments" = 'y' ] +read additionalPlugins + +if [ "$additionalPlugins" = 'y' ] then echo -e "${VP_YELLOW}Activate Gravity Forms? [y/n]" read gravityForms @@ -222,6 +242,8 @@ then fi +wp plugin activate wp-accessibility + # Clean up some root installation files echo -e "${VP_RED}Deleting ${VP_BOLD}import.sql${VP_NONE} and the ${VP_BOLD}duplicator.zip${VP_NONE} files.${VP_WHITE}" rm -rf ./*.zip diff --git a/new_wp.sh b/new_wp/new_wp.sh similarity index 81% rename from new_wp.sh rename to new_wp/new_wp.sh index f1706d0..f0fd0ef 100755 --- a/new_wp.sh +++ b/new_wp/new_wp.sh @@ -25,8 +25,8 @@ fi echo -e "${VP_CYAN}This bash script is under the assumption that you are using valet-plus to set up this WordPress install.${VP_NONE}" echo -e "${VP_CYAN}${VP_BOLD}This script will now clear your terminal window.${VP_NONE}" echo "" -echo -e "${VP_WHITE}${VP_BOLD}Please press enter to continue." -read clearTerminal +echo -e "${VP_WHITE}${VP_BOLD}Please press enter to continue."; read clearTerminal + clear # We will now try to cache the sudo password, as we'll be setting up an SSL for their dev environment @@ -34,19 +34,28 @@ echo -e "${VP_RED}${VP_BOLD}You may be asked twice for your password, but this i sudo -v # Set the Site Name -echo -e "Enter the site name." -read siteName +echo -e "Enter the site name."; read siteName echo "" # Set the database name echo -e "Enter your chosen database name." -echo -e "${VP_WHITE}Note, wp_ is automatically prefixed" -read dbName +echo -e "${VP_WHITE}Note, wp_ is automatically prefixed"; read dbName +echo "" + +echo -e "Enter your database user name if it differs from root, otherwise hit enter."; read dbUser echo "" +echo -e "Enter your database password if it differs from root, otherwise hit enter."; read dbPassword +echo "" + +# If a $dbUser was not entered, we'll default to valet-plus' mysql username +[ -z "$dbUser" ] && $dbUser = 'root' + +# If a $dbUser was not entered, we'll default to valet-plus' mysql password +[ -z "$dbPassword" ] && $dbPassword = 'root' + # Let's double check the WordPress version they want to download -echo -e "${VP_PURPLE}If you'd like to download a different version number, please enter in the number, otherwise, just press enter.${VP_WHITE}" -read wpVersion +echo -e "${VP_PURPLE}If you'd like to download a different version number, please enter in the number, otherwise, just press enter.${VP_WHITE}"; read wpVersion echo "" # Start downloading WordPress and it's latest version @@ -54,7 +63,7 @@ echo "" ## Create the wp-config file and the database echo -e "${VP_PURPLE}Creating database and setting up wp-config.php file.${VP_WHITE}" -wp config create --dbname=wp_$dbName --dbuser=root --dbpass=root --extra-php < Date: Tue, 5 Feb 2019 14:54:44 -0600 Subject: [PATCH 03/16] Fixed issue with README.md --- clique/README.md | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/clique/README.md b/clique/README.md index 51be2cf..0dc8980 100644 --- a/clique/README.md +++ b/clique/README.md @@ -1,7 +1,6 @@ # Clique Studios Local Backend WP Install ## Prerequisites: -___ * Install `valet` or `valet-plus` * If running `valet`, install `wp-cli` * `mkdir` a folder in your `/Sites/` folder, or whever you have `valet park` set with a sub-dir for the **`wp-boilerplate` [repository][1]** @@ -12,7 +11,6 @@ ___ * You can run `.app` as your domain, but you WILL need to create an SSL certificate for each folder you have parked, which this script does automatically. ## Description -___ The following below describes what this shell script does. * Asks for a few prompts for you to fill in : your password (for `valet`), the sitename, blog description *(optional)*, database name, database password, @@ -53,15 +51,13 @@ If you wanna try it, I suggest creating a `.custom_bash_scripts`dir on `$HOME` a ### [Download the Bash Script][2] - This will be my baby and maintenance will be on going, so PLEASE any issues you encounter OR any improvements you feel I would make, create tickets here: https://github.com/kupoback/shell_scripts/issues ## @TODO List -___ * **@TODO**: Allow the addition of sub pages, but will need to rethink the logic on this [1]:https://bitbucket.org/clique_studios/wp-boilerplate/src/master/ -[2]:https://github.com/kupoback/shell_scripts/blob/master/clique_wp.sh \ No newline at end of file +[2]:https://github.com/kupoback/shell_scripts/blob/master/clique/clique_wp.sh \ No newline at end of file From 8bcc2d80568877387bc3d030372879a5e02b6138 Mon Sep 17 00:00:00 2001 From: Nick Makris <> Date: Tue, 5 Feb 2019 14:59:39 -0600 Subject: [PATCH 04/16] Another tweak to readme.md --- clique/README.md | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/clique/README.md b/clique/README.md index 0dc8980..d012aff 100644 --- a/clique/README.md +++ b/clique/README.md @@ -43,15 +43,20 @@ The following below describes what this shell script does. * I find it best to run local sites via SSL to mimic the live site to it’s truest form * The final thing on screen will showcase the domain you can command click on to access the front-end, a link to access the back end, the login creds based on the repo, and a link to Duplicators cleanup files. +## Postfase Unfortunately since the repo file is `zip` and not `tar.gz` it take a little longer. This is my first complex automate as much as possible script, and when starting `SAWS` I was able to get everything setup in under 2 minutes. -If you wanna try it, I suggest creating a `.custom_bash_scripts`dir on `$HOME` and adding that folder to your path. Then running `chmod 755 clique_wp.sh` followed by `source ~/.bash_profile` or `source ~/.bashrc` where ever you’re storing your `PATH` declarations. - ### [Download the Bash Script][2] -This will be my baby and maintenance will be on going, so PLEASE any issues you encounter OR any improvements you feel I would make, create tickets here: https://github.com/kupoback/shell_scripts/issues +If you wanna try it, I suggest creating a `.custom_bash_scripts` dir on `$HOME` or `$USER$` and adding that folder to your path. + +* Example: `export PATH="$PATH:$HOME/.custom_bash_scripts:$PATH"` + +Running the command in terminal `chmod 755 clique_wp.sh` followed by `source ~/.bash_profile` or `source ~/.bashrc` where ever you’re storing your `PATH` declarations, will allow you to then call to the shell script in terminal wherever. + +This will be my baby and maintenance will be on going, so PLEASE any issues you encounter OR any improvements you feel I would make, create tickets [here][3]. ## @TODO List @@ -60,4 +65,5 @@ This will be my baby and maintenance will be on going, so PLEASE any issues you [1]:https://bitbucket.org/clique_studios/wp-boilerplate/src/master/ -[2]:https://github.com/kupoback/shell_scripts/blob/master/clique/clique_wp.sh \ No newline at end of file +[2]:https://github.com/kupoback/shell_scripts/blob/master/clique/clique_wp.sh +[3]:https://github.com/kupoback/shell_scripts/issues \ No newline at end of file From b7e13e790fbde57e7559392c6a87db510b970cf4 Mon Sep 17 00:00:00 2001 From: kupoback Date: Tue, 5 Feb 2019 15:03:41 -0600 Subject: [PATCH 05/16] Update README.md --- clique/README.md | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/clique/README.md b/clique/README.md index 51be2cf..57cad18 100644 --- a/clique/README.md +++ b/clique/README.md @@ -1,7 +1,6 @@ # Clique Studios Local Backend WP Install ## Prerequisites: -___ * Install `valet` or `valet-plus` * If running `valet`, install `wp-cli` * `mkdir` a folder in your `/Sites/` folder, or whever you have `valet park` set with a sub-dir for the **`wp-boilerplate` [repository][1]** @@ -12,7 +11,6 @@ ___ * You can run `.app` as your domain, but you WILL need to create an SSL certificate for each folder you have parked, which this script does automatically. ## Description -___ The following below describes what this shell script does. * Asks for a few prompts for you to fill in : your password (for `valet`), the sitename, blog description *(optional)*, database name, database password, @@ -45,23 +43,27 @@ The following below describes what this shell script does. * I find it best to run local sites via SSL to mimic the live site to it’s truest form * The final thing on screen will showcase the domain you can command click on to access the front-end, a link to access the back end, the login creds based on the repo, and a link to Duplicators cleanup files. +## Postfase Unfortunately since the repo file is `zip` and not `tar.gz` it take a little longer. This is my first complex automate as much as possible script, and when starting `SAWS` I was able to get everything setup in under 2 minutes. -If you wanna try it, I suggest creating a `.custom_bash_scripts`dir on `$HOME` and adding that folder to your path. Then running `chmod 755 clique_wp.sh` followed by `source ~/.bash_profile` or `source ~/.bashrc` where ever you’re storing your `PATH` declarations. - ### [Download the Bash Script][2] +If you wanna try it, I suggest creating a `.custom_bash_scripts` dir on `$HOME` or `$USER$` and adding that folder to your path. + +* Example: `export PATH="$PATH:$HOME/.custom_bash_scripts:$PATH"` + +Running the command in terminal `chmod 755 clique_wp.sh` followed by `source ~/.bash_profile` or `source ~/.bashrc` where ever you’re storing your `PATH` declarations, will allow you to then call to the shell script in terminal wherever. -This will be my baby and maintenance will be on going, so PLEASE any issues you encounter OR any improvements you feel I would make, create tickets here: https://github.com/kupoback/shell_scripts/issues +This will be my baby and maintenance will be on going, so PLEASE any issues you encounter OR any improvements you feel I would make, create tickets [here][3]. ## @TODO List -___ * **@TODO**: Allow the addition of sub pages, but will need to rethink the logic on this [1]:https://bitbucket.org/clique_studios/wp-boilerplate/src/master/ -[2]:https://github.com/kupoback/shell_scripts/blob/master/clique_wp.sh \ No newline at end of file +[2]:https://github.com/kupoback/shell_scripts/blob/master/clique/clique_wp.sh +[3]:https://github.com/kupoback/shell_scripts/issues From 1e0390d8491e81e569ca18f1e15d45800acc5a51 Mon Sep 17 00:00:00 2001 From: Nick Makris <> Date: Tue, 5 Feb 2019 16:42:09 -0600 Subject: [PATCH 06/16] Cleaned up more file issues. --- clique/clique_wp.sh | 180 ++++++++++++++++++++++++++++---------------- new_wp/new_wp.sh | 18 +++-- 2 files changed, 127 insertions(+), 71 deletions(-) diff --git a/clique/clique_wp.sh b/clique/clique_wp.sh index ebce13d..1f5e422 100755 --- a/clique/clique_wp.sh +++ b/clique/clique_wp.sh @@ -1,58 +1,69 @@ #!/bin/bash # Styles -VP_NONE='\033[00m' -VP_RED='\033[01;31m' -VP_GREEN='\033[01;32m' -VP_YELLOW='\033[01;33m' -VP_PURPLE='\033[01;35m' -VP_CYAN='\033[01;36m' -VP_WHITE='\033[01;37m' -VP_BOLD='\033[1m' -VP_UNDERLINE='\033[4m' +VP_NONE=$'\033[00m' +VP_RED=$'\033[01;31m' +VP_GREEN=$'\033[01;32m' +VP_YELLOW=$'\033[01;33m' +VP_PURPLE=$'\033[01;35m' +VP_CYAN=$'\033[01;36m' +VP_WHITE=$'\033[01;37m' +VP_BOLD=$'\033[1m' +VP_UNDERLINE=$'\033[4m' # Setup some folder paths to variables folderPath=$HOME/Sites/ dirName=${PWD##*/} installPath=$folderPath/$dirName/ wpBoilerplate=$folderPath/wp-boilerplate/ -themeFolder=$folderPath/$dirName/wp-content/themes/ +themeFolder=$folderPath/$dirName/wp-content/themes url="https://$dirName.app" # Inform the user that this is assuming they're using Valet-plus echo -e "${VP_CYAN}This bash script is under the assumption that you are using valet-plus to set up this WordPress install.${VP_NONE}" -echo -e "${VP_CYAN}${VP_BOLD}This script will now clear your terminal window.${VP_NONE}" -echo "" -echo -e "${VP_WHITE}${VP_BOLD}Please press enter to continue." -read clearTerminal +echo -e "${VP_CYAN}${VP_BOLD}This script will now clear your terminal window." +echo "${VP_WHITE}${VP_NONE}" +read -p "${VP_WHITE}${VP_BOLD}Please press enter to continue.${VP_WHITE}${VP_NONE}" clearTerminal clear && printf '\e[3J' # We will now try to cache the sudo password, as we'll be setting up an SSL for their dev environment -echo -e "${VP_RED}${VP_BOLD}You may be asked twice for your password, but this is to setup an SSL locally to best mimic a live environment.${VP_NONE}" +echo -e "${VP_RED}${VP_BOLD}You may be asked twice for your password, but this is to setup an SSL locally to best mimic a live environment.${VP_WHITE}${VP_NONE}" sudo -v +echo "${VP_WHITE}${VP_NONE}" # Set the Site Name -echo -e "Enter the site name." -read siteName +read -p "${VP_WHITE}Enter the site name. ${VP_WHITE}${VP_NONE}" siteName echo "" -echo -e "Enter a blog description (optional)." -read blogDescription +read -p "${VP_WHITE}Enter a blog description (optional). ${VP_NONE}" blogDescription echo "" -echo -e "Enter the theme folder name, ommiting -theme" -read themeName +read -p "${VP_WHITE}Enter the theme folder name, ommiting -theme. ${VP_NONE}" themeName echo "" # Set the database name -echo -e "Enter your chosen database name." -echo -e "${VP_CYAN}Note:${VP_WHITE} wp_ is automatically prefixed" -read dbName +echo -e "${VP_WHITE}Enter your chosen database name.${VP_NONE}" +read -p "${VP_RED}Note${VP_WHITE}:${VP_NONE} wp_ is automatically prefixed. ${VP_WHITE}${VP_NONE}" dbName +echo "" + +# Get the database username +read -p "Enter your database user name if it differs from ${VP_YELLOW}root${VP_WHITE}${VP_NONE}, otherwise hit enter. ${VP_WHITE}${VP_NONE}" dbUser +echo "" + +# Get the database password +read -p "Enter your database password if it differs from ${VP_YELLOW}root${VP_WHITE}${VP_NONE}, otherwise hit enter. ${VP_WHITE}${VP_NONE}" dbPassword echo "" +# If a $dbUser was not entered, we'll default to valet-plus' mysql username +[ -z "$dbUser" ] && dbUser=root + +# If a $dbUser was not entered, we'll default to valet-plus' mysql password +[ -z "$dbPassword" ] && dbPassword=root + # Fetch the latest files from the wp-boilerplate repo and then pull it cd $wpBoilerplate +echo -e "Fetching and pulling the latest version of ${VP_CYAN}wp-boilerplate${VP_WHITE}${VP_NONE}" git fetch --force git pull --force @@ -61,8 +72,6 @@ cp -a ./*.zip $installPath cd $installPath unzip -q ./*.zip -wp core update - # Copy the .sql file, and rename it cp ./dup-installer/*.sql ./import.sql @@ -70,8 +79,9 @@ cp ./dup-installer/*.sql ./import.sql echo -e "${VP_RED}Deleting wp-config file and creating a new one.${VP_NONE}${VP_WHITE}" rm -rf wp-config.php -echo -e "Creating database and setting up wp-config.php file." -wp config create --dbname=wp_$dbName --dbuser=root --dbpass=root --extra-php < Date: Tue, 5 Feb 2019 16:44:07 -0600 Subject: [PATCH 07/16] Update README.md --- clique/README.md | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/clique/README.md b/clique/README.md index ef167ef..4dc507b 100644 --- a/clique/README.md +++ b/clique/README.md @@ -10,8 +10,6 @@ * Line 19: The .TLD is the correct setup for your env. To check, run `valet domain` and see what it states. * You can run `.app` as your domain, but you WILL need to create an SSL certificate for each folder you have parked, which this script does automatically. -*** - ## Description The following below describes what this shell script does. @@ -60,7 +58,6 @@ Running the command in terminal `chmod 755 clique_wp.sh` followed by `source ~/. This will be my baby and maintenance will be on going, so PLEASE any issues you encounter OR any improvements you feel I would make, create tickets [here][3]. -*** ## @TODO List @@ -70,4 +67,4 @@ This will be my baby and maintenance will be on going, so PLEASE any issues you [`wp-boilerplate` repository]:https://bitbucket.org/clique_studios/wp-boilerplate/src/master/ [Download the Bash Script]:https://github.com/kupoback/shell_scripts/blob/master/clique/clique_wp.sh -[3]:https://github.com/kupoback/shell_scripts/issues \ No newline at end of file +[3]:https://github.com/kupoback/shell_scripts/issues From 929a70870687871aa9d2cfb197e1182d218bf147 Mon Sep 17 00:00:00 2001 From: Nick Makris <> Date: Tue, 5 Feb 2019 16:45:08 -0600 Subject: [PATCH 08/16] typo --- clique/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clique/README.md b/clique/README.md index 4dc507b..1d2865b 100644 --- a/clique/README.md +++ b/clique/README.md @@ -43,7 +43,7 @@ The following below describes what this shell script does. * I find it best to run local sites via SSL to mimic the live site to it’s truest form * The final thing on screen will showcase the domain you can command click on to access the front-end, a link to access the back end, the login creds based on the repo, and a link to Duplicators cleanup files. -## Postfase +## Postface Unfortunately since the repo file is `zip` and not `tar.gz` it take a little longer. This is my first complex automate as much as possible script, and when starting `SAWS` I was able to get everything setup in under 2 minutes. From 7d604c45728e6686072563680577019603f84239 Mon Sep 17 00:00:00 2001 From: Nick Makris Date: Thu, 14 Feb 2019 13:47:48 -0600 Subject: [PATCH 09/16] Working off of "AirOnSkin"'s suggestions, updated spots. --- clique/clique_wp.sh | 241 ++++++++++++++++++++++++-------------------- 1 file changed, 129 insertions(+), 112 deletions(-) diff --git a/clique/clique_wp.sh b/clique/clique_wp.sh index 1f5e422..07edd51 100755 --- a/clique/clique_wp.sh +++ b/clique/clique_wp.sh @@ -5,70 +5,71 @@ VP_NONE=$'\033[00m' VP_RED=$'\033[01;31m' VP_GREEN=$'\033[01;32m' VP_YELLOW=$'\033[01;33m' -VP_PURPLE=$'\033[01;35m' +# VP_PURPLE=$'\033[01;35m' VP_CYAN=$'\033[01;36m' VP_WHITE=$'\033[01;37m' VP_BOLD=$'\033[1m' VP_UNDERLINE=$'\033[4m' # Setup some folder paths to variables -folderPath=$HOME/Sites/ -dirName=${PWD##*/} -installPath=$folderPath/$dirName/ -wpBoilerplate=$folderPath/wp-boilerplate/ -themeFolder=$folderPath/$dirName/wp-content/themes -url="https://$dirName.app" +folderPath="{$HOME}/Sites" +dirName="${PWD##*/}" +installPath="${folderPath}/${dirName}" +wpBoilerplate="${folderPath}/wp-boilerplate" +themeFolder="${folderPath}/${dirName}/wp-content/themes" +url="https://${dirName}.app" # Inform the user that this is assuming they're using Valet-plus -echo -e "${VP_CYAN}This bash script is under the assumption that you are using valet-plus to set up this WordPress install.${VP_NONE}" -echo -e "${VP_CYAN}${VP_BOLD}This script will now clear your terminal window." -echo "${VP_WHITE}${VP_NONE}" -read -p "${VP_WHITE}${VP_BOLD}Please press enter to continue.${VP_WHITE}${VP_NONE}" clearTerminal +echo -e "${VP_CYAN}This bash script is under the assumption that you are using valet-plus to set up this WordPress install.${VP_NONE} +${VP_CYAN}${VP_BOLD}This script will now clear your terminal window. +${VP_WHITE}${VP_NONE} + +${VP_WHITE}${VP_BOLD}Please press enter to continue.${VP_WHITE}${VP_NONE}" +read -r clear && printf '\e[3J' # We will now try to cache the sudo password, as we'll be setting up an SSL for their dev environment echo -e "${VP_RED}${VP_BOLD}You may be asked twice for your password, but this is to setup an SSL locally to best mimic a live environment.${VP_WHITE}${VP_NONE}" sudo -v -echo "${VP_WHITE}${VP_NONE}" -# Set the Site Name -read -p "${VP_WHITE}Enter the site name. ${VP_WHITE}${VP_NONE}" siteName -echo "" +# Grab the Site Name +echo -e "${VP_WHITE}Enter the site name.${VP_WHITE}${VP_NONE}" +read -r siteName -read -p "${VP_WHITE}Enter a blog description (optional). ${VP_NONE}" blogDescription -echo "" +# Grab the Blog Description +echo -e "\\n${VP_WHITE}Enter a blog description (optional).${VP_NONE}" +read -r blogDescription -read -p "${VP_WHITE}Enter the theme folder name, ommiting -theme. ${VP_NONE}" themeName -echo "" +# Grab the theme folder name +echo -e "\\n${VP_WHITE}Enter the theme folder name, ommiting -theme.${VP_NONE}" +read -r themeName -# Set the database name -echo -e "${VP_WHITE}Enter your chosen database name.${VP_NONE}" -read -p "${VP_RED}Note${VP_WHITE}:${VP_NONE} wp_ is automatically prefixed. ${VP_WHITE}${VP_NONE}" dbName -echo "" +# Grab the database name +echo -e "\\n${VP_WHITE}Enter your chosen database name.${VP_NONE} +${VP_RED}Note${VP_WHITE}:${VP_NONE} wp_ is automatically prefixed.${VP_WHITE}${VP_NONE}" read -r dbName -# Get the database username -read -p "Enter your database user name if it differs from ${VP_YELLOW}root${VP_WHITE}${VP_NONE}, otherwise hit enter. ${VP_WHITE}${VP_NONE}" dbUser -echo "" +# Grab the database username +echo -e "\\nEnter your database user name if it differs from ${VP_YELLOW}root${VP_WHITE}${VP_NONE}, otherwise hit enter.${VP_WHITE}${VP_NONE}" +read -r dbUser -# Get the database password -read -p "Enter your database password if it differs from ${VP_YELLOW}root${VP_WHITE}${VP_NONE}, otherwise hit enter. ${VP_WHITE}${VP_NONE}" dbPassword -echo "" +# Grab the database password +echo -e "\\nEnter your database password if it differs from ${VP_YELLOW}root${VP_WHITE}${VP_NONE}, otherwise hit enter.${VP_WHITE}${VP_NONE}" +read -r dbPassword # If a $dbUser was not entered, we'll default to valet-plus' mysql username -[ -z "$dbUser" ] && dbUser=root +[ -z "${dbUser}" ] && dbUser=root # If a $dbUser was not entered, we'll default to valet-plus' mysql password -[ -z "$dbPassword" ] && dbPassword=root +[ -z "${dbPassword}" ] && dbPassword=root # Fetch the latest files from the wp-boilerplate repo and then pull it -cd $wpBoilerplate +cd "${wpBoilerplate}" echo -e "Fetching and pulling the latest version of ${VP_CYAN}wp-boilerplate${VP_WHITE}${VP_NONE}" -git fetch --force -git pull --force +git fetch --force && git pull --force # With a fresh pull, copy the zip file into the new project folder and unzip the contents -cp -a ./*.zip $installPath +cp -a ./*.zip "${installPath}" cd $installPath unzip -q ./*.zip @@ -81,7 +82,7 @@ rm -rf wp-config.php # Creating the new wp-config file echo -e "Creating database and setting up wp-config.php file.${VP_NONE}" -wp config create --dbname=wp_$dbName --dbuser=$dbUser --dbpass=$dbPassword --extra-php < Date: Thu, 14 Feb 2019 15:41:19 -0600 Subject: [PATCH 10/16] Another round of changes to formating and updated some removals. --- clique/clique_wp.sh | 208 +++++++++++++++++++++----------------------- 1 file changed, 100 insertions(+), 108 deletions(-) diff --git a/clique/clique_wp.sh b/clique/clique_wp.sh index 07edd51..82e39c5 100755 --- a/clique/clique_wp.sh +++ b/clique/clique_wp.sh @@ -5,57 +5,57 @@ VP_NONE=$'\033[00m' VP_RED=$'\033[01;31m' VP_GREEN=$'\033[01;32m' VP_YELLOW=$'\033[01;33m' -# VP_PURPLE=$'\033[01;35m' +VP_PURPLE=$'\033[01;35m' VP_CYAN=$'\033[01;36m' VP_WHITE=$'\033[01;37m' VP_BOLD=$'\033[1m' VP_UNDERLINE=$'\033[4m' + # Setup some folder paths to variables -folderPath="{$HOME}/Sites" +folderPath="${HOME}/Sites/" dirName="${PWD##*/}" -installPath="${folderPath}/${dirName}" -wpBoilerplate="${folderPath}/wp-boilerplate" -themeFolder="${folderPath}/${dirName}/wp-content/themes" +installPath="${folderPath}/${dirName}/" +wpBoilerplate="${folderPath}/wp-boilerplate/" +themeFolder="${folderPath}/${dirName}/wp-content/themes/" url="https://${dirName}.app" # Inform the user that this is assuming they're using Valet-plus -echo -e "${VP_CYAN}This bash script is under the assumption that you are using valet-plus to set up this WordPress install.${VP_NONE} +echo -e "${VP_CYAN}This bash script is under the assumption that you are using valet-plus to set up this WordPress install. ${VP_CYAN}${VP_BOLD}This script will now clear your terminal window. -${VP_WHITE}${VP_NONE} +${VP_WHITE} -${VP_WHITE}${VP_BOLD}Please press enter to continue.${VP_WHITE}${VP_NONE}" +${VP_WHITE}${VP_BOLD}Please press enter to continue.${VP_WHITE}" read -r clear && printf '\e[3J' # We will now try to cache the sudo password, as we'll be setting up an SSL for their dev environment -echo -e "${VP_RED}${VP_BOLD}You may be asked twice for your password, but this is to setup an SSL locally to best mimic a live environment.${VP_WHITE}${VP_NONE}" +echo -e "${VP_RED}${VP_BOLD}You may be asked twice for your password, but this is to setup an SSL locally to best mimic a live environment.${VP_NONE}" sudo -v # Grab the Site Name -echo -e "${VP_WHITE}Enter the site name.${VP_WHITE}${VP_NONE}" -read -r siteName +read -p "${VP_WHITE}Enter the site name: ${VP_NONE}" siteName # Grab the Blog Description -echo -e "\\n${VP_WHITE}Enter a blog description (optional).${VP_NONE}" +echo -e "\\n${VP_WHITE}Enter a blog description (optional):${VP_NONE}" read -r blogDescription # Grab the theme folder name -echo -e "\\n${VP_WHITE}Enter the theme folder name, ommiting -theme.${VP_NONE}" -read -r themeName +read -p $'\n'"${VP_WHITE}Enter the theme folder name, ommiting -theme${VP_NONE}: " themeName + # Grab the database name -echo -e "\\n${VP_WHITE}Enter your chosen database name.${VP_NONE} -${VP_RED}Note${VP_WHITE}:${VP_NONE} wp_ is automatically prefixed.${VP_WHITE}${VP_NONE}" read -r dbName +echo -e "\\n${VP_WHITE}Enter your chosen database name. + +${VP_RED}Note${VP_WHITE}: wp_ is automatically prefixed.${VP_NONE}" +read -r dbName # Grab the database username -echo -e "\\nEnter your database user name if it differs from ${VP_YELLOW}root${VP_WHITE}${VP_NONE}, otherwise hit enter.${VP_WHITE}${VP_NONE}" -read -r dbUser +read -p $'\n'"${VP_WHITE}Enter your database user name if it differs from \"${VP_YELLOW}root${VP_WHITE}\", otherwise hit enter.${VP_NONE} " dbUser # Grab the database password -echo -e "\\nEnter your database password if it differs from ${VP_YELLOW}root${VP_WHITE}${VP_NONE}, otherwise hit enter.${VP_WHITE}${VP_NONE}" -read -r dbPassword +read -p "${VP_WHITE}Enter your database password if it differs from \"${VP_YELLOW}root${VP_WHITE}\", otherwise hit enter.${VP_NONE} " dbPassword # If a $dbUser was not entered, we'll default to valet-plus' mysql username [ -z "${dbUser}" ] && dbUser=root @@ -64,55 +64,50 @@ read -r dbPassword [ -z "${dbPassword}" ] && dbPassword=root # Fetch the latest files from the wp-boilerplate repo and then pull it -cd "${wpBoilerplate}" -echo -e "Fetching and pulling the latest version of ${VP_CYAN}wp-boilerplate${VP_WHITE}${VP_NONE}" -git fetch --force && git pull --force +cd "${wpBoilerplate}" || exit 1 + +echo -e "\\n${VP_WHITE}Fetching and pulling the latest version of ${VP_CYAN}wp-boilerplate${VP_WHITE}${VP_NONE}" +git fetch --force +git pull --force # With a fresh pull, copy the zip file into the new project folder and unzip the contents -cp -a ./*.zip "${installPath}" -cd $installPath +cp -a ./*.zip "${installPath}"/ +cd "${installPath}" || exit 1 unzip -q ./*.zip # Copy the .sql file, and rename it cp ./dup-installer/*.sql ./import.sql # We want to remove the wp-config file here and create a new one -echo -e "${VP_RED}Deleting wp-config file and creating a new one.${VP_NONE}${VP_WHITE}" +echo -e "\\n${VP_RED}Deleting wp-config file and creating a new one.${VP_WHITE}${VP_NONE}" rm -rf wp-config.php # Creating the new wp-config file -echo -e "Creating database and setting up wp-config.php file.${VP_NONE}" -wp config create --dbname=wp_"${dbName}" --dbuser="${dbUser}" --dbpass="${dbPassword}" --extra-php < Date: Thu, 23 May 2019 16:07:23 -0500 Subject: [PATCH 11/16] Create env_install.sh --- clique/env_install.sh | 365 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 365 insertions(+) create mode 100644 clique/env_install.sh diff --git a/clique/env_install.sh b/clique/env_install.sh new file mode 100644 index 0000000..9e03989 --- /dev/null +++ b/clique/env_install.sh @@ -0,0 +1,365 @@ +#!/usr/bin/env bash + +# USAGE +usage() { echo -e " +USAGE: ${0} [OPTIONS]\\n +OPTIONS:\\n +-m (optional) Monochrome output colors +-q (optional) Suppress informational messages +-h Display this usage information\\n +"; } + +# OPTIONS +while getopts "mqh" opt; do + case "${opt}" in + m) monochrome="yes" ;; + q) quiet="yes" ;; + h) + usage + exit 0 + ;; + *) + usage + exit 1 + ;; + esac +done + +# COMMON VARIABLES & FUNCTIONS +# colors +if [[ -n "${monochrome}" ]]; then + ink_brew="\\xF0\x9f\x8d\xba" + ink_clear="\\x1b[0m" + ink_grey="\\x1b[38;5;244m" + ink_red="\\x1b[0m" + ink_green="\\x1b[0m" + ink_blue="\\x1b[0m" + ink_yellow="\\x1b[0m" + ink_purple="\\x1b[0m" +else + ink_brew="\\xF0\x9f\x8d\xba" + ink_clear="\\x1b[0m" + ink_grey="\\x1b[38;5;244m" + ink_red="\\x1b[38;5;204m" + ink_green="\\x1b[38;5;120m" + ink_blue="\\x1b[38;5;081m" + ink_yellow="\\x1b[38;5;228m" + ink_purple="\\x1b[38;5;207m" +fi + +# output +yes_no="${ink_blue}[${ink_clear} ${ink_green}yes${ink_clear} ${ink_blue}/${ink_clear} ${ink_red}no${ink_clear} ${ink_blue}]${ink_clear}" +mysql_maria="${ink_blue}[${ink_clear} ${ink_yellow}mysql${ink_clear} ${ink_blue}/${ink_clear} ${ink_purple}mariadb${ink_clear} ${ink_blue}]${ink_clear}" +latest="${ink_yellow}latest version" +yuicompressor='' +path=$HOME +sitepath="$HOME/Sites" +phpmyadmin=https://www.phpmyadmin.net/downloads/phpMyAdmin-latest-english.tar.gz +nl() { if [[ -z "${quiet}" ]]; then echo; fi; } +say() { if [[ -z "${quiet}" ]]; then echo -e "\\n${ink_grey}${1}${ink_clear}"; fi; } +tinysay() { if [[ -z "${quiet}" ]]; then echo -e "${ink_grey}${1}${ink_clear}"; fi; } +errsay() { echo -e "\\n${ink_red}${1}. Script aborted!${ink_clear}"; } +sucsay() { echo -e "${ink_green}${1} successfully installed.${ink_clear}"; } +err() { echo -e "\\n${ink_red}${1}${ink_clear}"; } +ask() { echo -en "\\n${ink_grey}${1} ${ink_clear}"; } +askinfo() { + echo -en "${ink_grey}${1} ${ink_clear}" + read -r "${2}" +} +saysitepath() { + echo -en "${ink_grey}${1}: ${ink_clear}" + echo -en "${ink_blue}${path} ${ink_clear}" +} + +# confirm +confirm() { + ask "${1}" + read -r INPUT + case "${INPUT}" in + [yY][eE][sS] | [yY]) ;; + [mM][yY][sS][qQ][lL] | [mM][aA][rR][iI][aA][dD][bB] | [mM][aA][rR][iI][aA]) ;; + [nN][oO] | [nN]) say "Script aborted.\\n" && exit 0 ;; + *) confirm "${1}" ;; + esac +} + +# Cache the sudo password +cache_sudo_password() { + + say "Please enter your local user password." + sudo -k + sudo -v && tinysay "${ink_blue}OK" +} + +# Gather all the Install Parameters +collect_install_parameters() { + + say "This script will install the basic tools used for local development." + nl + + confirm "Would you like to continue? ${yes_no}" + clear + + askinfo "Would you like to use MySQL or mariaDB? ${mysql_maria}" dbStructure + askinfo "${dbStructure} username (default: root):" dbUserName + askinfo "${dbStructure} password (default: root):" dbUserPass + nl + tinysay "What TLS would you like your sites to be served under? Default is ${ink_yellow}test${ink_grey}" + askinfo "${ink_red}Note${ink_grey}: Using ${ink_blue}app${ink_grey} or ${ink_blue}dev${ink_grey} will require you to run ${ink_purple}valet secure folder_name${ink_grey} before visiting the page:" getTLS + askinfo "Install phpmyadmin? ${yes_no}: " installPhpMyAdmin + askinfo "If using phpStorm, would you like to install yuicompressor for JavaScript and CSS minification watcher? ${yes_no}" getYUI + + # # setting defaults if values were omitted + if [[ -z "${dbStructure}" ]]; then dbStructure="mariadb"; fi + if [[ -z "${getTLS}" ]]; then getTLS="test"; fi + if [[ -z "${getYUI}" ]]; then getYUI="no"; fi + if [[ -z "${dbUserName}" ]] ; then dbUserName="root" ; fi + if [[ -z "${dbUserPass}" ]] ; then dbUserPass="root" ; fi + + say "This ${ink_yellow}computer${ink_grey} will have the following installed:" + nl + + say "${ink_green}PACKAGE MANAGER" + tinysay "${ink_blue}Homebrew${ink_grey} - A tool/repo installer similar to NPM" + tinysay "${ink_blue}Composer${ink_grey}: ${latest}" + tinysay "${ink_blue}Node/NPM${ink_grey}: ${latest}" + nl + + say "${ink_green}ENVIRONMENT" + tinysay "${ink_blue}Laravel Valet${ink_grey} - Local Dev Environment." + tinysay "${ink_blue}php${ink_grey}" + tinysay "${ink_blue}Database${ink_grey}: ${ink_yellow}${dbStructure}" + tinysay "${ink_blue}Database username${ink_grey}: ${ink_yellow}${dbUserName}" + tinysay "${ink_blue}Database password${ink_grey}: ${ink_yellow}${dbUserPass}" + + if [[ "${installPhpMyAdmin}" != n* ]]; then + tinysay "${ink_blue}phpMyAdmin${ink_grey} - latest version" + fi + tinysay "${ink_blue}Local site TLS${ink_grey}: ${ink_yellow}${getTLS}" + nl + + say "${ink_green}TOOLS" + tinysay "${ink_blue}Gulp${ink_grey} - Sage8 Projects: ${latest}" + tinysay "${ink_blue}WP-CLI${ink_grey}: ${latest}" + tinysay "${ink_blue}Yarn${ink_grey} (for Sage9 Projects): ${latest}" + if [[ "${getYUI}" != n* ]]; then + tinysay "${ink_blue}YUICompressor${ink_grey}: ${latest}" + fi + + confirm "Would you like to continue? ${yes_no}" +} + +# Install homebrew +install_homebrew() { + if ! hash brew 2>/dev/null; then + say "Downloading and installing Homebrew. Please wait…" + /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" + say "Homebrew is installed. You can use it to install packages by calling to the command ${ink_blue}brew${ink_grey}" + confirm "Would you like to continue? ${yes_no}" + else + tinysay "Homebrew is already installed. You can call to it with the command ${ink_blue}brew${ink_grey}" + confirm "Would you like to continue? ${yes_no}" + fi +} + +# Install Composer, node, php, wget, SASS, yuicompressor, and database of choice +install_homebrew_packages() { + if ! type brew >/dev/null 2>&1; then + if [[ "${getYUI}" != n* ]] ; then + yuicompressor="yuicompressor" + fi + + tinysay "Installing ${ink_brew} brew packages. Please wait…" + # brew install composer node php wget sass/sass/sass ${dbStructure} ${yuicompressor} + brew services start ${dbStructure} + tinysay "${ink_green}Install Complete!${ink_grey}" + fi +} + +# Check for any errors when installing brew packages +brew_error_checks() { + tinysay "Checking ${ink_brew} brew for errors." + + if ! type composer >/dev/null 2>&1; then + errsay "There was an error installing Composer. Please review why and report back to the script creator." + else + sucsay composer + fi + + if ! type mysql >/dev/null 2>&1; then + errsay "There was an error installing ${dbStructure}. Please review why and report back to the script creator." + else + sucsay ${dbStructure} + fi + + if ! type node >/dev/null 2>&1; then + errsay "There was an error installing Node. Please review why and report back to the script creator." + else + sucsay node + fi + + if ! type php >/dev/null 2>&1; then + errsay "There was an error installing php. Please review why and report back to the script creator." + else + sucsay php + fi + + if ! type sass >/dev/null 2>&1; then + errsay "There was an error installing sass. Please review why and report back to the script creator." + else + sucsay sass + fi + + if ! type wget >/dev/null 2>&1; then + errsay "There was an error installing wget. Please review why and report back to the script creator." + else + sucsay wget + fi + + if [[ "${getYUI}" != n* ]] ; then + if ! type yuicompressor >/dev/null 2>&1; then + errsay "There was an error installing yuicompressor. Please review why and report back to the script creator." + else + sucsay yuicompressor + fi + fi +} + +# Writes exports to ./bash_profile +bash_profile_write() { + if [[ ! -e $HOME/.bash_profile ]]; then + tinysay "Creating a .bash_profile file at $HOME" + fi + + if ! grep -q "export PATH" $HOME/.bash_profile; then + tinysay "Adding export PATH to ~/.bash_profile" + echo 'export PATH' >> $HOME/.bash_profile + fi + + if ! grep -q 'export PATH="$PATH:$HOME/npm/bin"' $HOME/.bash_profile; then + tinysay "Adding NPM to your \$PATH" + echo 'export PATH="$PATH:$HOME/npm/bin"' >> $HOME/.bash_profile + fi + + if ! grep -q 'export PATH="/usr/local/bin:$PATH"' $HOME/.bash_profile; then + tinysay "Adding bin to your \$Path" + echo 'export PATH="/usr/local/bin:$PATH"' >> $HOME/.bash_profile + fi + + if ! grep -q 'export PATH="/usr/local/sbin:$PATH"' $HOME/.bash_profile; then + tinysay "Adding sbin to your \$Path" + echo 'export PATH="/usr/local/sbin:$PATH"' >> $HOME/.bash_profile + fi + + if ! grep -q 'export PATH="$PATH:$HOME/.composer/vendor/bin"' $HOME/.bash_profile; then + tinysay "Adding Composer to ~/.bash_profile" + echo 'export PATH="$PATH:$HOME/.composer/vendor/bin"' >> $HOME/.bash_profile + fi + + source $HOME/.bash_profile + tinysay "Reloaded your ${ink_yellow}.bash_proflie${ink_grey}" + +} + +# Installs npm packages +install_npm_packages() { + if type npm >/dev/null 2>&1; then + if ! type yarn >/dev/null 2>&1; then + tinysay "Installing ${ink_blue}yarn${ink_grey}" + npm install -g yarn + if ! yarn -v; then + errsay "There was an error installing yarn. Please review why and report back to the script creator." ; exit 1 + fi + sucsay "yarn" + fi + if ! type gulp >/dev/null 2>&1; then + tinysay "Installing ${ink_blue}gulp${ink_grey}" + npm install -g gulp + if ! gulp -v; then + errsay "There was an error installing gulp. Please review why and report back to the script creator." ; exit 1 + fi + sucsay "Gulp" + fi + fi +} + +# Installs WP-CLI and wp-completion.bash +install_wpcli() { + + if ! type wp >/dev/null 2>&1; then + curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar + if php wp-cli.phar --info ; then + chmod +x wp-cli.phar + sudo mv wp-cli.phar /usr/local/bin/wp + else + errsay "WP-CLI didn't install correctly, please see why." + fi + fi + + if type wp >/dev/null 2>&1; then + cd $HOME + mkdir .bash_completions + cd .bash_completions + if [[ -e $HOME/.bash_completions/wp-completion.bash ]]; then + curl -O https://raw.githubusercontent.com/wp-cli/wp-cli/v1.5.1/utils/wp-completion.bash + echo "source \$HOME/.bash_completions/wp-completion.bash" >> $HOME/.bash_profile + fi + fi + + source $HOME/.bash_profile + +} + +# Sets up MySQL/MariaDB +setup_mysql() { + tinysay "${ink_yellow}Opening up MySQL portion of install, this will require user interaction. Enter in a password, then just hit enter.${ink_clear}" + secs=$((10)) + while [ $secs -gt 0 ]; do + tinysay "${secs}…" + sleep 1 + : $((secs--)) + done + mysql_secure_installation --user=${dbUserName} --password=${dbUserPass} +} + +# Installs valet +install_valet() { + if ! type composer >/dev/null 2>&1; then + tinysay "Beginning the installation of laravel/valet, your dev env." + composer global require laravel/valet + if ! type valet >/dev/null 2>&1; then + tinysay "Valet's downloaded, let's install it." + valet install + sudo valet trust + valet domain ${getTLS} + cd ${path} + if [[ ! -d ${sitepath} ]]; then + mkdir Sites + fi + cd ${sitepath} + valet park + sucsay "You now have a Sites directory located at ${sitepath}. You can create new folders within here, and valet will serve them in your browser using the ${getTLS} as your TLS." + fi + fi +} + +# Installs phpmyadmin and adds a syslink to the Sites directory +install_phpmyadmin() { + cd ${sitepath} + brew install phpmyadmin + ln -s /usr/local/share/phpmyadmin . + valet secure phpmyadmin +} + +# Main Script Start +# cache_sudo_password +# collect_install_parameters +# install_homebrew +# install_homebrew_packages +# brew_error_checks +# bash_profile_write +# install_npm_packages +# install_wpcli +# setup_mysql +# install_valet +# install_phpmyadmin From 4247af9d4a824c0dd3577153b4ee7bb521cb3a7a Mon Sep 17 00:00:00 2001 From: kupoback Date: Fri, 24 May 2019 10:51:02 -0500 Subject: [PATCH 12/16] Update env_install.sh Update variable for consistency --- clique/env_install.sh | 42 ++++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/clique/env_install.sh b/clique/env_install.sh index 9e03989..ce20eb5 100644 --- a/clique/env_install.sh +++ b/clique/env_install.sh @@ -51,9 +51,9 @@ fi yes_no="${ink_blue}[${ink_clear} ${ink_green}yes${ink_clear} ${ink_blue}/${ink_clear} ${ink_red}no${ink_clear} ${ink_blue}]${ink_clear}" mysql_maria="${ink_blue}[${ink_clear} ${ink_yellow}mysql${ink_clear} ${ink_blue}/${ink_clear} ${ink_purple}mariadb${ink_clear} ${ink_blue}]${ink_clear}" latest="${ink_yellow}latest version" -yuicompressor='' -path=$HOME -sitepath="$HOME/Sites" +yuicompressor="" +path="${HOME}" +sitepath="${HOME}/Sites" phpmyadmin=https://www.phpmyadmin.net/downloads/phpMyAdmin-latest-english.tar.gz nl() { if [[ -z "${quiet}" ]]; then echo; fi; } say() { if [[ -z "${quiet}" ]]; then echo -e "\\n${ink_grey}${1}${ink_clear}"; fi; } @@ -227,36 +227,38 @@ brew_error_checks() { # Writes exports to ./bash_profile bash_profile_write() { - if [[ ! -e $HOME/.bash_profile ]]; then - tinysay "Creating a .bash_profile file at $HOME" + if [[ ! -e ${HOME}/.bash_profile ]]; then + tinysay "Creating a .bash_profile file at ${HOME}" fi - if ! grep -q "export PATH" $HOME/.bash_profile; then + if ! grep -q "export PATH" ${HOME}/.bash_profile; then tinysay "Adding export PATH to ~/.bash_profile" - echo 'export PATH' >> $HOME/.bash_profile + echo 'export PATH' >> ${HOME}/.bash_profile fi - if ! grep -q 'export PATH="$PATH:$HOME/npm/bin"' $HOME/.bash_profile; then + if ! grep -q 'export PATH="$PATH:${HOME}/npm/bin"' ${HOME}/.bash_profile; then tinysay "Adding NPM to your \$PATH" - echo 'export PATH="$PATH:$HOME/npm/bin"' >> $HOME/.bash_profile + echo 'export PATH="$PATH:${HOME}/npm/bin"' >> ${HOME}/.bash_profile fi - if ! grep -q 'export PATH="/usr/local/bin:$PATH"' $HOME/.bash_profile; then + if ! grep -q 'export PATH="/usr/local/bin:$PATH"' ${HOME}/.bash_profile; then tinysay "Adding bin to your \$Path" - echo 'export PATH="/usr/local/bin:$PATH"' >> $HOME/.bash_profile + echo 'export PATH="/usr/local/bin:$PATH"' >> ${HOME}/.bash_profile fi - if ! grep -q 'export PATH="/usr/local/sbin:$PATH"' $HOME/.bash_profile; then + if ! grep -q 'export PATH="/usr/local/sbin:$PATH"' ${HOME}/.bash_profile; then tinysay "Adding sbin to your \$Path" - echo 'export PATH="/usr/local/sbin:$PATH"' >> $HOME/.bash_profile + echo 'export PATH="/usr/local/sbin:$PATH"' >> ${HOME}/.bash_profile fi - if ! grep -q 'export PATH="$PATH:$HOME/.composer/vendor/bin"' $HOME/.bash_profile; then + if ! grep -q 'export PATH="$PATH:${HOME}/.composer/vendor/bin"' ${HOME}/.bash_profile; then tinysay "Adding Composer to ~/.bash_profile" - echo 'export PATH="$PATH:$HOME/.composer/vendor/bin"' >> $HOME/.bash_profile + echo 'export PATH="$PATH:${HOME}/.composer/vendor/bin"' >> ${HOME}/.bash_profile fi - source $HOME/.bash_profile + + + source ${HOME}/.bash_profile tinysay "Reloaded your ${ink_yellow}.bash_proflie${ink_grey}" } @@ -297,16 +299,16 @@ install_wpcli() { fi if type wp >/dev/null 2>&1; then - cd $HOME + cd ${HOME} mkdir .bash_completions cd .bash_completions - if [[ -e $HOME/.bash_completions/wp-completion.bash ]]; then + if [[ -e ${HOME}/.bash_completions/wp-completion.bash ]]; then curl -O https://raw.githubusercontent.com/wp-cli/wp-cli/v1.5.1/utils/wp-completion.bash - echo "source \$HOME/.bash_completions/wp-completion.bash" >> $HOME/.bash_profile + echo "source \${HOME}/.bash_completions/wp-completion.bash" >> ${HOME}/.bash_profile fi fi - source $HOME/.bash_profile + source ${HOME}/.bash_profile } From 3fb0be01ad47b69c390e80c5f6b3d3f60fb321be Mon Sep 17 00:00:00 2001 From: Nick Makris <> Date: Tue, 11 Jun 2019 12:46:03 -0500 Subject: [PATCH 13/16] Worked on new_wp.sh and adding in some tools written. --- README.md | 0 clique/README.md | 0 clique/clique_wp.sh | 2 +- new_wp/new_wp.sh | 424 +++++++++++++++++++++++++++------------- new_wp/tools_install.sh | 367 ++++++++++++++++++++++++++++++++++ 5 files changed, 652 insertions(+), 141 deletions(-) mode change 100644 => 100755 README.md mode change 100644 => 100755 clique/README.md create mode 100755 new_wp/tools_install.sh diff --git a/README.md b/README.md old mode 100644 new mode 100755 diff --git a/clique/README.md b/clique/README.md old mode 100644 new mode 100755 diff --git a/clique/clique_wp.sh b/clique/clique_wp.sh index 82e39c5..f364c6f 100755 --- a/clique/clique_wp.sh +++ b/clique/clique_wp.sh @@ -205,7 +205,7 @@ wp post update 2 --post_title=Home --post_name=home --post_type=page --post_stat if [[ -n "${pageList}" ]] then echo -e "\\n${VP_CYAN}Creating pages.${VP_WHITE}${VP_NONE}" - IFS="," + IFS=", " arr=("${pageList}") for i in "${!arr[@]}" do diff --git a/new_wp/new_wp.sh b/new_wp/new_wp.sh index eb133a3..2d1b12f 100755 --- a/new_wp/new_wp.sh +++ b/new_wp/new_wp.sh @@ -1,159 +1,303 @@ -#!/bin/bash - -# Styles -VP_NONE='\033[00m' -VP_RED='\033[01;31m' -VP_GREEN='\033[01;32m' -VP_YELLOW='\033[01;33m' -VP_PURPLE='\033[01;35m' -VP_CYAN='\033[01;36m' -VP_WHITE='\033[01;37m' -VP_BOLD='\033[1m' -VP_UNDERLINE='\033[4m' +#!/usr/bin/env bash -dirName=${PWD##*/} +# change to script directory +#cd "$(dirname "${BASH_SOURCE[0]}")" || exit 1 -#Forwarn Part 1 -if [ ! "$(ls -a ./.git)" ]; then - echo -e "${VP_RED}This script runs under the assumption that you've cloned a repository down." - echo "" - echo -e "Exiting script.${VP_NONE}${VP_WHITE}" - exit -fi +# USAGE +usage () { echo -e " +USAGE: ${0} [OPTIONS]\\n +OPTIONS:\\n +-m (optional) Monochrome output colors +-q (optional) Suppress informational messages +-h Display this usage information\\n +" ; } -# Inform the user that this is assuming they're using Valet-plus -echo -e "${VP_CYAN}This bash script is under the assumption that you are using valet-plus to set up this WordPress install.${VP_NONE}" -echo -e "${VP_CYAN}${VP_BOLD}This script will now clear your terminal window.${VP_NONE}" -echo "" -echo -e "${VP_WHITE}${VP_BOLD}Please press enter to continue."; -read clearTerminal - -clear - -# We will now try to cache the sudo password, as we'll be setting up an SSL for their dev environment -echo -e "${VP_RED}${VP_BOLD}You may be asked twice for your password, but this is to setup an SSL locally to best mimic a live environment.${VP_NONE}" -sudo -v - -# Set the Site Name -echo -e "Enter the site name."; -read siteName -echo "" - -# Set the database name -echo -e "Enter your chosen database name." -echo -e "${VP_WHITE}Note, wp_ is automatically prefixed"; -read dbName -echo "" - -echo -e "Enter your database user name if it differs from root, otherwise hit enter."; -read dbUser -echo "" - -echo -e "Enter your database password if it differs from root, otherwise hit enter."; -read dbPassword -echo "" - -# If a $dbUser was not entered, we'll default to valet-plus' mysql username -[ -z "$dbUser" ] && $dbUser = 'root' - -# If a $dbUser was not entered, we'll default to valet-plus' mysql password -[ -z "$dbPassword" ] && $dbPassword = 'root' - -# Let's double check the WordPress version they want to download -echo -e "${VP_PURPLE}If you'd like to download a different version number, please enter in the number, otherwise, just press enter.${VP_WHITE}"; -read wpVersion -echo "" - -# Start downloading WordPress and it's latest version -[ -z "$wpVersion" ] && wp core download || wp core download --version=$wpVersion - -## Create the wp-config file and the database -echo -e "${VP_PURPLE}Creating database and setting up wp-config.php file.${VP_WHITE}" -wp config create --dbname=wp_$dbName --dbuser=$dbUser --dbpass=$dbName --extra-php </dev/null 2>&1 && ! type valet >/dev/null 2>&1; then + err "${ink_red}This script requires the installation of wp-cli and valet or valet plus" + tinyerr "You can install ${ink_blue}wp-cli${ink_red} using Homebrew or by visiting ${ink_purple}https://wp-cli.org" + tinyerr "You can install ${ink_blue}valet${ink_red} from ${ink_purple}https://laravel.com/docs/master/valet" + tinyerr "OR" + tinyerr "You can install ${ink_blue}valet-plus${ink_red} from ${ink_purple}https://github.com/weprovide/valet-plus" + say "Exiting script\\n" && exit 0 + fi + + say "This script is under the assumption that you're using ${ink_blue}valet-plus${ink_gray} to setup this WordPress environment." + confirm "Would you like to continue? ${yes_no}" + clear + tinysay "Starting new WordPress environment setup ..." + +} + +cache_sudo_password () { + + say "Please enter your local user password." + sudo -k ; sudo -v && tinysay "${ink_blue}OK" + +} + +collect_environment_information () { + + say "Please provide the necessary information for the new environment:" + nl + askinfo "Site name:" siteName + askinfo "Enter your TLS: " domainTLS + askinfo "Install SSL (default: yes): ${yes_no}" addSSL + askinfo "WordPress version (default: latest):" wpVersion + askinfo "Database name (wp_ will be prefixed):" dbName + askinfo "Database user name (default: root):" dbUserName + askinfo "Database user pass (default: root):" dbUserPass + askinfo "Admin user name:" adminUserName + askinfo "Admin user pass:" adminUserPass + askinfo "Admin user email:" adminUserEmail + askinfo "Install Blank Site (default: no): ${yes_no}" blankInstall + askinfo "Disable Comments (default: no): ${yes_no}" disableComments + askinfo "Disable Trackbacks (default: no): ${yes_no}" disableTrackbacks + askinfo "Create additional pages? ${yes_no}" createPages + + sslURL="https://${PWD##*/}.${domainTLS}" + nonSSLURL="http://${PWD##*/}.${domainTLS}" + + # setting defaults if values were omitted + if [[ -z "${domainTLS}" ]] ; then tinysay "You must enter a TLS. Exiting script\\n" && exit 0 ; fi + if [[ -z "${addSSL}" ]] ; then addSSL="yes" ; fi + if [[ -z "${wpVersion}" ]] ; then wpVersion="latest" ; fi + if [[ -z "${dbUserName}" ]] ; then dbUserName="root" ; fi + if [[ -z "${dbUserPass}" ]] ; then dbUserPass="root" ; fi + if [[ -z "${disableComments}" ]] ; then disableComments="no" ; fi + if [[ -z "${disableTrackbacks}" ]] ; then disableTrackbacks="no" ; fi + if [[ -z "${blankInstall}" ]] ; then blankInstall="no" ; fi + if [[ "${createPages}" =~ ^([yY][eE][sS]|[yY])+ ]] ; then create_pages ; fi + + say "The ${ink_yellow}new environment${ink_gray} will be created with the following information:" + nl + tinysay "Site name: ${ink_yellow}${siteName}" + if [[ "${addSSL}" =~ ^([yY][eE][sS]|[yY])+ ]] ; then + tinysay "URL: ${ink_yellow}${sslURL}" + else + tinysay "URL: ${ink_yellow}${nonSSLURL}" + fi + tinysay "WordPress version: ${ink_yellow}${wpVersion}" + tinysay "Database name: ${ink_yellow}wp_${dbName}" + tinysay "Database user name: ${ink_yellow}${dbUserName}" + tinysay "Database user pass: ${ink_yellow}${dbUserPass}" + tinysay "Admin user name: ${ink_yellow}${adminUserName}" + tinysay "Admin user pass: ${ink_yellow}${adminUserPass}" + tinysay "Admin user email: ${ink_yellow}${adminUserEmail}" + if [[ "${createPages}" =~ ^([yY][eE][sS]|[yY])+ ]] ; then + tinysay "Creating pages: ${ink_yellow}${pageList}" + fi + + confirm "Would you like to continue? ${yes_no}" + +} + +download_wordpress () { + + say "Downloading WordPress ..." + if [[ "${wpVersion}" == "latest" ]] ; then + if [[ "${blankInstall}" =~ ^([yY][eE][sS]|[yY])+ ]] ; then + if ! wp core download --skip-content ; then + errsay "Error during WordPress download" ; exit 1 + fi + else + if ! wp core download ; then + errsay "Error during WordPress download" ; exit 1 + fi + fi + else + if [[ "${blankInstall}" =~ ^([yY][eE][sS]|[yY])+ ]] ; then + if ! wp core download --version="${wpVersion}" --skip-content; then + errsay "Error during WordPress download" ; exit 1 + fi + else + if ! wp core download --version="${wpVersion}" ; then + errsay "Error during WordPress download" ; exit 1 + fi + fi + fi + +} + +create_wp_config () { + + say "Creating WordPress configuration file (wp-config.php) ..." rm -rf wp-config.php - echo -e "${VP_RED}Database 'wp_$dbName' exists. Please enter another db name." - - echo -e "Enter your chosen database name." - echo -e "${VP_WHITE}Note, wp_ is automatically prefixed" - read dbNameReTry - echo "" - - wp config create --dbname=wp_$dbNameReTry --dbuser=$dbUser --dbpass=$dbPassword --force --extra-php </dev/null; then + say "Downloading and installing Homebrew. Please wait…" + /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" + say "Homebrew is installed. You can use it to install packages by calling to the command ${ink_blue}brew${ink_grey}" + confirm "Would you like to continue? ${yes_no}" + else + tinysay "Homebrew is already installed. You can call to it with the command ${ink_blue}brew${ink_grey}" + confirm "Would you like to continue? ${yes_no}" + fi +} + +# Install Composer, node, php, wget, SASS, yuicompressor, and database of choice +install_homebrew_packages() { + if ! type brew >/dev/null 2>&1; then + if [[ "${getYUI}" != n* ]] ; then + yuicompressor="yuicompressor" + fi + + tinysay "Installing ${ink_brew} brew packages. Please wait…" + # brew install composer node php wget sass/sass/sass ${dbStructure} ${yuicompressor} + brew services start ${dbStructure} + tinysay "${ink_green}Install Complete!${ink_grey}" + fi +} + +# Check for any errors when installing brew packages +brew_error_checks() { + tinysay "Checking ${ink_brew} brew for errors." + + if ! type composer >/dev/null 2>&1; then + errsay "There was an error installing Composer. Please review why and report back to the script creator." + else + sucsay composer + fi + + if ! type mysql >/dev/null 2>&1; then + errsay "There was an error installing ${dbStructure}. Please review why and report back to the script creator." + else + sucsay ${dbStructure} + fi + + if ! type node >/dev/null 2>&1; then + errsay "There was an error installing Node. Please review why and report back to the script creator." + else + sucsay node + fi + + if ! type php >/dev/null 2>&1; then + errsay "There was an error installing php. Please review why and report back to the script creator." + else + sucsay php + fi + + if ! type sass >/dev/null 2>&1; then + errsay "There was an error installing sass. Please review why and report back to the script creator." + else + sucsay sass + fi + + if ! type wget >/dev/null 2>&1; then + errsay "There was an error installing wget. Please review why and report back to the script creator." + else + sucsay wget + fi + + if [[ "${getYUI}" != n* ]] ; then + if ! type yuicompressor >/dev/null 2>&1; then + errsay "There was an error installing yuicompressor. Please review why and report back to the script creator." + else + sucsay yuicompressor + fi + fi +} + +# Writes exports to ./bash_profile +bash_profile_write() { + if [[ ! -e ${HOME}/.bash_profile ]]; then + tinysay "Creating a .bash_profile file at ${HOME}" + fi + + if ! grep -q "export PATH" ${HOME}/.bash_profile; then + tinysay "Adding export PATH to ~/.bash_profile" + echo 'export PATH' >> ${HOME}/.bash_profile + fi + + if ! grep -q 'export PATH="$PATH:${HOME}/npm/bin"' ${HOME}/.bash_profile; then + tinysay "Adding NPM to your \$PATH" + echo 'export PATH="$PATH:${HOME}/npm/bin"' >> ${HOME}/.bash_profile + fi + + if ! grep -q 'export PATH="/usr/local/bin:$PATH"' ${HOME}/.bash_profile; then + tinysay "Adding bin to your \$Path" + echo 'export PATH="/usr/local/bin:$PATH"' >> ${HOME}/.bash_profile + fi + + if ! grep -q 'export PATH="/usr/local/sbin:$PATH"' ${HOME}/.bash_profile; then + tinysay "Adding sbin to your \$Path" + echo 'export PATH="/usr/local/sbin:$PATH"' >> ${HOME}/.bash_profile + fi + + if ! grep -q 'export PATH="$PATH:${HOME}/.composer/vendor/bin"' ${HOME}/.bash_profile; then + tinysay "Adding Composer to ~/.bash_profile" + echo 'export PATH="$PATH:${HOME}/.composer/vendor/bin"' >> ${HOME}/.bash_profile + fi + + + + source ${HOME}/.bash_profile + tinysay "Reloaded your ${ink_yellow}.bash_proflie${ink_grey}" + +} + +# Installs npm packages +install_npm_packages() { + if type npm >/dev/null 2>&1; then + if ! type yarn >/dev/null 2>&1; then + tinysay "Installing ${ink_blue}yarn${ink_grey}" + npm install -g yarn + if ! yarn -v; then + errsay "There was an error installing yarn. Please review why and report back to the script creator." ; exit 1 + fi + sucsay "yarn" + fi + if ! type gulp >/dev/null 2>&1; then + tinysay "Installing ${ink_blue}gulp${ink_grey}" + npm install -g gulp + if ! gulp -v; then + errsay "There was an error installing gulp. Please review why and report back to the script creator." ; exit 1 + fi + sucsay "Gulp" + fi + fi +} + +# Installs WP-CLI and wp-completion.bash +install_wpcli() { + + if ! type wp >/dev/null 2>&1; then + curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar + if php wp-cli.phar --info ; then + chmod +x wp-cli.phar + sudo mv wp-cli.phar /usr/local/bin/wp + else + errsay "WP-CLI didn't install correctly, please see why." + fi + fi + + if type wp >/dev/null 2>&1; then + cd ${HOME} + mkdir .bash_completions + cd .bash_completions + if [[ -e ${HOME}/.bash_completions/wp-completion.bash ]]; then + curl -O https://raw.githubusercontent.com/wp-cli/wp-cli/v1.5.1/utils/wp-completion.bash + echo "source \${HOME}/.bash_completions/wp-completion.bash" >> ${HOME}/.bash_profile + fi + fi + + source ${HOME}/.bash_profile + +} + +# Sets up MySQL/MariaDB +setup_mysql() { + tinysay "${ink_yellow}Opening up MySQL portion of install, this will require user interaction. Enter in a password, then just hit enter.${ink_clear}" + secs=$((10)) + while [ $secs -gt 0 ]; do + tinysay "${secs}…" + sleep 1 + : $((secs--)) + done + mysql_secure_installation --user=${dbUserName} --password=${dbUserPass} +} + +# Installs valet +install_valet() { + if ! type composer >/dev/null 2>&1; then + tinysay "Beginning the installation of laravel/valet, your dev env." + composer global require laravel/valet + if ! type valet >/dev/null 2>&1; then + tinysay "Valet's downloaded, let's install it." + valet install + sudo valet trust + valet domain ${getTLS} + cd ${path} + if [[ ! -d ${sitepath} ]]; then + mkdir Sites + fi + cd ${sitepath} + valet park + sucsay "You now have a Sites directory located at ${sitepath}. You can create new folders within here, and valet will serve them in your browser using the ${getTLS} as your TLS." + fi + fi +} + +# Installs phpmyadmin and adds a syslink to the Sites directory +install_phpmyadmin() { + cd ${sitepath} + brew install phpmyadmin + ln -s /usr/local/share/phpmyadmin . + valet secure phpmyadmin +} + +# Main Script Start +# cache_sudo_password +# collect_install_parameters +# install_homebrew +# install_homebrew_packages +# brew_error_checks +# bash_profile_write +# install_npm_packages +# install_wpcli +# setup_mysql +# install_valet +# install_phpmyadmin \ No newline at end of file From 6a1308307783f58f685e1dcd1a2baf1db7e86df9 Mon Sep 17 00:00:00 2001 From: Nick Makris <> Date: Wed, 12 Jun 2019 16:14:12 -0500 Subject: [PATCH 14/16] Continued work on the new_wp.sh script optimizing it based on feedback. --- clique/env_install.sh | 0 new_wp/new_wp.sh | 104 ++++++++++----- wp_install.sh | 303 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 371 insertions(+), 36 deletions(-) mode change 100644 => 100755 clique/env_install.sh create mode 100755 wp_install.sh diff --git a/clique/env_install.sh b/clique/env_install.sh old mode 100644 new mode 100755 diff --git a/new_wp/new_wp.sh b/new_wp/new_wp.sh index 2d1b12f..8eda73d 100755 --- a/new_wp/new_wp.sh +++ b/new_wp/new_wp.sh @@ -46,6 +46,7 @@ fi yes_no="${ink_blue}[${ink_clear} ${ink_green}yes${ink_clear} ${ink_blue}/${ink_clear} ${ink_red}no${ink_clear} ${ink_blue}]${ink_clear}" nl () { if [[ -z "${quiet}" ]] ; then echo ; fi ; } say () { if [[ -z "${quiet}" ]] ; then echo -e "\\n${ink_gray}${1}${ink_clear}" ; fi ; } +success () { if [[ -z "${quiet}" ]] ; then echo -e "\\n${ink_green}${1}${ink_clear}" ; fi ; } tinysay () { if [[ -z "${quiet}" ]] ; then echo -e "${ink_gray}${1}${ink_clear}" ; fi ; } errsay () { echo -e "\\n${ink_red}${1}. Script aborted!${ink_clear}" ; } err () { echo -e "\\n${ink_red}${1}${ink_clear}" ; } @@ -82,10 +83,10 @@ initiate_env_setup () { say "Exiting script\\n" && exit 0 fi - say "This script is under the assumption that you're using ${ink_blue}valet-plus${ink_gray} to setup this WordPress environment." + say "This script is under the assumption that you're using ${ink_blue}valet${ink_gray} or ${ink_blue}valet-plus${ink_gray} to setup this WordPress environment." confirm "Would you like to continue? ${yes_no}" clear - tinysay "Starting new WordPress environment setup ..." + say "Starting new WordPress environment setup ..." } @@ -101,16 +102,18 @@ collect_environment_information () { say "Please provide the necessary information for the new environment:" nl askinfo "Site name:" siteName - askinfo "Enter your TLS: " domainTLS + askinfo "Enter your TLS (omit the period [.] ): " domainTLS askinfo "Install SSL (default: yes): ${yes_no}" addSSL askinfo "WordPress version (default: latest):" wpVersion - askinfo "Database name (wp_ will be prefixed):" dbName - askinfo "Database user name (default: root):" dbUserName - askinfo "Database user pass (default: root):" dbUserPass - askinfo "Admin user name:" adminUserName - askinfo "Admin user pass:" adminUserPass - askinfo "Admin user email:" adminUserEmail - askinfo "Install Blank Site (default: no): ${yes_no}" blankInstall + askinfo "MySQL Localhost or IP (default: localhost):" dbHost + askinfo "Database Name (include prefix if desired):" dbName + askinfo "Database Table Prefix (default: wp_):" dbTablePrefix + askinfo "Database User Name (default: root):" dbUserName + askinfo "Database User Password:" dbUserPass + askinfo "WP Admin User Name:" adminUserName + askinfo "WP Admin User Password:" adminUserPass + askinfo "WP Admin Email:" adminUserEmail + askinfo "Install Blank Site; This will still install ${ink_yellow}Twentynineteen${ink_gray} theme (default: no): ${yes_no}" blankInstall askinfo "Disable Comments (default: no): ${yes_no}" disableComments askinfo "Disable Trackbacks (default: no): ${yes_no}" disableTrackbacks askinfo "Create additional pages? ${yes_no}" createPages @@ -121,9 +124,15 @@ collect_environment_information () { # setting defaults if values were omitted if [[ -z "${domainTLS}" ]] ; then tinysay "You must enter a TLS. Exiting script\\n" && exit 0 ; fi if [[ -z "${addSSL}" ]] ; then addSSL="yes" ; fi - if [[ -z "${wpVersion}" ]] ; then wpVersion="latest" ; fi + if [[ -z "${dbHost}" ]] ; then dbHost="localhost" ; fi + if [[ -z "${dbName}" ]] ; then + err "\\nYou didn't enter in a database name." + askinfo "Database Name (include prefix if desired):" dbName + fi + if [[ -z "${dbTablePrefix}" ]] ; then dbTablePrefix="wp_" ; fi if [[ -z "${dbUserName}" ]] ; then dbUserName="root" ; fi - if [[ -z "${dbUserPass}" ]] ; then dbUserPass="root" ; fi + if [[ -z "${dbUserPass}" ]] ; then dbUserPass="" ; fi + if [[ -z "${wpVersion}" ]] ; then wpVersion="latest" ; fi if [[ -z "${disableComments}" ]] ; then disableComments="no" ; fi if [[ -z "${disableTrackbacks}" ]] ; then disableTrackbacks="no" ; fi if [[ -z "${blankInstall}" ]] ; then blankInstall="no" ; fi @@ -131,21 +140,30 @@ collect_environment_information () { say "The ${ink_yellow}new environment${ink_gray} will be created with the following information:" nl - tinysay "Site name: ${ink_yellow}${siteName}" + tinysay "Site name: ${ink_yellow}${siteName}" if [[ "${addSSL}" =~ ^([yY][eE][sS]|[yY])+ ]] ; then - tinysay "URL: ${ink_yellow}${sslURL}" + tinysay "URL: ${ink_yellow}${sslURL}" else - tinysay "URL: ${ink_yellow}${nonSSLURL}" + tinysay "URL: ${ink_yellow}${nonSSLURL}" fi - tinysay "WordPress version: ${ink_yellow}${wpVersion}" - tinysay "Database name: ${ink_yellow}wp_${dbName}" - tinysay "Database user name: ${ink_yellow}${dbUserName}" - tinysay "Database user pass: ${ink_yellow}${dbUserPass}" - tinysay "Admin user name: ${ink_yellow}${adminUserName}" - tinysay "Admin user pass: ${ink_yellow}${adminUserPass}" - tinysay "Admin user email: ${ink_yellow}${adminUserEmail}" - if [[ "${createPages}" =~ ^([yY][eE][sS]|[yY])+ ]] ; then - tinysay "Creating pages: ${ink_yellow}${pageList}" + tinysay "WordPress version: ${ink_yellow}${wpVersion}" + tinysay "Database Host: ${ink_yellow}${dbHost}" + tinysay "Database Name: ${ink_yellow}${dbName}" + tinysay "Database Table Prefix: ${ink_yellow}${dbTablePrefix}" + tinysay "Database User Name: ${ink_yellow}${dbUserName}" + if [[ -z "${dbUserPass}" ]] ; then + tinysay "Database User Password: ${ink_yellow}No Password" + else + tinysay "Database User Password: ${ink_yellow}${dbUserPass}" + fi + tinysay "WP Admin User Name: ${ink_yellow}${adminUserName}" + tinysay "WP Admin User Password: ${ink_yellow}${adminUserPass}" + tinysay "WP Admin User Email: ${ink_yellow}${adminUserEmail}" + if [[ "${blankInstall}" =~ ^([yY][eE][sS]|[yY])+ ]] ; then + tinysay "Default Contents: ${ink_yellow}TwentyNineteen Theme Only" + fi + if [[ "${createPages}" =~ ^([yY][eE][sS]|[yY])+ ]] ; then + tinysay "Creating pages: ${ink_yellow}${pageList}" fi confirm "Would you like to continue? ${yes_no}" @@ -183,7 +201,7 @@ create_wp_config () { say "Creating WordPress configuration file (wp-config.php) ..." rm -rf wp-config.php - if ! wp config create --dbname=wp_"${dbName}" --dbuser="${dbUserName}" --dbpass="${dbUserPass}" + if ! wp config create --dbhost=${dbHost} --dbname="${dbName}" --dbuser="${dbUserName}" --dbpass="${dbUserPass}" --dbprefix="${dbTablePrefix}" then errsay "Error during creation of wp-config.php" ; exit 1 ; fi } @@ -200,28 +218,32 @@ create_wp_database () { build_wp_site () { say "Building WordPress site ..." - if ! wp core install --url="${dirName}.app" --title="${siteName}" --admin_user="${adminUserName}" --admin_password="${adminUserPass}" --admin_email="${adminUserEmail}" ; then + if ! wp core install --url="${dirName}.${domainTLS}" --title="${siteName}" --admin_user="${adminUserName}" --admin_password="${adminUserPass}" --admin_email="${adminUserEmail}" ; then errsay "Error during building of site" ; exit 1 fi - tinysay "Changing ${ink_yellow}\"Sampe Page\"${ink_gray} to ${ink_yellow}\"Home\"${ink_gray}" + if [[ "${blankInstall}" =~ ^([yY][eE][sS]|[yY])+ ]] ; then + add_missing_folders + + fi + + say "Changing ${ink_yellow}\"Sampe Page\"${ink_gray} to ${ink_yellow}\"Home\"${ink_gray}" wp post update 2 --post_title=Home --post_name=home --post_type=page --post_status=publish --post_content= --post_excerpt= - tinysay "Setting \"Home\" as the Front Page" + say "Setting \"Home\" as the Front Page" wp option update show_on_front 'page' wp option update page_on_front 2 - tinysay "Changing timezone to Chicago" + say "Changing timezone to Chicago" wp option update timezone_string "America/Chicago" if [[ "${disableComments}" =~ ^([yY][eE][sS]|[yY])+ ]] ; then disable_comments ; fi if [[ "${disableTrackbacks}" =~ ^([yY][eE][sS]|[yY])+ ]] ; then disable_tackbacks ; fi if [[ "${createPages}" =~ ^([yY][eE][sS]|[yY])+ ]] ; then loop_create_pages ; fi - tinysay "Flushing permalinks" - wp cache flush + say "Flushing permalinks" wp rewrite structure /%postname%/ - wp rewrite flush + wp cache flush } @@ -255,6 +277,16 @@ setup_complete() { } # Conditional Functions +add_missing_folders() { + if [[ "${blankInstall}" =~ ^([yY][eE][sS]|[yY])+ ]] ; then + mkdir wp-content/themes wp-content/plugins + say "Installing TwentyNinteent Theme to confirm site is setup." + if ! wp theme install twentynineteen --activate ; then + errsay "Error installing Twentynineteen theme. Contact script creator to correct the issue" && exit 0; + fi + fi +} + create_pages() { say "You can choose to create top level pages you know you'll need here, otherwise just hit enter to skip this." say "Please separate page names with a semicolon (;) with no space after it. The ${VP_CYAN}Homepage${VP_WHITE} is already created." @@ -267,25 +299,25 @@ loop_create_pages() { if [[ -n "${pageList}" || "${pageList}" != *"," ]] ; then - tinysay "Creating pages…" + say "Creating pages…" IFS=";" for i in ${pageList} do wp post create --post_title="${i}" --post_type=page --post_status="publish" done unset IFS - tinysay "Pages created." + success "Pages created." fi } disable_comments() { - tinysay "Disabling Comments…" + say "Disabling Comments…" wp post list --format=ids | xargs wp post update --comment_status=closed wp option update default_comment_status "closed" } disable_tackbacks() { - tinysay "Disabling Trackbacks…" + say "Disabling Trackbacks…" wp post list --format=ids | xargs wp post update --ping_status=closed wp option update default_ping_status "closed" wp option update default_pingback_flag 0 diff --git a/wp_install.sh b/wp_install.sh new file mode 100755 index 0000000..2d1b12f --- /dev/null +++ b/wp_install.sh @@ -0,0 +1,303 @@ +#!/usr/bin/env bash + +# change to script directory +#cd "$(dirname "${BASH_SOURCE[0]}")" || exit 1 + +# USAGE +usage () { echo -e " +USAGE: ${0} [OPTIONS]\\n +OPTIONS:\\n +-m (optional) Monochrome output colors +-q (optional) Suppress informational messages +-h Display this usage information\\n +" ; } + +# OPTIONS +while getopts "mqh" opt ; do + case "${opt}" in + m) monochrome="yes" ;; + q) quiet="yes" ;; + h) usage ; exit 0 ;; + *) usage ; exit 1 ;; + esac +done + +# COMMON VARIABLES & FUNCTIONS +# colors +if [[ -n "${monochrome}" ]] ; then + ink_clear="\\x1b[0m" + ink_gray="\\x1b[38;5;244m" + ink_red="\\x1b[0m" + ink_green="\\x1b[0m" + ink_blue="\\x1b[0m" + ink_yellow="\\x1b[0m" + ink_purple="\\x1b[0m" +else + ink_clear="\\x1b[0m" + ink_gray="\\x1b[38;5;244m" + ink_red="\\x1b[38;5;204m" + ink_green="\\x1b[38;5;120m" + ink_blue="\\x1b[38;5;081m" + ink_yellow="\\x1b[38;5;228m" + ink_purple="\\x1b[38;5;207m" +fi + +# output +yes_no="${ink_blue}[${ink_clear} ${ink_green}yes${ink_clear} ${ink_blue}/${ink_clear} ${ink_red}no${ink_clear} ${ink_blue}]${ink_clear}" +nl () { if [[ -z "${quiet}" ]] ; then echo ; fi ; } +say () { if [[ -z "${quiet}" ]] ; then echo -e "\\n${ink_gray}${1}${ink_clear}" ; fi ; } +tinysay () { if [[ -z "${quiet}" ]] ; then echo -e "${ink_gray}${1}${ink_clear}" ; fi ; } +errsay () { echo -e "\\n${ink_red}${1}. Script aborted!${ink_clear}" ; } +err () { echo -e "\\n${ink_red}${1}${ink_clear}" ; } +tinyerr () { echo -e "${ink_red}${1}${ink_clear}" ; } +ask () { echo -en "\\n${ink_gray}${1} ${ink_clear}" ; } +askinfo () { echo -en "${ink_gray}${1} ${ink_clear}" ; read -r "${2}" ; } + +# confirm +confirm () { + ask "${1}" + read -r INPUT + case "${INPUT}" in + [yY][eE][sS] | [yY]) ;; + [nN][oO] | [nN]) say "Script aborted.\\n" && exit 0 ;; + *) confirm "${1}" ;; + esac +} + +# PRE-FLIGHT CHECKS +#if [[ ! -d ./.git ]] ; then errsay "No cloned repository found" ; exit 1 ; fi + +# VARIABLES +dirName=${PWD##*/} + +# FUNCTIONS +initiate_env_setup () { + + if ! type wp >/dev/null 2>&1 && ! type valet >/dev/null 2>&1; then + err "${ink_red}This script requires the installation of wp-cli and valet or valet plus" + tinyerr "You can install ${ink_blue}wp-cli${ink_red} using Homebrew or by visiting ${ink_purple}https://wp-cli.org" + tinyerr "You can install ${ink_blue}valet${ink_red} from ${ink_purple}https://laravel.com/docs/master/valet" + tinyerr "OR" + tinyerr "You can install ${ink_blue}valet-plus${ink_red} from ${ink_purple}https://github.com/weprovide/valet-plus" + say "Exiting script\\n" && exit 0 + fi + + say "This script is under the assumption that you're using ${ink_blue}valet-plus${ink_gray} to setup this WordPress environment." + confirm "Would you like to continue? ${yes_no}" + clear + tinysay "Starting new WordPress environment setup ..." + +} + +cache_sudo_password () { + + say "Please enter your local user password." + sudo -k ; sudo -v && tinysay "${ink_blue}OK" + +} + +collect_environment_information () { + + say "Please provide the necessary information for the new environment:" + nl + askinfo "Site name:" siteName + askinfo "Enter your TLS: " domainTLS + askinfo "Install SSL (default: yes): ${yes_no}" addSSL + askinfo "WordPress version (default: latest):" wpVersion + askinfo "Database name (wp_ will be prefixed):" dbName + askinfo "Database user name (default: root):" dbUserName + askinfo "Database user pass (default: root):" dbUserPass + askinfo "Admin user name:" adminUserName + askinfo "Admin user pass:" adminUserPass + askinfo "Admin user email:" adminUserEmail + askinfo "Install Blank Site (default: no): ${yes_no}" blankInstall + askinfo "Disable Comments (default: no): ${yes_no}" disableComments + askinfo "Disable Trackbacks (default: no): ${yes_no}" disableTrackbacks + askinfo "Create additional pages? ${yes_no}" createPages + + sslURL="https://${PWD##*/}.${domainTLS}" + nonSSLURL="http://${PWD##*/}.${domainTLS}" + + # setting defaults if values were omitted + if [[ -z "${domainTLS}" ]] ; then tinysay "You must enter a TLS. Exiting script\\n" && exit 0 ; fi + if [[ -z "${addSSL}" ]] ; then addSSL="yes" ; fi + if [[ -z "${wpVersion}" ]] ; then wpVersion="latest" ; fi + if [[ -z "${dbUserName}" ]] ; then dbUserName="root" ; fi + if [[ -z "${dbUserPass}" ]] ; then dbUserPass="root" ; fi + if [[ -z "${disableComments}" ]] ; then disableComments="no" ; fi + if [[ -z "${disableTrackbacks}" ]] ; then disableTrackbacks="no" ; fi + if [[ -z "${blankInstall}" ]] ; then blankInstall="no" ; fi + if [[ "${createPages}" =~ ^([yY][eE][sS]|[yY])+ ]] ; then create_pages ; fi + + say "The ${ink_yellow}new environment${ink_gray} will be created with the following information:" + nl + tinysay "Site name: ${ink_yellow}${siteName}" + if [[ "${addSSL}" =~ ^([yY][eE][sS]|[yY])+ ]] ; then + tinysay "URL: ${ink_yellow}${sslURL}" + else + tinysay "URL: ${ink_yellow}${nonSSLURL}" + fi + tinysay "WordPress version: ${ink_yellow}${wpVersion}" + tinysay "Database name: ${ink_yellow}wp_${dbName}" + tinysay "Database user name: ${ink_yellow}${dbUserName}" + tinysay "Database user pass: ${ink_yellow}${dbUserPass}" + tinysay "Admin user name: ${ink_yellow}${adminUserName}" + tinysay "Admin user pass: ${ink_yellow}${adminUserPass}" + tinysay "Admin user email: ${ink_yellow}${adminUserEmail}" + if [[ "${createPages}" =~ ^([yY][eE][sS]|[yY])+ ]] ; then + tinysay "Creating pages: ${ink_yellow}${pageList}" + fi + + confirm "Would you like to continue? ${yes_no}" + +} + +download_wordpress () { + + say "Downloading WordPress ..." + if [[ "${wpVersion}" == "latest" ]] ; then + if [[ "${blankInstall}" =~ ^([yY][eE][sS]|[yY])+ ]] ; then + if ! wp core download --skip-content ; then + errsay "Error during WordPress download" ; exit 1 + fi + else + if ! wp core download ; then + errsay "Error during WordPress download" ; exit 1 + fi + fi + else + if [[ "${blankInstall}" =~ ^([yY][eE][sS]|[yY])+ ]] ; then + if ! wp core download --version="${wpVersion}" --skip-content; then + errsay "Error during WordPress download" ; exit 1 + fi + else + if ! wp core download --version="${wpVersion}" ; then + errsay "Error during WordPress download" ; exit 1 + fi + fi + fi + +} + +create_wp_config () { + + say "Creating WordPress configuration file (wp-config.php) ..." + rm -rf wp-config.php + if ! wp config create --dbname=wp_"${dbName}" --dbuser="${dbUserName}" --dbpass="${dbUserPass}" + then errsay "Error during creation of wp-config.php" ; exit 1 ; fi + +} + +create_wp_database () { + + say "Creating WordPress database ..." + if ! wp db create ; then + errsay "Error during database creation" ; exit 1 + fi + +} + +build_wp_site () { + + say "Building WordPress site ..." + if ! wp core install --url="${dirName}.app" --title="${siteName}" --admin_user="${adminUserName}" --admin_password="${adminUserPass}" --admin_email="${adminUserEmail}" ; then + errsay "Error during building of site" ; exit 1 + fi + + tinysay "Changing ${ink_yellow}\"Sampe Page\"${ink_gray} to ${ink_yellow}\"Home\"${ink_gray}" + wp post update 2 --post_title=Home --post_name=home --post_type=page --post_status=publish --post_content= --post_excerpt= + + tinysay "Setting \"Home\" as the Front Page" + wp option update show_on_front 'page' + wp option update page_on_front 2 + + tinysay "Changing timezone to Chicago" + wp option update timezone_string "America/Chicago" + + if [[ "${disableComments}" =~ ^([yY][eE][sS]|[yY])+ ]] ; then disable_comments ; fi + if [[ "${disableTrackbacks}" =~ ^([yY][eE][sS]|[yY])+ ]] ; then disable_tackbacks ; fi + if [[ "${createPages}" =~ ^([yY][eE][sS]|[yY])+ ]] ; then loop_create_pages ; fi + + tinysay "Flushing permalinks" + wp cache flush + wp rewrite structure /%postname%/ + wp rewrite flush + +} + + +enable_tls_for_env () { + + if [[ "${addSSL}" =~ ^([yY][eE][sS]|[yY])+ ]] ; then + say "Enabling TLS for site ..." + if ! valet secure "${dirName}" ; then + errsay "Error while securing site" + fi + fi + +} + +setup_complete() { + say "Environment sucessfully setup." + tinysay "You may now sign in to your website." + nl + if [[ "${addSSL}" =~ ^([yY][eE][sS]|[yY])+ ]] ; then + tinysay "Front End URL: ${ink_yellow}${sslURL}" + tinysay "Back End URL: ${ink_yellow}${sslURL}/wp-admin" + else + tinysay "Front End URL: ${ink_yellow}${nonSSLURL}" + tinysay "Back End URL: ${ink_yellow}${nonSSLURL}/wp-admin" + fi + nl + tinysay "Login Credentials" + tinysay "Admin User Name: ${ink_yellow}${adminUserName}" + tinysay "Admin User Password: ${ink_yellow}${adminUserPass}" +} + +# Conditional Functions +create_pages() { + say "You can choose to create top level pages you know you'll need here, otherwise just hit enter to skip this." + say "Please separate page names with a semicolon (;) with no space after it. The ${VP_CYAN}Homepage${VP_WHITE} is already created." + say "${VP_CYAN}Example:${VP_WHITE} About Us;Contact Us;Blog ${VP_NONE}" + nl + read -r pageList +} + +loop_create_pages() { + + if [[ -n "${pageList}" || "${pageList}" != *"," ]] ; + then + tinysay "Creating pages…" + IFS=";" + for i in ${pageList} + do + wp post create --post_title="${i}" --post_type=page --post_status="publish" + done + unset IFS + tinysay "Pages created." + fi +} + +disable_comments() { + tinysay "Disabling Comments…" + wp post list --format=ids | xargs wp post update --comment_status=closed + wp option update default_comment_status "closed" +} + +disable_tackbacks() { + tinysay "Disabling Trackbacks…" + wp post list --format=ids | xargs wp post update --ping_status=closed + wp option update default_ping_status "closed" + wp option update default_pingback_flag 0 +} + +# MAIN +initiate_env_setup +cache_sudo_password +collect_environment_information +download_wordpress +create_wp_config +create_wp_database +build_wp_site +enable_tls_for_env +setup_complete \ No newline at end of file From 24295f34c186cefe18b3383869948d29f6cd8e27 Mon Sep 17 00:00:00 2001 From: Nick Makris <> Date: Thu, 29 Aug 2019 15:44:07 -0400 Subject: [PATCH 15/16] Added comments --- eqAuction.sh | 15 +++++++++++++++ new_wp/tools_install.sh | 2 ++ 2 files changed, 17 insertions(+) create mode 100644 eqAuction.sh diff --git a/eqAuction.sh b/eqAuction.sh new file mode 100644 index 0000000..28ee6b0 --- /dev/null +++ b/eqAuction.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +#Define your log directory here - easiest to symlink to your wine DIR +LOGDIR=~/eqLogs + +#Don't mess with this! +IFS=$'\n' + +while :; do + for f in `find ${LOGDIR}/eqlog* -newerct "1 minute ago"`; do + echo "Working with: $f" + curl -F "dump=$(tail -n100 $f|grep -E '[A-Za-z] auctions, ')" http://ahungry.com/aucDump.php + done + sleep 60 +done diff --git a/new_wp/tools_install.sh b/new_wp/tools_install.sh index a66b0d4..2409311 100755 --- a/new_wp/tools_install.sh +++ b/new_wp/tools_install.sh @@ -62,10 +62,12 @@ errsay() { echo -e "\\n${ink_red}${1}. Script aborted!${ink_clear}"; } sucsay() { echo -e "${ink_green}${1} successfully installed.${ink_clear}"; } err() { echo -e "\\n${ink_red}${1}${ink_clear}"; } ask() { echo -en "\\n${ink_grey}${1} ${ink_clear}"; } +# Asks for info askinfo() { echo -en "${ink_grey}${1} ${ink_clear}" read -r "${2}" } +# Get site path saysitepath() { echo -en "${ink_grey}${1}: ${ink_clear}" echo -en "${ink_blue}${path} ${ink_clear}" From d39aa80995d4b8f77482d366a5d100cb5ad77d47 Mon Sep 17 00:00:00 2001 From: Nick Makris <> Date: Thu, 29 Aug 2019 21:25:58 -0400 Subject: [PATCH 16/16] Updated various functions for WP Blade for Sage 9, creating alias files, and verifying that files exist and that the file paths are correct via Source linter. --- clique/env_install.sh | 143 +++++++++++++++++++-------------------- new_wp/tools_install.sh | 145 ++++++++++++++++++++-------------------- 2 files changed, 144 insertions(+), 144 deletions(-) diff --git a/clique/env_install.sh b/clique/env_install.sh index ce20eb5..a184302 100755 --- a/clique/env_install.sh +++ b/clique/env_install.sh @@ -10,25 +10,18 @@ OPTIONS:\\n "; } # OPTIONS -while getopts "mqh" opt; do +while getopts "mqh" opt ; do case "${opt}" in - m) monochrome="yes" ;; - q) quiet="yes" ;; - h) - usage - exit 0 - ;; - *) - usage - exit 1 - ;; + m) monochrome="yes" ;; + q) quiet="yes" ;; + h) usage ; exit 0 ;; + *) usage ; exit 1 ;; esac done # COMMON VARIABLES & FUNCTIONS # colors -if [[ -n "${monochrome}" ]]; then - ink_brew="\\xF0\x9f\x8d\xba" +if [[ -n "${monochrome}" ]] ; then ink_clear="\\x1b[0m" ink_grey="\\x1b[38;5;244m" ink_red="\\x1b[0m" @@ -37,7 +30,6 @@ if [[ -n "${monochrome}" ]]; then ink_yellow="\\x1b[0m" ink_purple="\\x1b[0m" else - ink_brew="\\xF0\x9f\x8d\xba" ink_clear="\\x1b[0m" ink_grey="\\x1b[38;5;244m" ink_red="\\x1b[38;5;204m" @@ -55,21 +47,16 @@ yuicompressor="" path="${HOME}" sitepath="${HOME}/Sites" phpmyadmin=https://www.phpmyadmin.net/downloads/phpMyAdmin-latest-english.tar.gz -nl() { if [[ -z "${quiet}" ]]; then echo; fi; } -say() { if [[ -z "${quiet}" ]]; then echo -e "\\n${ink_grey}${1}${ink_clear}"; fi; } -tinysay() { if [[ -z "${quiet}" ]]; then echo -e "${ink_grey}${1}${ink_clear}"; fi; } -errsay() { echo -e "\\n${ink_red}${1}. Script aborted!${ink_clear}"; } -sucsay() { echo -e "${ink_green}${1} successfully installed.${ink_clear}"; } -err() { echo -e "\\n${ink_red}${1}${ink_clear}"; } -ask() { echo -en "\\n${ink_grey}${1} ${ink_clear}"; } -askinfo() { - echo -en "${ink_grey}${1} ${ink_clear}" - read -r "${2}" -} -saysitepath() { - echo -en "${ink_grey}${1}: ${ink_clear}" - echo -en "${ink_blue}${path} ${ink_clear}" -} +nl () { if [[ -z "${quiet}" ]]; then echo; fi; } +say () { if [[ -z "${quiet}" ]]; then echo -e "\\n${ink_grey}${1}${ink_clear}"; fi; } +success () { if [[ -z "${quiet}" ]] ; then echo -e "\\n${ink_green}${1}${ink_clear}" ; fi ; } +tinysay () { if [[ -z "${quiet}" ]] ; then echo -e "${ink_grey}${1}${ink_clear}" ; fi ; } +errsay () { echo -e "\\n${ink_red}${1}. Script aborted!${ink_clear}"; } +sucsay () { echo -e "${ink_green}${1} successfully installed.${ink_clear}"; } +err () { echo -e "\\n${ink_red}${1}${ink_clear}"; } +ask () { echo -en "\\n${ink_grey}${1} ${ink_clear}"; } +askinfo () { echo -en "${ink_grey}${1} ${ink_clear}" ; read -r "${2}" ; } +saysitepath () { echo -en "${ink_grey}${1}: ${ink_clear}\\n${ink_blue}${path} ${ink_clear}" ; } # confirm confirm() { @@ -100,12 +87,12 @@ collect_install_parameters() { confirm "Would you like to continue? ${yes_no}" clear - askinfo "Would you like to use MySQL or mariaDB? ${mysql_maria}" dbStructure + askinfo "Would you like to use MySQL or mariaDB? mariaDB runs SQL statements quicker and uses less resources compared to MySQL, though may eventually become uncompatible with MySQL: ${mysql_maria}" dbStructure askinfo "${dbStructure} username (default: root):" dbUserName askinfo "${dbStructure} password (default: root):" dbUserPass nl - tinysay "What TLS would you like your sites to be served under? Default is ${ink_yellow}test${ink_grey}" - askinfo "${ink_red}Note${ink_grey}: Using ${ink_blue}app${ink_grey} or ${ink_blue}dev${ink_grey} will require you to run ${ink_purple}valet secure folder_name${ink_grey} before visiting the page:" getTLS + tinysay "What TLS would you like your sites to be served under? Default is ${ink_blue}test${ink_grey}" + askinfo "${ink_red}Note${ink_grey}: Using ${ink_blue}app${ink_grey} or ${ink_blue}dev${ink_grey} will require you to run ${ink_yellow}valet secure {folder_name}${ink_grey} before visiting the page:" getTLS askinfo "Install phpmyadmin? ${yes_no}: " installPhpMyAdmin askinfo "If using phpStorm, would you like to install yuicompressor for JavaScript and CSS minification watcher? ${yes_no}" getYUI @@ -127,13 +114,13 @@ collect_install_parameters() { say "${ink_green}ENVIRONMENT" tinysay "${ink_blue}Laravel Valet${ink_grey} - Local Dev Environment." - tinysay "${ink_blue}php${ink_grey}" + tinysay "${ink_blue}php${ink_grey}: ${ink_yellow}Latest Version of 7" tinysay "${ink_blue}Database${ink_grey}: ${ink_yellow}${dbStructure}" tinysay "${ink_blue}Database username${ink_grey}: ${ink_yellow}${dbUserName}" tinysay "${ink_blue}Database password${ink_grey}: ${ink_yellow}${dbUserPass}" if [[ "${installPhpMyAdmin}" != n* ]]; then - tinysay "${ink_blue}phpMyAdmin${ink_grey} - latest version" + tinysay "${ink_blue}phpMyAdmin${ink_grey}: ${latest}" fi tinysay "${ink_blue}Local site TLS${ink_grey}: ${ink_yellow}${getTLS}" nl @@ -145,6 +132,7 @@ collect_install_parameters() { if [[ "${getYUI}" != n* ]]; then tinysay "${ink_blue}YUICompressor${ink_grey}: ${latest}" fi + nl confirm "Would you like to continue? ${yes_no}" } @@ -169,8 +157,8 @@ install_homebrew_packages() { yuicompressor="yuicompressor" fi - tinysay "Installing ${ink_brew} brew packages. Please wait…" - # brew install composer node php wget sass/sass/sass ${dbStructure} ${yuicompressor} + tinysay "Installing ${ink_yellow} brew packages${ink_grey}. Please wait…" + brew install composer node php wget sass/sass/sass ${dbStructure} ${yuicompressor} brew services start ${dbStructure} tinysay "${ink_green}Install Complete!${ink_grey}" fi @@ -178,7 +166,7 @@ install_homebrew_packages() { # Check for any errors when installing brew packages brew_error_checks() { - tinysay "Checking ${ink_brew} brew for errors." + tinysay "Checking ${ink_blue}brew${ink_grey} for errors." if ! type composer >/dev/null 2>&1; then errsay "There was an error installing Composer. Please review why and report back to the script creator." @@ -227,38 +215,46 @@ brew_error_checks() { # Writes exports to ./bash_profile bash_profile_write() { - if [[ ! -e ${HOME}/.bash_profile ]]; then + if [[ ! -e "${HOME}"/.bash_profile ]]; then tinysay "Creating a .bash_profile file at ${HOME}" fi - if ! grep -q "export PATH" ${HOME}/.bash_profile; then + if ! grep -q "export PATH" "${HOME}"/.bash_profile; then tinysay "Adding export PATH to ~/.bash_profile" - echo 'export PATH' >> ${HOME}/.bash_profile + echo "export PATH" >> "${HOME}"/.bash_profile fi - if ! grep -q 'export PATH="$PATH:${HOME}/npm/bin"' ${HOME}/.bash_profile; then + if ! grep -q "export PATH=\"$PATH:${HOME}/npm/bin\"" "${HOME}"/.bash_profile; then tinysay "Adding NPM to your \$PATH" - echo 'export PATH="$PATH:${HOME}/npm/bin"' >> ${HOME}/.bash_profile + echo "export PATH=\"$PATH:${HOME}/npm/bin\"" >> "${HOME}"/.bash_profile fi - if ! grep -q 'export PATH="/usr/local/bin:$PATH"' ${HOME}/.bash_profile; then + if ! grep -q "export PATH=\"/usr/local/bin:$PATH\"" "${HOME}"/.bash_profile; then tinysay "Adding bin to your \$Path" - echo 'export PATH="/usr/local/bin:$PATH"' >> ${HOME}/.bash_profile + echo "export PATH=\"/usr/local/bin:$PATH\"" >> "${HOME}"/.bash_profile fi - if ! grep -q 'export PATH="/usr/local/sbin:$PATH"' ${HOME}/.bash_profile; then + if ! grep -q "export PATH=\"/usr/local/sbin:$PATH\"" "${HOME}"/.bash_profile; then tinysay "Adding sbin to your \$Path" - echo 'export PATH="/usr/local/sbin:$PATH"' >> ${HOME}/.bash_profile + echo "export PATH=\"/usr/local/sbin:$PATH\"" >> "${HOME}"/.bash_profile fi - if ! grep -q 'export PATH="$PATH:${HOME}/.composer/vendor/bin"' ${HOME}/.bash_profile; then + if ! grep -q "export PATH=\"$PATH:${HOME}/.composer/vendor/bin\"" "${HOME}"/.bash_profile; then tinysay "Adding Composer to ~/.bash_profile" - echo 'export PATH="$PATH:${HOME}/.composer/vendor/bin"' >> ${HOME}/.bash_profile + echo "export PATH=\"$PATH:${HOME}/.composer/vendor/bin\"" >> "${HOME}"/.bash_profile fi - + # Make an SSH Alias file + mkdir "${HOME}"/.custom_bash_files + cd "${HOME}"/.custom_bash_files || exit + cat > .alias_ssh.sh + echo "# This file can be used to set aliases for utiliing ssh for servers" > .alias_ssh.sh + echo "# Example: alias sitessh=\"ssh root@test.sandbox6.cliquedomains.com\" would create a quick tab completeion to ssh into the Sandbox 6 Digital Ocean Server." >> .alias_ssh.sh + nl + cat > .alias_commands.sh + echo "# This file can be used to set up various alias' needed to make development easier." > .alias_commands.sh - source ${HOME}/.bash_profile + source "${HOME}"/.bash_profile tinysay "Reloaded your ${ink_yellow}.bash_proflie${ink_grey}" } @@ -299,16 +295,21 @@ install_wpcli() { fi if type wp >/dev/null 2>&1; then - cd ${HOME} + cd "${HOME}" || exit mkdir .bash_completions - cd .bash_completions - if [[ -e ${HOME}/.bash_completions/wp-completion.bash ]]; then + cd .bash_completions || exit + if [[ -e "${HOME}"/.bash_completions/wp-completion.bash ]]; then curl -O https://raw.githubusercontent.com/wp-cli/wp-cli/v1.5.1/utils/wp-completion.bash - echo "source \${HOME}/.bash_completions/wp-completion.bash" >> ${HOME}/.bash_profile + echo "source \"${HOME}\"/.bash_completions/wp-completion.bash" >> "${HOME}"/.bash_profile fi fi - source ${HOME}/.bash_profile + + tinysay "Installing Blade Plugin for ${ink_yellow}WP-CLI${ink_grey}" + tinysay "This will allow you to compile, wipe, or clear the blade cache files used in Sage 9." + php -d memory_limit=-1 "$(which wp)" package install git@github.com:alwaysblank/blade-generate.git + + source "${HOME}"/.bash_profile } @@ -327,18 +328,18 @@ setup_mysql() { # Installs valet install_valet() { if ! type composer >/dev/null 2>&1; then - tinysay "Beginning the installation of laravel/valet, your dev env." + tinysay "Beginning the installation of ${ink_yellow}laravel/valet${ink_grey}, your dev env." composer global require laravel/valet if ! type valet >/dev/null 2>&1; then tinysay "Valet's downloaded, let's install it." valet install sudo valet trust - valet domain ${getTLS} - cd ${path} + valet domain "${getTLS}" + cd "${path}" || exit if [[ ! -d ${sitepath} ]]; then mkdir Sites fi - cd ${sitepath} + cd "${sitepath}" || exit valet park sucsay "You now have a Sites directory located at ${sitepath}. You can create new folders within here, and valet will serve them in your browser using the ${getTLS} as your TLS." fi @@ -347,21 +348,21 @@ install_valet() { # Installs phpmyadmin and adds a syslink to the Sites directory install_phpmyadmin() { - cd ${sitepath} + cd "${sitepath}" || exit brew install phpmyadmin ln -s /usr/local/share/phpmyadmin . valet secure phpmyadmin } # Main Script Start -# cache_sudo_password -# collect_install_parameters -# install_homebrew -# install_homebrew_packages -# brew_error_checks -# bash_profile_write -# install_npm_packages -# install_wpcli -# setup_mysql -# install_valet -# install_phpmyadmin +cache_sudo_password +collect_install_parameters +install_homebrew +install_homebrew_packages +brew_error_checks +bash_profile_write +install_npm_packages +install_wpcli +setup_mysql +install_valet +install_phpmyadmin \ No newline at end of file diff --git a/new_wp/tools_install.sh b/new_wp/tools_install.sh index 2409311..a184302 100755 --- a/new_wp/tools_install.sh +++ b/new_wp/tools_install.sh @@ -10,25 +10,18 @@ OPTIONS:\\n "; } # OPTIONS -while getopts "mqh" opt; do +while getopts "mqh" opt ; do case "${opt}" in - m) monochrome="yes" ;; - q) quiet="yes" ;; - h) - usage - exit 0 - ;; - *) - usage - exit 1 - ;; + m) monochrome="yes" ;; + q) quiet="yes" ;; + h) usage ; exit 0 ;; + *) usage ; exit 1 ;; esac done # COMMON VARIABLES & FUNCTIONS # colors -if [[ -n "${monochrome}" ]]; then - ink_brew="\\xF0\x9f\x8d\xba" +if [[ -n "${monochrome}" ]] ; then ink_clear="\\x1b[0m" ink_grey="\\x1b[38;5;244m" ink_red="\\x1b[0m" @@ -37,7 +30,6 @@ if [[ -n "${monochrome}" ]]; then ink_yellow="\\x1b[0m" ink_purple="\\x1b[0m" else - ink_brew="\\xF0\x9f\x8d\xba" ink_clear="\\x1b[0m" ink_grey="\\x1b[38;5;244m" ink_red="\\x1b[38;5;204m" @@ -55,23 +47,16 @@ yuicompressor="" path="${HOME}" sitepath="${HOME}/Sites" phpmyadmin=https://www.phpmyadmin.net/downloads/phpMyAdmin-latest-english.tar.gz -nl() { if [[ -z "${quiet}" ]]; then echo; fi; } -say() { if [[ -z "${quiet}" ]]; then echo -e "\\n${ink_grey}${1}${ink_clear}"; fi; } -tinysay() { if [[ -z "${quiet}" ]]; then echo -e "${ink_grey}${1}${ink_clear}"; fi; } -errsay() { echo -e "\\n${ink_red}${1}. Script aborted!${ink_clear}"; } -sucsay() { echo -e "${ink_green}${1} successfully installed.${ink_clear}"; } -err() { echo -e "\\n${ink_red}${1}${ink_clear}"; } -ask() { echo -en "\\n${ink_grey}${1} ${ink_clear}"; } -# Asks for info -askinfo() { - echo -en "${ink_grey}${1} ${ink_clear}" - read -r "${2}" -} -# Get site path -saysitepath() { - echo -en "${ink_grey}${1}: ${ink_clear}" - echo -en "${ink_blue}${path} ${ink_clear}" -} +nl () { if [[ -z "${quiet}" ]]; then echo; fi; } +say () { if [[ -z "${quiet}" ]]; then echo -e "\\n${ink_grey}${1}${ink_clear}"; fi; } +success () { if [[ -z "${quiet}" ]] ; then echo -e "\\n${ink_green}${1}${ink_clear}" ; fi ; } +tinysay () { if [[ -z "${quiet}" ]] ; then echo -e "${ink_grey}${1}${ink_clear}" ; fi ; } +errsay () { echo -e "\\n${ink_red}${1}. Script aborted!${ink_clear}"; } +sucsay () { echo -e "${ink_green}${1} successfully installed.${ink_clear}"; } +err () { echo -e "\\n${ink_red}${1}${ink_clear}"; } +ask () { echo -en "\\n${ink_grey}${1} ${ink_clear}"; } +askinfo () { echo -en "${ink_grey}${1} ${ink_clear}" ; read -r "${2}" ; } +saysitepath () { echo -en "${ink_grey}${1}: ${ink_clear}\\n${ink_blue}${path} ${ink_clear}" ; } # confirm confirm() { @@ -102,12 +87,12 @@ collect_install_parameters() { confirm "Would you like to continue? ${yes_no}" clear - askinfo "Would you like to use MySQL or mariaDB? ${mysql_maria}" dbStructure + askinfo "Would you like to use MySQL or mariaDB? mariaDB runs SQL statements quicker and uses less resources compared to MySQL, though may eventually become uncompatible with MySQL: ${mysql_maria}" dbStructure askinfo "${dbStructure} username (default: root):" dbUserName askinfo "${dbStructure} password (default: root):" dbUserPass nl - tinysay "What TLS would you like your sites to be served under? Default is ${ink_yellow}test${ink_grey}" - askinfo "${ink_red}Note${ink_grey}: Using ${ink_blue}app${ink_grey} or ${ink_blue}dev${ink_grey} will require you to run ${ink_purple}valet secure folder_name${ink_grey} before visiting the page:" getTLS + tinysay "What TLS would you like your sites to be served under? Default is ${ink_blue}test${ink_grey}" + askinfo "${ink_red}Note${ink_grey}: Using ${ink_blue}app${ink_grey} or ${ink_blue}dev${ink_grey} will require you to run ${ink_yellow}valet secure {folder_name}${ink_grey} before visiting the page:" getTLS askinfo "Install phpmyadmin? ${yes_no}: " installPhpMyAdmin askinfo "If using phpStorm, would you like to install yuicompressor for JavaScript and CSS minification watcher? ${yes_no}" getYUI @@ -129,13 +114,13 @@ collect_install_parameters() { say "${ink_green}ENVIRONMENT" tinysay "${ink_blue}Laravel Valet${ink_grey} - Local Dev Environment." - tinysay "${ink_blue}php${ink_grey}" + tinysay "${ink_blue}php${ink_grey}: ${ink_yellow}Latest Version of 7" tinysay "${ink_blue}Database${ink_grey}: ${ink_yellow}${dbStructure}" tinysay "${ink_blue}Database username${ink_grey}: ${ink_yellow}${dbUserName}" tinysay "${ink_blue}Database password${ink_grey}: ${ink_yellow}${dbUserPass}" if [[ "${installPhpMyAdmin}" != n* ]]; then - tinysay "${ink_blue}phpMyAdmin${ink_grey} - latest version" + tinysay "${ink_blue}phpMyAdmin${ink_grey}: ${latest}" fi tinysay "${ink_blue}Local site TLS${ink_grey}: ${ink_yellow}${getTLS}" nl @@ -147,6 +132,7 @@ collect_install_parameters() { if [[ "${getYUI}" != n* ]]; then tinysay "${ink_blue}YUICompressor${ink_grey}: ${latest}" fi + nl confirm "Would you like to continue? ${yes_no}" } @@ -171,8 +157,8 @@ install_homebrew_packages() { yuicompressor="yuicompressor" fi - tinysay "Installing ${ink_brew} brew packages. Please wait…" - # brew install composer node php wget sass/sass/sass ${dbStructure} ${yuicompressor} + tinysay "Installing ${ink_yellow} brew packages${ink_grey}. Please wait…" + brew install composer node php wget sass/sass/sass ${dbStructure} ${yuicompressor} brew services start ${dbStructure} tinysay "${ink_green}Install Complete!${ink_grey}" fi @@ -180,7 +166,7 @@ install_homebrew_packages() { # Check for any errors when installing brew packages brew_error_checks() { - tinysay "Checking ${ink_brew} brew for errors." + tinysay "Checking ${ink_blue}brew${ink_grey} for errors." if ! type composer >/dev/null 2>&1; then errsay "There was an error installing Composer. Please review why and report back to the script creator." @@ -229,38 +215,46 @@ brew_error_checks() { # Writes exports to ./bash_profile bash_profile_write() { - if [[ ! -e ${HOME}/.bash_profile ]]; then + if [[ ! -e "${HOME}"/.bash_profile ]]; then tinysay "Creating a .bash_profile file at ${HOME}" fi - if ! grep -q "export PATH" ${HOME}/.bash_profile; then + if ! grep -q "export PATH" "${HOME}"/.bash_profile; then tinysay "Adding export PATH to ~/.bash_profile" - echo 'export PATH' >> ${HOME}/.bash_profile + echo "export PATH" >> "${HOME}"/.bash_profile fi - if ! grep -q 'export PATH="$PATH:${HOME}/npm/bin"' ${HOME}/.bash_profile; then + if ! grep -q "export PATH=\"$PATH:${HOME}/npm/bin\"" "${HOME}"/.bash_profile; then tinysay "Adding NPM to your \$PATH" - echo 'export PATH="$PATH:${HOME}/npm/bin"' >> ${HOME}/.bash_profile + echo "export PATH=\"$PATH:${HOME}/npm/bin\"" >> "${HOME}"/.bash_profile fi - if ! grep -q 'export PATH="/usr/local/bin:$PATH"' ${HOME}/.bash_profile; then + if ! grep -q "export PATH=\"/usr/local/bin:$PATH\"" "${HOME}"/.bash_profile; then tinysay "Adding bin to your \$Path" - echo 'export PATH="/usr/local/bin:$PATH"' >> ${HOME}/.bash_profile + echo "export PATH=\"/usr/local/bin:$PATH\"" >> "${HOME}"/.bash_profile fi - if ! grep -q 'export PATH="/usr/local/sbin:$PATH"' ${HOME}/.bash_profile; then + if ! grep -q "export PATH=\"/usr/local/sbin:$PATH\"" "${HOME}"/.bash_profile; then tinysay "Adding sbin to your \$Path" - echo 'export PATH="/usr/local/sbin:$PATH"' >> ${HOME}/.bash_profile + echo "export PATH=\"/usr/local/sbin:$PATH\"" >> "${HOME}"/.bash_profile fi - if ! grep -q 'export PATH="$PATH:${HOME}/.composer/vendor/bin"' ${HOME}/.bash_profile; then + if ! grep -q "export PATH=\"$PATH:${HOME}/.composer/vendor/bin\"" "${HOME}"/.bash_profile; then tinysay "Adding Composer to ~/.bash_profile" - echo 'export PATH="$PATH:${HOME}/.composer/vendor/bin"' >> ${HOME}/.bash_profile + echo "export PATH=\"$PATH:${HOME}/.composer/vendor/bin\"" >> "${HOME}"/.bash_profile fi - + # Make an SSH Alias file + mkdir "${HOME}"/.custom_bash_files + cd "${HOME}"/.custom_bash_files || exit + cat > .alias_ssh.sh + echo "# This file can be used to set aliases for utiliing ssh for servers" > .alias_ssh.sh + echo "# Example: alias sitessh=\"ssh root@test.sandbox6.cliquedomains.com\" would create a quick tab completeion to ssh into the Sandbox 6 Digital Ocean Server." >> .alias_ssh.sh + nl + cat > .alias_commands.sh + echo "# This file can be used to set up various alias' needed to make development easier." > .alias_commands.sh - source ${HOME}/.bash_profile + source "${HOME}"/.bash_profile tinysay "Reloaded your ${ink_yellow}.bash_proflie${ink_grey}" } @@ -301,16 +295,21 @@ install_wpcli() { fi if type wp >/dev/null 2>&1; then - cd ${HOME} + cd "${HOME}" || exit mkdir .bash_completions - cd .bash_completions - if [[ -e ${HOME}/.bash_completions/wp-completion.bash ]]; then + cd .bash_completions || exit + if [[ -e "${HOME}"/.bash_completions/wp-completion.bash ]]; then curl -O https://raw.githubusercontent.com/wp-cli/wp-cli/v1.5.1/utils/wp-completion.bash - echo "source \${HOME}/.bash_completions/wp-completion.bash" >> ${HOME}/.bash_profile + echo "source \"${HOME}\"/.bash_completions/wp-completion.bash" >> "${HOME}"/.bash_profile fi fi - source ${HOME}/.bash_profile + + tinysay "Installing Blade Plugin for ${ink_yellow}WP-CLI${ink_grey}" + tinysay "This will allow you to compile, wipe, or clear the blade cache files used in Sage 9." + php -d memory_limit=-1 "$(which wp)" package install git@github.com:alwaysblank/blade-generate.git + + source "${HOME}"/.bash_profile } @@ -329,18 +328,18 @@ setup_mysql() { # Installs valet install_valet() { if ! type composer >/dev/null 2>&1; then - tinysay "Beginning the installation of laravel/valet, your dev env." + tinysay "Beginning the installation of ${ink_yellow}laravel/valet${ink_grey}, your dev env." composer global require laravel/valet if ! type valet >/dev/null 2>&1; then tinysay "Valet's downloaded, let's install it." valet install sudo valet trust - valet domain ${getTLS} - cd ${path} + valet domain "${getTLS}" + cd "${path}" || exit if [[ ! -d ${sitepath} ]]; then mkdir Sites fi - cd ${sitepath} + cd "${sitepath}" || exit valet park sucsay "You now have a Sites directory located at ${sitepath}. You can create new folders within here, and valet will serve them in your browser using the ${getTLS} as your TLS." fi @@ -349,21 +348,21 @@ install_valet() { # Installs phpmyadmin and adds a syslink to the Sites directory install_phpmyadmin() { - cd ${sitepath} + cd "${sitepath}" || exit brew install phpmyadmin ln -s /usr/local/share/phpmyadmin . valet secure phpmyadmin } # Main Script Start -# cache_sudo_password -# collect_install_parameters -# install_homebrew -# install_homebrew_packages -# brew_error_checks -# bash_profile_write -# install_npm_packages -# install_wpcli -# setup_mysql -# install_valet -# install_phpmyadmin \ No newline at end of file +cache_sudo_password +collect_install_parameters +install_homebrew +install_homebrew_packages +brew_error_checks +bash_profile_write +install_npm_packages +install_wpcli +setup_mysql +install_valet +install_phpmyadmin \ No newline at end of file