Skip to content

Instantly share code, notes, and snippets.

@rootindex
Created April 13, 2016 14:12
Show Gist options
  • Save rootindex/deaa9c2d950fa0dcc701b798ead556c1 to your computer and use it in GitHub Desktop.
Save rootindex/deaa9c2d950fa0dcc701b798ead556c1 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
function get_mage_path {
local result=${PWD##*/}
local ret='./'
if [ "$result" = "var" ]; then
local ret='../';
fi
if [ "$result" = "log" ]; then
local ret='../../';
fi
echo "$ret";
}
function is_magento_one {
local ret=0
[ ! -f "$(get_mage_path)app/Mage.php" ] || { local ret=1; }
echo "$ret"
}
function is_magento_two {
local ret=0
[ ! -f "$(get_mage_path)app/bootstrap.php" ] || { local ret=1; }
echo "$ret"
}
if [ $(is_magento_one) -eq 1 ]; then
echo "[*] Clearing Magento 1 Caches...";
rm -rf $(get_mage_path)var/cache/*
rm -rf $(get_mage_path)var/full_page_cache/*
rm -rf $(get_mage_path)media/css/*
rm -rf $(get_mage_path)media/css_secure/*
rm -rf $(get_mage_path)media/js/*
exit 1;
fi
if [ $(is_magento_two) -eq 1 ]; then
echo "[*] Clearing Magento 2 Caches...";
rm -rf $(get_mage_path)pub/static/frontend/*
rm -rf $(get_mage_path)var/generation/*
rm -rf $(get_mage_path)var/view_preprocessed/*
rm -rf $(get_mage_path)var/page_cache/*
rm -rf $(get_mage_path)var/cache/*
exit 1;
fi
echo "[-] Magento installation not detected, please change directory!";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment