Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sco-tt/a79fd45e669b595cebcd to your computer and use it in GitHub Desktop.
Save sco-tt/a79fd45e669b595cebcd to your computer and use it in GitHub Desktop.
#!/bin/bash
# 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
drush='/usr/bin/drush'
# where your drupal sites live
site_dir='/var/www'
echo "Scanning sites directory for drupal installations"
cd $site_dir
for i in $(ls)
do
a=$(readlink -f $i)
# if your site files are in directories immediately
# beneath your site_dir, i.e. /var/www/site.com,
# 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 ]]
then
echo "Drupal site found"
# `drush up` is interactive, so if you
# don't want updates hit `n` for each site
$drush up --security-only
else
echo "No Drupal site found in this directory"
fi
cd $site_dir
done
echo "Done with Drupal Security Updates"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment