#!/bin/bash # # skel.sh # Simple skeleton template for new shell scripts # # Changelog # 2014-03-27 - Nathan Isburgh # * Initial version # * Implementing basic 5 common functions # # Debug flag? 1=on, 0=off DEBUG=1 # Additional user-customized variables... # # END OF CONFIGURATION VARIABLES # NO MORE EDITS BEYOND THIS POINT # # Functions... # # fail [exit code] [exit message] # # Common exit codes: # 1 - Invalid arguments # 2 - Missing arguments # 3 - Missing software # fail() { cleanup ECODE=${1:-1} EMSG=$2 if [ -n $EMSG ] then echo $EMSG > /dev/stderr fi exit $ECODE } succeed() { cleanup exit } cleanup() { # Clean up temp files # Close out logs # Disconnect from remote resources return } # # debug "message" # debug() { printf "*** [%s] %s\n" "$(date +%r)" "$1" > /dev/stderr } usage() { cat << eof skel.sh Simple skeleton template file for new shell scripts eof } # Main body...