Skip to content

Instantly share code, notes, and snippets.

@matthewhaworth
Last active January 1, 2016 06:09
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matthewhaworth/bfc300ecb5a75618d0d5 to your computer and use it in GitHub Desktop.
Save matthewhaworth/bfc300ecb5a75618d0d5 to your computer and use it in GitHub Desktop.
Magento Install Script
#!/bin/sh
DEFAULT_MAGENTO_VERSION=1.7.0.2
DEFAULT_MAGE_URL="http://127.0.0.1/"
if [ -z $1 ] # Magento version
then
read -p "Choose Magento version ($DEFAULT_MAGENTO_VERSION): " MAGENTO_VERSION
if [ -z "$MAGENTO_VERSION" ]
then
MAGENTO_VERSION=$DEFAULT_MAGENTO_VERSION
MAGENTO_VERSION_RAW=$(echo $MAGENTO_VERSION | tr -d '.')
fi
else
MAGENTO_VERSION=$1
fi
if [ -z $2 ] # Installation path
then
read -p "Choose installation path ($(pwd)): " INSTALL_PATH
if [ -z "$INSTALL_PATH" ]
then
INSTALL_PATH=$(pwd)
fi
else
INSTALL_PATH=$2
fi
if [ -z $3 ] # Magento URL
then
read -p "Choose Magento url ($DEFAULT_MAGE_URL): " MAGE_URL
if [ -z "$MAGE_URL" ]
then
MAGE_URL=$DEFAULT_MAGE_URL
fi
else
MAGE_URL=$3
fi
if [ ! -d $INSTALL_PATH ]
then
mkdir -p $INSTALL_PATH
fi
cd $INSTALL_PATH
wget --quiet http://www.magentocommerce.com/downloads/assets/$MAGENTO_VERSION/magento-$MAGENTO_VERSION.tar.gz
tar -zxvf magento-$MAGENTO_VERSION.tar.gz
if [ "$MAGENTO_VERSION_RAW" -lt 1610 ]
then
wget --quiet http://www.magentocommerce.com/downloads/assets/1.2.0/magento-sample-data-1.2.0.tar.gz
tar -zxvf magento-sample-data-1.2.0.tar.gz
mv magento-sample-data-1.2.0/media/* magento/media/
mv magento-sample-data-1.2.0/magento-sample-data-1.2.0.sql magento/data.sql
else
wget --quiet http://www.magentocommerce.com/downloads/assets/1.6.1.0/magento-sample-data-1.6.1.0.tar.gz
tar -zxvf magento-sample-data-1.6.1.0.tar.gz
mv magento-sample-data-1.6.1.0/media/* magento/media/
mv magento-sample-data-1.6.1.0/magento_sample_data_for_1.6.1.0.sql magento/data.sql
fi
mv magento/* magento/.htaccess .
chmod -R o+w media
DB_NAME=$(pwd | tr -d '/')
mysql -h localhost -uroot -e "DROP DATABASE $DB_NAME"
mysql -h localhost -uroot -e "CREATE DATABASE $DB_NAME"
mysql -h localhost -uroot $DB_NAME < data.sql
php -f install.php -- \
--license_agreement_accepted "yes" \
--locale "en_GB" \
--timezone "Europe/London" \
--default_currency "GBP" \
--db_host "localhost" \
--db_name "$DB_NAME" \
--db_user "root" \
--db_pass "" \
--use_rewrites "yes" \
--use_secure "no" \
--secure_base_url "" \
--use_secure_admin "no" \
--admin_firstname "codepool" \
--admin_lastname "codepool" \
--admin_email "jenkins@codepool.co.uk" \
--admin_username "codepool" \
--admin_password "codepool123" \
--url "$MAGE_URL"
touch var/.htaccess | mkdir app/etc
chmod o+w var var/.htaccess app/etc
rm -rf downloader/pearlib/cache/* downloader/pearlib/download/*
rm -rf magento/ magento-sample-data-1.6.1.0/
rm -rf magento-downloader-1.7.0.0.tar.gz magento-sample-data-1.6.1.0.tar.gz data.sql
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment