#!/bin/bash # # skel.sh # - Simple template file for new scripts # # Changelog: # * 2014-05-22 - Nathan Isburgh # - Initial version of script # # Debug flag - 1 for verbose debugging DEBUG=1 # # NO EDITS BELOW THIS LINE # # # succeed() # - gracefully exit from program successfully # succeed() { cleanup exit 0 } # # fail( code, msg ) # - gracefully exit from program in failure state # fail() { cleanup if [ -n "$2" ] then echo "$2" > /dev/stderr fi exit ${1:-1} } # # cleanup() # - clean up log/lock files, etc # cleanup() { return } # # debug( msg ) # - Prints standard debug message to stderr # - Only print if debugging is enabled # debug() { if [ "$DEBUG" -ne 1 ] then return fi echo $(date +%T) " $@" > /dev/stderr } # # usage() # - Print a basic usage statement for user to understand program use # usage() { cat << eof Usage: $0 Simple skeleton/template for new scripts eof } # Main code body # ... succeed