Skip to content

Instantly share code, notes, and snippets.

@spolischook
Last active July 25, 2017 13:42
Show Gist options
  • Save spolischook/eeacff7de1a3da6f1100490097951560 to your computer and use it in GitHub Desktop.
Save spolischook/eeacff7de1a3da6f1100490097951560 to your computer and use it in GitHub Desktop.
Oro install application
#!/bin/bash
APPLICATION_URL=$1;
ENVIRORMENT=${2:-prod};
[[ $ENVIRORMENT = prod ]] && CONFIG_SUFFIX="" || CONFIG_SUFFIX="_"$ENVIRORMENT;
COMPOSER=dev.json composer install --prefer-dist --no-suggest --optimize-autoloader --no-interaction
SECONDS=0;
rm -rf app/cache/prod app/cache/test app/cache/dev app/cache/Temp
DB_RIVER=$(sed -n -e 's/^.*database_driver: //p' app/config/parameters${CONFIG_SUFFIX}.yml);
DB=$(sed -n -e 's/^.*database_name: //p' app/config/parameters${CONFIG_SUFFIX}.yml);
DB_HOST=$(sed -n -e 's/^.*database_host: //p' app/config/parameters${CONFIG_SUFFIX}.yml);
DB_USER=$(sed -n -e 's/^.*database_user: //p' app/config/parameters${CONFIG_SUFFIX}.yml);
DB_PASS=$(sed -n -e 's/^.*database_password: //p' app/config/parameters${CONFIG_SUFFIX}.yml);
if [ "$DB_RIVER" == "pdo_mysql" ]; then
MYSQL_PWD="$DB_PASS";
mysql -e "drop database $DB;" -u $DB_USER || true;
mysql -e "create database $DB;" -u $DB_USER;
elif [ "$DB_RIVER" == "pdo_pgsql" ]; then
PGPASSWORD=$DB_PASS dropdb --host=$DB_HOST --username=$DB_USER $DB || true;
PGPASSWORD=$DB_PASS createdb --host=$DB_HOST --username=$DB_USER --owner=$DB_USER --template=template0 $DB
else
echo "Unkown database driver: "$DB_RIVER;
exit 1;
fi
sed -i -e 's/installed: .*$/installed: null/g' app/config/parameters${CONFIG_SUFFIX}.yml
app/console oro:install --drop-database --user-name=admin \
--user-email=admin@example.com --user-firstname=John \
--user-lastname=Doe --user-password=admin --organization-name=ORO \
--env=$ENVIRORMENT --sample-data=n --timeout=3000 \
--application-url=$APPLICATION_URL;
duration=$SECONDS;
echo $(date -u -d @"$duration" +'%-Mm %-Ss elapsed.');

Oro product install script

How to use

Put this script in your bin directory. It's highly recommended to have bin directory in your home directory.

First (url) argument is mandatory

oroinstall http://dev-platform.local

Second argument can be a envirorment (prod by default)

oroinstall http://dev-platform.local test

How it works

Line What it do
3 Get URL as first argument. Application URL should be provided to correct install
4-5 Get envirorment as second argument. By default it's prod
6 Install composer dependencies
7 SECONDS env variable seted to null for mesure the time of install execution
8 Remove old production cache and Temp directory from last failed behat execution
10-14 Get parameters from parameters.yml of your current application
16-22 Remove and create database
28 Set installed flag in parameters.yml to null
30-34 Install application
36-37 Mesure and echo time execution
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment