{{{ # !/bin/bash # Copyright (C) 2018 Nicholas.A.Schembri@bamboofields.net # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # self=$(echo $0|sed 's:.*/::') display_help(){ cat < dev test qa uat prod --port= tcp port --testall Run internal test --debugLevel= 0 - none 1 - some 2 - more -h, --help Display Note: $self --debugLevel=0 --testall Validation: ( test code is okay ) ( test is valid ) EOF } ########################################################### cron_task(){ cmd="curl --silent --insecure -i https://www.google.com" cmd="date" if [ $debugLevel -gt 0 ]; then echo "${cmd}" fi # sometimes it's hard for bash to parse cmd with variables # eval "$cmd" # export output=$(${cmd}) echo $($cmd) . } ######################################################## timestamp=$(date +%Y.%m.%d.%H%M%S) LOG_FILE=/var/tmp/$self.$timestamp.log verbose=0 quiet=1 user="" pass="" host="" task="" cron=0 debugLevel=0 # get the args while [ "$#" -gt 0 ]; do case $1 in -h|-\?|--help) # synopsis, then exit. display_help exit ;; -q|--quiet) quiet=1 ;; --task=?*) task=${1#*=} ;; --testall) testall exit ;; --host=?*) host=${1#*=} # Delete everything up to "=" and assign the remainder. ;; --debugLevel=?*) debugLevel=${1#*=} #export debugLevel ;; --cron) cron=1 ;; --) # End of all options. shift break ;; -?*) printf 'WARN: Unknown option (ignored): %s\n' "$1" >&2 ;; *) # Default case: If no more options then break out of the loop. break esac shift done ######################################################### if [ $debugLevel -gt 0 ]; then cat <