Skip to content

Instantly share code, notes, and snippets.

@bluk
Last active August 29, 2015 14:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bluk/85bf23fa77b206540331 to your computer and use it in GitHub Desktop.
Save bluk/85bf23fa77b206540331 to your computer and use it in GitHub Desktop.
Sample Magento 2 Development Environment Reinstall Script
#!/bin/bash
# The MIT License (MIT)
#
# Copyright (c) 2015 Bryant Luk
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
DATABASE_NAME=magento2
DATABASE_USERNAME=root
DATABASE_PASSWORD=password
ADMIN_EMAIL=admin@example.com
ADMIN_USERNAME=admin
ADMIN_PASSWORD=123123q
BASE_URL=http://magento.loc/
bin/magento setup:uninstall --no-interaction
mysql -u $DATABASE_USERNAME --password=$DATABASE_PASSWORD -e "drop database $DATABASE_NAME;"
mysql -u $DATABASE_USERNAME --password=$DATABASE_PASSWORD -e "create database $DATABASE_NAME;"
rm -rf var/*
rm -rf pub/media/*
rm app/etc/config.php
rm app/etc/env.php
rm -rf pub/static/*
rm -rf pub/opt/*
rm -rf pub/errors/*
git checkout -- pub
# Should really do a chown to the right user
chmod -R a+wX var
chmod -R a+wX app/etc
chmod -R a+wX pub
composer install
php bin/magento setup:install \
--db-host=127.0.0.1 \
--db-name=$DATABASE_NAME \
--db-user=$DATABASE_USERNAME \
--db-password=$DATABASE_PASSWORD \
--base-url=$BASE_URL \
--language=en_US \
--timezone=America/Chicago \
--currency=USD \
--admin-user=$ADMIN_USERNAME \
--admin-password=$ADMIN_PASSWORD \
--admin-email=$ADMIN_EMAIL \
--admin-firstname=Jane \
--admin-lastname=Smith
--cleanup-database \
--backend-frontname=backend \
--use-rewrites=1
# --use_sample_data=1
# Should really do a chown to the right user
chmod -R a+wX var
chmod -R a+wX app/etc
chmod -R a+wX pub
rm -rf dev/tests/integration/tmp/*
rm -rf dev/tests/unit/tmp/*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment