This repository has been archived by the owner on Apr 13, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsetup.sh
62 lines (46 loc) · 2.16 KB
/
setup.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/bin/bash
set -e
set -x
TMPNAME=`openssl rand -base64 32 | tr -cd '[:alnum:]' | head -c8`;
if [ -z $MAGENTO_DB_HOST ]; then MAGENTO_DB_HOST="localhost"; fi
if [ -z $MAGENTO_DB_PORT ]; then MAGENTO_DB_PORT="3306"; fi
if [ -z $MAGENTO_DB_USER ]; then MAGENTO_DB_USER="root"; fi
if [ -z $MAGENTO_DB_PASS ]; then MAGENTO_DB_PASS=""; fi
if [ -z $MAGENTO_DB_ALLOWSAME ]; then MAGENTO_DB_ALLOWSAME="0"; fi
if [ -z $MAGENTO_DB_NAME ]; then
MAGENTO_DB_NAME="magento_${TMPNAME}";
fi
CURRENT_DIR=`pwd`
BUILDENV="/tmp/magento.${TMPNAME}"
TOOLS="${CURRENT_DIR}/tools"
PUBLIC_DIR="${BUILDENV}/public/"
COMPOSER_HOME="$HOME/.config/composer/vendor/bin/"
mkdir -p "${TOOLS}"
mkdir -p "${PUBLIC_DIR}"
# Remove any previously installed composer packages to prevent installation conflicts.
rm -rfv ~/.composer/
composer global require n98/magerun colinmollenhour/modman phpunit/phpunit:4.8.35
echo "Using build directory ${BUILDENV}"
echo "Installing Magento version ${MAGENTO_VERSION}"
# Create main database
MYSQLPASS=""
if [ ! -z $MAGENTO_DB_PASS ]; then MYSQLPASS="-p${MAGENTO_DB_PASS}"; fi
mysql -u${MAGENTO_DB_USER} ${MYSQLPASS} -h${MAGENTO_DB_HOST} -P${MAGENTO_DB_PORT} -e "DROP DATABASE IF EXISTS \`${MAGENTO_DB_NAME}\`; CREATE DATABASE \`${MAGENTO_DB_NAME}\`;"
${COMPOSER_HOME}n98-magerun install \
--dbHost="${MAGENTO_DB_HOST}" --dbUser="${MAGENTO_DB_USER}" --dbPass="${MAGENTO_DB_PASS}" --dbName="${MAGENTO_DB_NAME}" --dbPort="${MAGENTO_DB_PORT}" \
--installSampleData=no \
--useDefaultConfigParams=yes \
--magentoVersionByName="${MAGENTO_VERSION}" \
--installationFolder="${PUBLIC_DIR}" \
--baseUrl="http://magento.local/" || { echo "Installing Magento failed"; exit 1; }
mkdir -p "${PUBLIC_DIR}/.modman/project"
cp -rf . "${PUBLIC_DIR}/.modman/project"
cd "${PUBLIC_DIR}"
${COMPOSER_HOME}modman deploy-all
${COMPOSER_HOME}n98-magerun config:set dev/template/allow_symlink 1
${COMPOSER_HOME}n98-magerun sys:setup:run
cd "${PUBLIC_DIR}/.modman/project";
${COMPOSER_HOME}phpunit
mysql -u${MAGENTO_DB_USER} ${MYSQLPASS} -h${MAGENTO_DB_HOST} -P${MAGENTO_DB_PORT} -e "DROP DATABASE IF EXISTS \`${MAGENTO_DB_NAME}\`;"
echo "Deleting ${BUILDENV}"
rm -rf "${BUILDENV}"