Useful Drupal scripts

Here are some useful Drupal scripts! The first is a script that will put your Drupal directory's UNIX file permissions back to a secure and useful state. The second is great if you have a production and a staging website. You often need to clone your production website back to production then change some configuration to make the staging website "development". This is pretty basic; for instance, I sometimes need to disable google analytics as well in this script. The third is basically a listing of the crucial Drupal 7 modules I install in every site I have.

DrupalPermissionsSetup.sh

#!/bin/bash 
#assumes your site is installed at /home/username/public_html 

USERNAME=username 
INSTALL_DIR=public_html 

if [ "$1" != "--really" ]; then 
  cat $0
  exit 0 
fi 

cd /home/$USERNAME/ 
chown -R $USERNAME:www-data $INSTALL_DIR 
find $INSTALL_DIR -type d -exec chmod u=rwx,g=rx,o= '{}&' \; 
find $INSTALL_DIR -type f -exec chmod u=rw,g=r,o= '{}' \; 

#this code handles multisite install files directories 
find $INSTALL_DIR/sites -type d -name files -exec chmod ug=rwx,o= '{}' \; 
for d in $INSTALL_DIR/sites/*/files; do 
  chown -R www-data:$USERNAME $d 
  find $d -type d -exec chmod ug=rwx,o= '{}' \; 
  find $d -type f -exec chmod ug=rw,o= '{}' \; 
done 

AfterCloningProduction.sh

#!/bin/bash 
#clone your production database to staging then run this script using drush to get into development mode 

#set some important variables. Need to customize the favicon updating line and the developer modules line at least, plus these variables: 
USERNAME=username 
INSTALL_DIR=public_html 
DEV_EMAIL=testingemail@example.com 

CURRENT_WD=`pwd` 
cd /home/$USERNAME/$INSTALL_DIR

drush vset -y preprocess_css 0 
drush vset -y preprocess_js 0 
drush vset -y error_level 2 
drush vset -y site_mail $DEV_EMAIL 

#this line changes your favicon to default - I leave my theme's default favicon as the Drupal logo and then I can easily see which tab is development and which is production 
drush php-eval '$s=variable_get("theme_THEMENAME_settings",""); $s["default_favicon"]=1; variable_set("theme_THEMENAME_settings", $s);' 

#developer modules - add more? 
drush en -y devel field_ui rules_admin views_ui 

drush cc all 

cd $CURRENT_WD

My always-install modules

drush dl admin_menu globalredirect pathauto subpathauto views devel wysiwyg xmlsitemap redirect token ctools diff tadaa
drush en -y admin_menu_toolbar views_ui globalredirect subpathauto pathauto devel wysiwyg xmlsitemap redirect diff tadaa

wget 'http://download.cksource.com/CKEditor/CKEditor/CKEditor%203.6.6.2/ckeditor_3.6.6.2.zip'
unzip ckeditor_3.6.6.2.zip -d sites/all/libraries
Tags: 

Add new comment