Last active
March 15, 2023 13:23
-
-
Save enishant/211212beeadff49aba00c0622a0f33ab to your computer and use it in GitHub Desktop.
Magento:Upgrade modules, Compile code, Deploy static content, Flush cache
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
echo "---| Set base directory path |---" | |
MAGENTO=$(basename $(pwd)) | |
cd /Applications/MAMP/htdocs/magento/$MAGENTO | |
echo "---| Set PHP base path |---" | |
PHP_BASE_PATH="/Applications/MAMP/bin/php" | |
echo "---| Updating PHP path |---" | |
if [ "$MAGENTO" == "magento1" ] || [ "$MAGENTO" == "magento2" ]; then | |
php=$PHP_BASE_PATH/php7.3.29/bin/php | |
else | |
php=$PHP_BASE_PATH/php7.4.21/bin/php | |
fi | |
echo "---| Updating local/ngrok URL |---" | |
# Reference for ngrok.php: https://gist.github.com/enishant/f80ab379c5ace81ee4a077acc5cc6185 | |
NGROK_URL=$($php ~/ngrok.php); | |
if [ -z "$NGROK_URL" ] | |
then | |
NGROK_URL="http://127.0.0.1" | |
fi | |
echo "---| Set base URL |---" | |
if [ "$MAGENTO" == "magento1" ] || [ "$MAGENTO" == "magento2" ]; then | |
BASE_URL="$NGROK_URL/magento/$MAGENTO/" | |
else | |
BASE_URL="$NGROK_URL/magento/$MAGENTO/pub/" | |
fi | |
echo "---| Updating Base url |---" | |
$php bin/magento setup:store-config:set --base-url="$BASE_URL" | |
if [ "$NGROK_URL" != "http://127.0.0.1" ]; then | |
$php bin/magento setup:store-config:set --base-url-secure="$BASE_URL" | |
fi | |
echo "---| Set memory limit |---" | |
MEMORY_LIMIT=" -dmemory_limit=-1 " | |
# Skipping Elasticsearch | |
# Reference: https://magento.stackexchange.com/a/320983/103551 | |
# echo "---| Skipping Elasticsearch |---" | |
# $php $MEMORY_LIMIT bin/magento module:disable {Magento_Elasticsearch,Magento_InventoryElasticsearch,Magento_Elasticsearch6,Magento_Elasticsearch7} | |
echo "---| Set deploy mode |---" | |
DEPLOY_MODE="developer" # default | developer | production | |
# Compile & Upgrade | |
echo "---| Compile & Upgrade |---" | |
$php $MEMORY_LIMIT bin/magento setup:di:compile | |
$php $MEMORY_LIMIT bin/magento setup:upgrade | |
# Deploy | |
echo "---| Deploy |---" | |
# $php $MEMORY_LIMIT bin/magento sampledata:deploy | |
# $php $MEMORY_LIMIT bin/magento deploy:mode:set $DEPLOY_MODE | |
# $php $MEMORY_LIMIT bin/magento setup:static-content:deploy -f | |
# Indexing & Cache | |
echo "---| Indexing & Cache |---" | |
# $php $MEMORY_LIMIT bin/magento indexer:reindex | |
# $php $MEMORY_LIMIT bin/magento indexer:reindex catalogsearch_fulltext | |
$php $MEMORY_LIMIT bin/magento cache:clean | |
$php $MEMORY_LIMIT bin/magento cache:flush | |
# Install Cron | |
echo "---| Install Cron |---" | |
# $php $MEMORY_LIMIT bin/magento cron:install | |
echo $BASE_URL |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment