diff --git a/README.markdown b/README.markdown index e4f2003..fa4e8b2 100644 --- a/README.markdown +++ b/README.markdown @@ -190,6 +190,9 @@ This is how it looks on my VM: ## Changelog +### v0.3.1 +* Cache downloaded archive files for faster creation of a new shop (directory configurable via MAGE_DOWNLOAD_DIR) + ### v0.3 * Added command line parameters for automatic installation diff --git a/config.conf.sample b/config.conf.sample index f5040d1..e6c6082 100644 --- a/config.conf.sample +++ b/config.conf.sample @@ -1,3 +1,4 @@ +MAGE_DOWNLOAD_DIR="/tmp/MageSpawner/" # Directory in which downloaded Magento files can be stored MAGE_DOMAIN="magentoshops.vm" # The shops will be created under this subdomain MAGE_DEFAULT_NAME="shop" # Preset for the shop name. The shop name is used # as part of the domain, directory and database name. diff --git a/install b/install index b4932b8..14b48e8 100755 --- a/install +++ b/install @@ -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" +version="0.3.1" usage="\ MageSpawner (v$version) @@ -136,6 +136,24 @@ init_spawner () return 0 } +########################### +## Get Magento archive file + +get_magento_archive_file () +{ + if [[ ! -f $MAGE_DOWNLOAD_PATH ]]; then + mkdir -p ${MAGE_DOWNLOAD_DIR} + echo -e "Downloading Magento package..." + if [[ $WGET != "" ]]; then + wget -O $MAGE_DOWNLOAD_PATH $MAGE_DOWNLOAD_URL + elif [[ $CURL != "" ]]; then + curl $MAGE_DOWNLOAD_URL -o $MAGE_DOWNLOAD_PATH + fi + echo -e "Package downloaded.\n" + fi + return 0; +} + ########################### ## Get Magento download URL @@ -332,25 +350,17 @@ MAGE_SECURE_URL="http://${MAGE_SHOPDOMAIN}" MAGE_DOWNLOAD_FILENAME=$(basename $MAGE_DOWNLOAD_URL) DB_NAME="${DB_NAMEPREFIX}${MAGE_NAME}" DB_SQL="CREATE DATABASE IF NOT EXISTS ${DB_NAME} CHARACTER SET utf8 COLLATE utf8_general_ci;" +MAGE_DOWNLOAD_PATH="${MAGE_DOWNLOAD_DIR}${MAGE_DOWNLOAD_FILENAME}" echo -e "Thanks, the required information was provided. The installation will now begin.\n" cd $MAGE_BASE_DIR -echo -e "Downloading Magento package..." - -if [[ $WGET != "" ]]; then - wget $MAGE_DOWNLOAD_URL -elif [[ $CURL != "" ]]; then - curl -O $MAGE_DOWNLOAD_URL -fi - -echo -e "Package downloaded.\n" +get_magento_archive_file echo "Unpacking package and setting permissions." -tar -zxf $MAGE_DOWNLOAD_FILENAME +tar -zxf $MAGE_DOWNLOAD_PATH mv magento/ "$MAGE_SHOPDOMAIN"/ -rm -f $MAGE_DOWNLOAD_FILENAME cd "$MAGE_SHOPDOMAIN"/ $CMDCHMOD $LINUX_PERM_WRITABLE_FOLDERS . app/etc var/ media/ echo -e "Package unpacked and permssions set.\n"