#!/bin/bash # Runs the cron tasks associated with one or all sites. # # Uses wget to run cron tasks. wget must be installed. # # Outputs the result of the cron call to stdout. # Normally, drupal cron.php will output nothing so # this script should output nothing at this step. # However, if the domain is not actually backed by # the drupal site, it could output real content. # This output is supressed (along with other output) # by specifying the -quiet script. # include library file . "`dirname ${0}`/drupalLibrary.sh" CRON_SCRIPT="cron.php" WGET_FLAGS="-O - -q" WGET_QUIET_FLAGS="-O /dev/null -q" printUsage() { echo -e " " echo -e "Runs the cron tasks associated with one or all sites.. (See script header for specifics.)" echo -e " " echo -e "Usage:" echo -e "$0 -quiet ( | all ) [install group root dir]" echo -e "where:" echo -e " " echo -e "-quiet suppresses extra script output." echo -e " " outputInstallGroupUsage foo 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 if [ -z "${pQuiet}" ]; then echo " " fi # process Group Root Dir pRootDir="`getGroupRootDir "${2}"`" errorStr="`validateGroupRootDir "${pRootDir}"`" if [ -n "${errorStr}" ]; then echo -e "${errorStr}\n" printUsage exit 1 fi pInstall="$1" if [ "`toLower "${pInstall}"`" == "all" ]; then pInstall="`getSitesInGroupDir "${pRootDir}"`" else # Validate the installation errorStr="`validateSite "${pInstall}" "${pRootDir}"`" if [ -n "${errorStr}" ]; then echo -e "** Error with specified install: ${errorStr}. Aborting.\n" exit 1 fi fi # Ensure wget is installed wgetBinary="`which wget 2>/dev/null`" if [ -z "${wgetBinary}" ]; then echo -e "** 'wget' not in path. Aborting.\n" exit 1 fi # Which flags to use? wgetFlags="${WGET_FLAGS}" if [ -n "${pQuiet}" ]; then wgetFlags="${WGET_QUIET_FLAGS}" fi # process for site in ${pInstall}; do if [ -z "${pQuiet}" ]; then echo -n "Calling cron for site '${site}'.... " fi # if there exists one (and only one) alias, # use the alias instead of the sitename # TODO put in a flag to supress this if [ `getInstallAliases "${site}" "${pRootDir}" | wc -l` -eq 1 ]; then site=`getInstallAliases "${site}" "${pRootDir}"` fi "${wgetBinary}" ${wgetFlags} "http://${site}/${CRON_SCRIPT}" if [ -z "${pQuiet}" ]; then echo "done." fi done # Done if [ -z "${pQuiet}" ]; then echo -e "\n** Done." fi