Skip to content

Instantly share code, notes, and snippets.

@luizventurote
Last active December 4, 2019 08:38
Show Gist options
  • Save luizventurote/83fddff8188851a117c6ead2c3ac4b4f to your computer and use it in GitHub Desktop.
Save luizventurote/83fddff8188851a117c6ead2c3ac4b4f to your computer and use it in GitHub Desktop.
Bash script to install a Magento store with sample data automatically using Valet Plus and n98-magerun.
#!/usr/bin/env bash
folderName=${PWD##*/}
magentoUser="MAGENTO_PUBLIC_KEY"
magentoPassword="MAGENTO_SECRET_KEY"
n98-magerun2.phar install --dbHost="localhost" --dbUser="root" --dbPass="root" --dbName="${folderName}" --installationFolder="magento-folder" --installSampleData=yes --baseUrl="http://${folderName}.test/"
mv magento-folder/* .
rm -r magento-folder
composer update
echo "{\"http-basic\": {\"repo.magento.com\": {\"username\": \"${magentoUser}\",\"password\": \"${magentoPassword}\"}}}" >> auth.json
php bin/magento sampledata:deploy
php bin/magento setup:upgrade
echo "UPDATE core_config_data SET value='0' WHERE path='web/secure/use_in_frontend';" >> update.sql
echo "UPDATE core_config_data SET value='en_US' WHERE path='general/locale/code';" >> update.sql
echo "UPDATE core_config_data SET value='0' WHERE path='dev/static/sign';" >> update.sql
echo "UPDATE core_config_data SET value='http://${folderName}.test' WHERE path='web/secure/base_url';" >> update.sql
mysql -uroot -proot ${folderName} < update.sql
rm update.sql
php bin/magento admin:user:create --admin-firstname luiz --admin-lastname venturote --admin-email [email protected] --admin-user luiz --admin-password admin123
php bin/magento cache:disable layout
php bin/magento cache:disable block_html
php bin/magento cache:disable full_page
valet open
echo "Done 🚀"
@luizventurote
Copy link
Author

To run this script on any folder, do this on mac OS: sudo cp valet-sample-magento.sh /usr/local/bin.

@luizventurote
Copy link
Author

Set the right permissions before if necessary: chmod +x ./valet-sample-magento.sh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment