Permalink
Browse files

v0.3.3. Added option --mageshopcode to remove.

  • Loading branch information...
1 parent d18f43e commit 58f96192f0ed81b3d5a280fde859eb2e9e16fe72 @mzeis committed Sep 26, 2013
Showing with 73 additions and 17 deletions.
  1. +5 −0 README.markdown
  2. +1 −1 install
  3. +67 −16 remove
View
@@ -188,8 +188,13 @@ This is how it looks on my VM:
Shop was deleted successfully. Please delete vhost entries and host config as needed.
+If you know the shopcode, you also can call `./remove --mageshopcode [code]`, e.g. `./remove --mageshopcode test`.
+
## Changelog
+### v0.3.3
+* Added Option --mageshopcode to remove
+
### v0.3.2
* Added Magento CE 1.8.0.0
View
@@ -20,7 +20,7 @@
# - The following commands must be locatable in your $PATH
# basename command mysql php sed tar wget (or curl)
-version="0.3.2"
+version="0.3.3"
usage="\
MageSpawner (v$version)
View
@@ -19,9 +19,9 @@
# - bash
# - The following executables must be locatable in your $PATH
# mysql
-#
+#
-version="0.2.1"
+version="0.3.3"
usage="\
MageSpawner Remover (v$version)
@@ -40,6 +40,7 @@ Options:
--help display this help message
--usage display this help message
--version display the version of this script
+ --mageshopcode [code] code of the shop to be deleted
Get more information at
http://matthias-zeis.com"
@@ -59,8 +60,71 @@ elif [ "$1" = "--version" ]; then
fi
###########################
+## Parse the arguments
+
+parse_arguments ()
+{
+ while :
+ do
+ case $1 in
+ -h | --help | --usage | -\?)
+ echo "$usage"
+ exit 0
+ ;;
+ --mageshopcode)
+ MAGE_SHOP_CODE=$2
+ shift 2
+ ;;
+ --) # End of all options
+ shift
+ break
+ ;;
+ -*)
+ echo "WARN: Unknown option (ignored): $1" >&2
+ shift
+ ;;
+ *) # no more options. Stop while loop
+ break
+ ;;
+ esac
+ done
+
+ return 0
+}
+
+###########################
+## Get Magento shop (= subdomain) name.
+
+get_mage_name ()
+{
+ if [[ -z "$MAGE_SHOP_CODE" ]]; then
+
+ echo "Which shop do you want to uninstall? Provide only the subdomain part of the domains provided."
+ ls -1 ${MAGE_BASE_DIR}
+
+ while true; do
+ read -p "Shop code: " MAGE_SHOP_CODE
+ MAGE_SHOP_DIR="${MAGE_BASE_DIR}${MAGE_SHOP_CODE}.${MAGE_DOMAIN}"
+
+ if [ -d "${MAGE_SHOP_DIR}" ]; then
+ break;
+ else
+ break;
+ echo "Shop does not exist. Please retry."
+ fi
+ done
+ else
+ MAGE_SHOP_DIR="${MAGE_BASE_DIR}${MAGE_SHOP_CODE}.${MAGE_DOMAIN}"
+ fi
+
+ return 0
+}
+
+###########################
## Main script
+parse_arguments "$@"
+
echo -e "Welcome to the Magento uninstall script.\n"
if [[ ! -f ${0%/*}/config.conf ]]; then
@@ -76,20 +140,7 @@ else
CMDRM="rm"
fi
-echo "Which shop do you want to uninstall? Provide only the subdomain part of the domains provided."
-ls -1 ${MAGE_BASE_DIR}
-
-while true; do
- read -p "Shop code: " MAGE_SHOP_CODE
- MAGE_SHOP_DIR="${MAGE_BASE_DIR}${MAGE_SHOP_CODE}.${MAGE_DOMAIN}"
-
- if [ -d "${MAGE_SHOP_DIR}" ]; then
- break;
- else
-break;
- echo "Shop does not exist. Please retry."
- fi
-done
+get_mage_name
DB_NAME="${DB_NAMEPREFIX}${MAGE_SHOP_CODE}"
DB_SQL="DROP DATABASE ${DB_NAME};"

0 comments on commit 58f9619

Please sign in to comment.