Created
July 21, 2023 00:41
-
-
Save payrequestio/b15562c635c5e41f44e1c424ef009740 to your computer and use it in GitHub Desktop.
Magento 2 clean up
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
# Loop through all user directories in /home | |
for user_directory in /home/*; do | |
if [[ -d "$user_directory" ]]; then | |
# Loop through all domain directories in the user directory | |
for domain_directory in "$user_directory"/domains/*; do | |
if [[ -d "$domain_directory" ]]; then | |
# Check if the public_html directory exists | |
public_html="$domain_directory/public_html" | |
if [[ -d "$public_html" ]]; then | |
# Check if the public_html directory contains a Magento 2 installation | |
if [[ -f "$public_html/app/etc/env.php" && -d "$public_html/vendor/magento/module-store" ]]; then | |
echo "Magento 2 installation found in: $public_html" | |
# Empty Magento caches | |
MAGENTO2_CACHE="yes" | |
if [[ "$MAGENTO2_CACHE" == "yes" ]]; then | |
echo "Emptying Magento 2 caches..." | |
# Get the highest PHP version from DirectAdmin configuration | |
php_version=$(ls -1 /usr/local/directadmin/data/users/"$(basename "$user_directory")"/php/php-fpm*.conf | awk -F'php-fpm|.conf' '{print $2}' | sort -nr | head -1) | |
php_path="/usr/local/php$php_version/bin/php" | |
# Execute the cache flush command for the Magento 2 installation using the correct PHP version | |
"$php_path" "$public_html/bin/magento" cache:flush | |
wait $! | |
fi | |
fi | |
fi | |
fi | |
done | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment