# The directory the Drupal site is installed in DRUPAL_DIR=~/public_html # The working directory for a temp copy of the new version UPDATE_TMP_DIR=~/update_drupal # A text file containing all the resources to copy across # to the new version (favicon.ico, logo.png). One per line # Note that .htaccess is copied anyway and should not be listed. FILES_TO_KEEP=~/drupal_copy.txt # A text file containing a list of all the site-specific # subfolders within the sites directory. For most Drupal # installations, the file should just contain one line with # the word default. But you may list example.com, # staging.example.com and so on, if you use multi-site DRUPAL_SITES=~/drupal_sites.txt # Near the bottom of the script is a Drush command to # updatedb. You may need to add a -l switch to specify # the sites you want to update, or use Drush aliases. # This could be picked up from the sites txt file, but # sometimes not all the databases referenced in # sites/*/settings.php are accessible on this server. # End configuration section # 1. Clear out the temp directory from last time mkdir -p $UPDATE_TMP_DIR cd $UPDATE_TMP_DIR rm drupal* -rf # 2. Download Drupal into temp directory # and get rid of version number in directory name. drush dl drupal mv $UPDATE_TMP_DIR/drupal* $UPDATE_TMP_DIR/drupal # 3. Remove group-write permissions for suPHP. chmod -R g-w $UPDATE_TMP_DIR/drupal/* # 4. Make the sites directories writeable, so they don't get lost for sites in `cat $DRUPAL_SITES`; do chmod +w $DRUPAL_DIR/sites/$sites chmod +w $DRUPAL_DIR/sites/$sites/settings.php done # 5. Move all the files we wish to keep into the new version for keeps in `cat $FILES_TO_KEEP`; do mv $DRUPAL_DIR/$keeps $UPDATE_TMP_DIR/drupal done mv $DRUPAL_DIR/.htaccess $UPDATE_TMP_DIR/drupal # 6. Copy the sites directory into the new version cp -r $DRUPAL_DIR/sites/* $UPDATE_TMP_DIR/drupal/sites # 7. Scary bit: Delete everything left in the Drupal directory rm $DRUPAL_DIR/* $DRUPAL_DIR/.ht* -rf # 8. Move the temp working copy into the main directory mv $UPDATE_TMP_DIR/drupal/* $UPDATE_TMP_DIR/drupal/.??* $DRUPAL_DIR # 9. Run updates cd $DRUPAL_DIR # drush -l example updatedb drush updatedb # 10. Remove temp working copy chmod -R +w $UPDATE_TMP_DIR/drupal rm $UPDATE_TMP_DIR/drupal -rf