#!/bin/bash PID=$$ config_file= verbose=0 usage() { msg=$1 if [ -n "${msg}" ]; then echo -e "${msg}\n"; fi cat <] [--verbose] [-h|--help] Options: -c|--config Specifies the config file to use (required) --verbose Send output of commands to console as well as log -h|--help Show this message and quit EOH } send_email() { subject="${EMAIL_SUBJECT_PREPEND} $1" body=$2 echo -e "From: ${EMAIL_FROM}\r\nTo: ${EMAIL_TO}\r\nSubject: ${subject}\r\n\r\n${body}\r\n" | /usr/sbin/sendmail -f ${EMAIL_FROM} ${EMAIL_TO} } run_cmd() { cmd=$1 logfile=$2 if [ $verbose = 1 ]; then echo "*** Running command: ${cmd}" # ${cmd} 2>&1 | tee ${logfile} else # ${cmd} &> ${logfile} a=1 fi } # Parse args params=${#} while [ ${#} -gt 0 ] do a=${1} shift case "${a}" in -h|--help) usage exit 0 ;; -c|--config) config_file=$1 shift ;; --verbose) verbose=1 ;; -*) echo "You have specified an invalid option: ${a}" usage exit 1 ;; esac done # Make sure all required values were specified if [ -z "${config_file}" -o ! -e "${config_file}" ]; then usage "You must specify a valid config file to use" exit 1 fi source ${config_file} #if [ -z "${snapshot}" ]; then # snapshot=`date +%Y%m%d` # run_cmd "catalyst -c ${config} -s '${snapshot}'" "/tmp/catalyst_build_snapshot.${PID}.log" # if [ $? != 0 ]; then # send_email "Catalyst build error - snapshot" "$(