This example of a our script stub, shows how the
Shared Script Functions and
Shared Script Variables are utilized in a script. The "stub" is used to start all(?) our scripts:
#!/bin/bash
#
# SCRIPT: ssh-keydeployer.sh
# AUTHOR: jim@willeke.com
# DATE: 1/31/2009 10:45:29 AM
T_VER=1.1A # Script Version Number
# REV: 1.1.A
# (Valid are A, B, D, T, Q, and P (For Alpha, Beta, Dev, Test, QA, and Production)
#
# PLATFORM: bash
#
# REQUIREMENTS: OpenSSH is required for this shell script to work.
# The file is expected to be located at: /usr/local/share/willeke/
# The following MSUST Be Present:
# . /usr/local/share/willeke/.sharedfunctions.sh
# . /usr/local/share/willeke/.sharedenv.sh
#
# PURPOSE: To deploy previously generated keys to remote hosts for ssh
#
# REV LIST:
# DATE: DATE_of_REVISION
# BY: AUTHOR_of_MODIFICATION
# MODIFICATION: Describe what was modified, new features, etc--
#
#
# set -n # Uncomment to check script syntax, without execution.
# # NOTE: Do not forget to put the # comment back in or
# # the shell script will never execute!
# set -x # Uncomment to debug this shell script
#
##########################################################
# DEFINE SHARED FILES AND VARIABLES HERE
##########################################################
# Read shared variables and subroutines
THIS_SCRIPT=$(basename $0)
BASESHARRED=/usr/local/share/willeke
if [ -f $BASESHARRED/.sharedfunctions.sh ]
then
. $BASESHARRED/.sharedfunctions.sh
else
printf "\nMissing file $BASESHARRED/.sharedfunctions.sh -- cannot continue!\n"
exit 1
fi
if [ -f $BASESHARRED/.sharedenv.sh ]
then
. $BASESHARRED/.sharedenv.sh
else
printf "\nMissing file $BASESHARRED/.sharedenv.sh -- cannot run!\n"
exit 1
fi
f_write_and_log "`date '+%Y-%m-%d %H:%M:%S'`: $0 $THIS_SCRIPT Version $T_VER Started by $USER"
##########################################################
# DEFINE PRIVATE FILES AND VARIABLES HERE
##########################################################
USERNAME=$1
USERPASSWORD=$2
INFILE=$3
##########################################################
# DEFINE FUNCTIONS HERE
####################################################################################################################
# BEGINNING OF MAIN
##########################################################
##########################################################
# CLEANUP
##########################################################
unset T_VER
# End of script