Last active
November 7, 2022 20:56
-
-
Save efann/568192dc3f4e363d0afb15976e79e5ac to your computer and use it in GitHub Desktop.
Run updates for all WordPress and Drupal sites under /var/www
This file contains hidden or 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 | |
# License: Eclipse Public License - v 2.0 (https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html) | |
# Updated on November 7, 2022 | |
if [[ $EUID -eq 0 ]] | |
then | |
echo -e "\nThis script may not be run as root. Exiting. . . .\n\n" | |
exit 1 | |
fi | |
# From https://stackoverflow.com/questions/3976362/bash-scripts-requiring-sudo-password | |
# Force asking for the password, so you don't have to wait till running the below external scripts. | |
if [[ ! $(sudo echo 0) ]]; then | |
echo -e "sudo password was not correct. Exiting. . . .\n\n" | |
exit; | |
fi | |
WPCLI="$(which wp-cli)" | |
DRUSH="$(which drush)" | |
if [ -z "$WPCLI" ] | |
then | |
echo -e "\nThis script needs wp-cli installed. You can find more information here: http://wp-cli.org/. Exiting. . . .\n\n" | |
exit 1 | |
fi | |
if [ -z "$DRUSH" ] | |
then | |
echo -e "\nThis script needs drush installed. You can find more information here: https://docs.drush.org/en/master/install/. Exiting. . . .\n\n" | |
exit 1 | |
fi | |
WP_REFRESH="$(which wordpress-refresh.sh)" | |
DRUPAL_REFRESH="$(which drupal-refresh.sh)" | |
lcWebSites="/var/www/" | |
pushd "$lcWebSites" | |
for lcFiles in *; do | |
if [ -d "$lcFiles" ]; then | |
lcWordpress="$lcFiles/public_html/wp-config.php" | |
lcFiles="$lcFiles/" | |
if [ -f "$lcWordpress" ] | |
then | |
lcCommand="$WP_REFRESH $lcFiles" | |
echo -e "$lcCommand" | |
eval "$lcCommand" | |
continue | |
fi | |
lcDrupal="$lcFiles/public_html/sites" | |
if [ -d "$lcDrupal" ] | |
then | |
lcCommand="$DRUPAL_REFRESH $lcFiles -all" | |
echo -e "$lcCommand" | |
eval "$lcCommand" | |
continue | |
fi | |
fi | |
done | |
popd | |
echo -e "\nDone with updating all of the CMSs. . . ." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment