From 9317c72d5235f0cba01474d3ef147caf60d88a6c Mon Sep 17 00:00:00 2001 From: Chuck Scott Date: Fri, 28 Oct 2016 14:51:36 -0400 Subject: [PATCH] Additional refinement of setup script. Now making sure that the sample add-on is not detected as a WordPress plugin till setup is complete. --- index.php => SAMPLE_index.php | 0 SETUP_SCRIPT | 45 +++++++++++++++++++++++++---------- 2 files changed, 33 insertions(+), 12 deletions(-) rename index.php => SAMPLE_index.php (100%) diff --git a/index.php b/SAMPLE_index.php similarity index 100% rename from index.php rename to SAMPLE_index.php diff --git a/SETUP_SCRIPT b/SETUP_SCRIPT index e921877..c9311ec 100755 --- a/SETUP_SCRIPT +++ b/SETUP_SCRIPT @@ -9,6 +9,19 @@ if [ "$THISDIR" != "." ] ; then echo "This script MUST be run from the directory where it resides. - Exiting..." fi +# Make sure the current directory is not the standard sample add-on slug name +THISDIR=${PWD##*/} +if [ "$slugString" = "glm-member-db-sample" ] ; then + echo " +The current directory name must not be 'glm-members-db-sample'! +Please clone this add-on to a new directory name before running this script. +" + exit +fi + +# Default the slug string to the name of this directory (WordPress standard) +slugString=$THISDIR + :' Strings that are replaced @@ -29,10 +42,10 @@ okToProceed="" while [ "$okToProceed" != "Yes" ] ; do - while [ "$descrName" = "" ] || \ + while [ "$slugString" = "" ] || \ + [ "$descrName" = "" ] || \ [ "$shortName" = "" ] || \ [ "$descrString" = "" ] || \ - [ "$slugString" = "" ] || \ [ "$definedPrefix" = "" ] || \ [ "$camelcasePrefix" = "" ] || \ [ "$databaseEnable" = "" ] || \ @@ -45,26 +58,31 @@ while [ "$okToProceed" != "Yes" ] ; do New GLM Associate Add-On Setup ------------------------------ " - read -e -i "$descrName" -p "Descriptive name (eg Gaslight Media Members Database Sample) : " descrName - read -e -i "$shortName" -p "Short name (eg Sample) : " shortName - read -e -i "$descrString" -p "Description (eg Gaslight Media Members Database Sample) : " descrString - read -e -i "$slugString" -p "Slug string (eg glm-member-db-sample) : " slugString - read -e -i "$definedPrefix" -p "Defined param prefix (eg GLM_MEMBERS_SAMPLE) : " definedPrefix - read -e -i "$camelcasePrefix" -p "CamelCase prefix (eg glmMembersSample) : " camelcasePrefix - read -e -i "$databaseEnable" -p "Enable Add-On DB tables (Yes/No) : " databaseEnable + read -e -i "$slugString" -p "Slug string.................(eg glm-member-db-sample)....................: " slugString + read -e -i "$descrName" -p "Descriptive name............(eg Gaslight Media Members Database Sample)..: " descrName + read -e -i "$shortName" -p "Short name..................(eg Sample)..................................: " shortName + read -e -i "$descrString" -p "Description.................(eg This is a sample add-on.)................: " descrString + read -e -i "$definedPrefix" -p "Defined param prefix........(eg GLM_MEMBERS_SAMPLE)......................: " definedPrefix + read -e -i "$camelcasePrefix" -p "CamelCase prefix............(eg glmMembersSample)........................: " camelcasePrefix + read -e -i "$databaseEnable" -p "Enable Add-On DB tables.....(Yes/No).....................................: " databaseEnable done echo " + Slug string........................: $slugString Descriptive name...................: $descrName Short name.........................: $shortName Description........................: $descrString - Slug string........................: $slugString Defined param prefix...............: $definedPrefix CamelCase prefix...................: $camelcasePrefix Add-on will have Database tables...: $databaseEnable " read -p "Is this all OK? (Yes/No): " okToProceed + + if [ "$slugString" != "$THISDIR" ] ; then + echo + read -p "The slug string does not match the name of this directory. Are you sure you want to continue? (Yes/No): " okToProceed + fi done @@ -100,10 +118,10 @@ find . \( -name '*.phtml' -o -name '*.php' -o -name '*.inc' -o -name '*.txt' \) # If add-on is contributing database tables if [ "$databaseEnable" = "Yes" ] ; then echo "Enabling database support for this add-on ..." - sed -i "s/{databaseEnable}//g" index.php + sed -i "s/{databaseEnable}//g" SAMPLE_index.php else echo "Dissabling database support for this add-on ..." - sed -i "s|{databaseEnable}|//|g" index.php + sed -i "s|{databaseEnable}|//|g" SAMPLE_index.php fi echo "Removing other sample code and extraneous files ..." @@ -116,6 +134,9 @@ rm -Rf views/admin/info rm -Rf views/admin/members rm -Rf views/admin/sample +echo "Enabling Add-on ..." +mv SAMPLE_index.php index.php + echo "Setup is complete, now removing this script ..." rm SETUP_SCRIPT -- 2.17.1