#!/usr/bin/env bash

set -e # Exit on error

if [ $(find $MAGE_ROOT_DIR -maxdepth 0 -type d -empty 2>/dev/null) ]; then
    # Install Magento
    /n98-magerun.phar install                               \
        --installationFolder=$MAGE_ROOT_DIR                 \
        --magentoVersionByName="magento-mirror-1.9.2.4"     \
        --installSampleData=no                              \
        --dbHost=db                                         \
        --dbUser=magento                                    \
        --dbPass=magento                                    \
        --dbName=magento                                    \
        --useDefaultConfigParams=yes                        \
        --baseUrl="https://pwa-magento.docker/"

    chgrp -R 33 $MAGE_ROOT_DIR/media $MAGE_ROOT_DIR/var
    find $MAGE_ROOT_DIR/media $MAGE_ROOT_DIR/var -type d -exec chmod 775 {} +
    find $MAGE_ROOT_DIR/media $MAGE_ROOT_DIR/var -type f -exec chmod 664 {} +

    cd $MAGE_ROOT_DIR
    modman init
    modman link /src
fi

cd $MAGE_ROOT_DIR
modman deploy src

magerun sys:setup:run


#!/usr/bin/env bash

set -e # Exit on error

if [ $(find $MAGE_ROOT_DIR -maxdepth 0 -type d -empty 2>/dev/null) ]; then
    # Install Magento
    php -dmemory_limit=1024M -f /n98-magerun.phar install   \
        --installationFolder=$MAGE_ROOT_DIR                 \
        --magentoVersionByName="magento-mirror-1.9.2.4"     \
        --installSampleData=no                              \
        --dbHost=db                                         \
        --dbUser=magento                                    \
        --dbPass=magento                                    \
        --dbName=magento                                    \
        --useDefaultConfigParams=yes                        \
        --baseUrl="https://pwa-magento.docker/"

    chgrp -R 33 $MAGE_ROOT_DIR/media $MAGE_ROOT_DIR/var
    find $MAGE_ROOT_DIR/media $MAGE_ROOT_DIR/var -type d -exec chmod 775 {} +
    find $MAGE_ROOT_DIR/media $MAGE_ROOT_DIR/var -type f -exec chmod 664 {} +

    cd $MAGE_ROOT_DIR
    modman init
    modman link /src
fi

cd $MAGE_ROOT_DIR
modman deploy src

magerun sys:setup:run

Increase memory for Magerun install in case people decide to install sample data.
Increase memory for Magerun install in case people decide to install sample data.

Sample data is a big download so will die after 10 minutes. Increasing memory
out of the box will cause less pain down the line for people despite installing
sample data being disabled by default.
