#!/bin/bash # A script to manage the installation of the drush script library. # # Drush, the Drupal Shell, is a script toolkit. See: drupal.org/project/drush # For most things, the Drupal Script Library, of which this script is a part, # works better than Drush. However, because Drush is written in PHP, it can provide # easy access to the Drupal API. This is very useful for calling the update process # from the command line. # # This script will allow the installation and update of the Drush code. # It is installed to a directory called 'drush' as a sub-directory to the directory # holding this script. # # Drush requires PHP5. # Script will look for PHP_HOME variable first, then look for php executable in path. # The validate option will ensure that Drush is running with a valid version of PHP # # The script provides validation that Drush is installed correctly and that the # correct version of PHP is available. # include library file . "`dirname ${0}`/drupalLibrary.sh" # The tag used for Drush installation DRUSH_GIT_TAG="master" # Dumps out script usage printUsage() { echo -e " " echo -e "Manages the installation of the Drush package." echo -e "For more info, see script header." echo -e " " echo -e "Usage: " echo -e "\t`basename $0` [-quiet] " echo -e " " echo -e "-quiet minimizes output." echo -e " " echo -e "install - Installs the Drush files, clobbering any previous installation." echo -e "update - Updates the Drush files." echo -e "findmods - Shows any mods to the checked-out Drush installation." echo -e "validate - Validates the Drush installation and PHP version." echo -e "\tOutputs an error message if problems detected; otherwise outputs nothing." echo -e "\tImplies '-quiet'" echo -e " " } ######### # Param handling if [ $# -eq 0 ]; then printUsage exit 0 fi # Handle flags while (true); do case "${1}" in -quiet ) pQuiet="-quiet" shift ;; * ) break ;; esac done # All operations require the Drupal Scripts Library to be our cwd cd "`dirname ${0}`" || { echo -e "** Unable to 'cd' to Drupal Scripts Library directory (!!). Aborting.\n" exit 1 } # Perform requested operation case "${1}" in install ) if [ -z "${pQuiet}" ]; then echo " " fi # Remove old installation (if it exists) if [ -d "./drush" ]; then rm -rf "./drush" || { ehco -e "** Unable to remove old drush directory in Drupal Scripts Library directory. Aborting.\n" exit 1 } fi # Check out drush gitQuietFlag="" if [ -n "${pQuiet}" ]; then gitQuietFlag="-q" fi git clone ${gitQuietFlag} --depth 1 --branch ${DRUSH_GIT_TAG} "`makeGitURL ${DRUSH_PROJECT_NAME}`" "${DRUSH_INSTALL_DIR}" || { echo -e "** Error performing checkout of Drush module. Aborting.\n" exit 1 } ;; update | findmods ) if [ -z "${pQuiet}" ]; then echo " " fi if [ ! -d "./${DRUSH_INSTALL_DIR}" ]; then echo -e "** Drush install directory '${DRUSH_INSTALL_DIR}' missing. Aborting.\n" exit 1 fi if [ "${1}" == "update" ]; then # update # TODO Git Test need to test this cd "${DRUSH_INSTALL_DIR}" && git pull -q || { echo -e "** Error performing update of Drush module. Aborting.\n" exit 1 } else # findmods findRepositoryUpdates "${DRUSH_INSTALL_DIR}" fi ;; validate ) pQuiet="-quiet" drupalScriptLibraryDir="`dirname ${0}`" errorStr="`validateDrushInstallation "${drupalScriptLibraryDir}"`" if [ -n "${errorStr}" ]; then echo "** ${errorStr}" fi ;; * ) echo -e "** Invalid operation parameter specified: '${1}'. Aborting.\n" exit 1 esac # Done if [ -z "${pQuiet}" ]; then echo -e "\n** Done." fi