#!/bin/bash # # PHP CLI executable # PHP=/opt/php-5.2.5/bin/php # # Configuration directory (include a trailing slash) # CONF_DIR=/opt/drush/etc/ ##### END OF CONFIGURATION ##### # Print usage info and exit usage() { echo "Usage: `basename $0` [options] " echo " Configured sites:" FILES=`find $CONF_DIR -name "*.conf"` for file in $FILES; do file=`basename $file` echo " ${file%.conf}" done exit } # Print error message and exit conf_error() { echo "Configuration error: $1" exit } # Grab the site from the first arg and save to rest to pass on to drush SITE=$1 shift ARGS=$@ CONF_FILE="${CONF_DIR}${SITE}.conf" if [ -f $CONF_FILE ]; then . $CONF_FILE else usage fi # make full path to drush.php DRUSH="${ROOT}/${DRUSH}" if [[ $HOST == '' ]]; then conf_error "HOST is not defined" elif [[ $ROOT == '' ]]; then conf_error "ROOT is not defined" elif [[ ! -d $ROOT ]]; then conf_error "ROOT ($ROOT) is not a directory." elif [[ $DRUSH == '' ]]; then conf_error "DRUSH is not defined" elif [[ ! -f $DRUSH ]]; then conf_error "DRUSH ($DRUSH) is not a file." fi $PHP $DRUSH -r $ROOT -l $HOST $ARGS