#!/bin/bash # itnobody.com # Run this script as a user who can move drupal files # This script should be run after a successful installation # Running this script merely reduces the footprint of cookie-cutter drupal files # and adds a few knick knacks to quiet down the signature of being a drupal site # Things this script does: # Create a 'backup' directory: DRUPAL_CLEAN-mo-day-yearThourminute # Rename cron.php to hostname.cron.php # Move all .txt files to backup dir # Move web.config to backup dir # Move scripts dir to backup dir # Move profile dir to backup dir # Move install.php to backup dir # Move example sites files to backup dir # Suppress generator tag in all themes (Unless a header tag override is already in place) PA=$1; if [ ! "$PA" ]; then read -p "Enter full path to drupal to clean: " PA fi if [ ! -d "$PA" ]; then echo $PA" does not exist" exit 1 fi CLEANMATCH="/bin/find $PA/ -name '*.txt' ! -path '$PA/DRUPAL_CLEAN-*' -print0" CLEANDIR="DRUPAL_CLEAN-"`date +%m-%d-%yT%H%M` echo "Backing up the listed files, will be placed in a a new directory '$CLEANDIR' in $PA" mkdir "$PA/$CLEANDIR" echo "Moving files ... ($CLEANMATCH) " eval "$CLEANMATCH -exec mv {} $PA/$CLEANDIR \;" echo " ... " if [ -f "$PA/web.config" ]; then echo "!!! Found web.config - moving !!!" mv $PA/web.config $PA/$CLEANDIR/ fi echo " ... " if [ -d "$PA/scripts" ]; then echo "!!! Found /scripts/ dir - moving !!!" mv $PA/scripts $PA/$CLEANDIR/ fi echo " ... " if [ -f "$PA/cron.php" ]; then echo "!!! cron.php found, renaming to "$HOSTNAME".cron.php !!!" mv $PA/cron.php $PA/$HOSTNAME.cron.php fi echo " ... " if [ -f "$PA/install.php" ]; then echo "!!! install.php found, moving to $PA/$CLEANDIR !!!" mv $PA/install.php $PA/$CLEANDIR/ fi echo " ... " if [ -d "$PA/profiles" ]; then echo "!!! profiles directory found, moving to $PA/$CLEANDIR !!!" mv $PA/profiles $PA/$CLEANDIR/ fi echo " ... " if [ -f "$PA/sites/example.sites.php" ]; then echo "!!! sites/example.sites.php found, moving to $PA/$CLEANDIR !!!" mv $PA/sites/example.sites.php $PA/$CLEANDIR/ fi echo "Files moved." echo "Scanning themes for html_head_alter (meta/generator manipulation)" for i in `find $PA/themes/ -type f -name "template.php"`; do headStat=`grep -i "_html_head_alter(" $i |wc -l` let a=`echo "$i" | tr "/" "\\n" | wc -l` let a-- theme=`echo "$i" |cut -d "/" -f $a` funcname=$theme"_html_head_alter" read -r -d '' template <> $i else echo "!!! SKIPPING "$i" has a $funcname() function - skipping. !!!" fi done