Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
# Script to do security updates only in Drupal 6 and Drupal 7 using drush version 6.2.0
# Note: drush up --security-only updates modules as well as core
# run `which drush` to find this path
# where your drupal sites live
echo "Scanning sites directory for drupal installations"
cd $site_dir
for i in $(ls)
a=$(readlink -f $i)
# if your site files are in directories immediately
# beneath your site_dir, i.e. /var/www/,
# then you don't need to `cd public_html'
# just use `cd $a` below
cd $a && cd public_html
echo $(pwd)
status=$($drush status | wc -l)
# Count the lines on drush status to see if it's
# actually a drupal site
if [[ $status -gt 7 ]]
echo "Drupal site found"
# `drush up` is interactive, so if you
# don't want updates hit `n` for each site
$drush up --security-only
echo "No Drupal site found in this directory"
cd $site_dir
echo "Done with Drupal Security Updates"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment