mirror of
https://github.com/natelandau/shell-scripting-templates.git
synced 2025-11-09 21:53:47 -05:00
v1.1.1 - offloaded variables to utils scripts
This commit is contained in:
@@ -5,8 +5,9 @@
|
|||||||
#
|
#
|
||||||
version="1.0.0" # Sets version variable for this script
|
version="1.0.0" # Sets version variable for this script
|
||||||
#
|
#
|
||||||
scriptTemplateVersion="1.1.0" # Version of scriptTemplate.sh that this script is based on
|
scriptTemplateVersion="1.1.1" # Version of scriptTemplate.sh that this script is based on
|
||||||
# v.1.1.0 - Added 'debug' option
|
# v.1.1.0 - Added 'debug' option
|
||||||
|
# v.1.1.1 - Moved all shared variables to Utils
|
||||||
#
|
#
|
||||||
# A Bash script boilerplate. Allows for common functions, logging, tmp
|
# A Bash script boilerplate. Allows for common functions, logging, tmp
|
||||||
# file creation, CL option passing, and more.
|
# file creation, CL option passing, and more.
|
||||||
@@ -33,9 +34,9 @@ scriptTemplateVersion="1.1.0" # Version of scriptTemplate.sh that this script is
|
|||||||
# -----------------------------------
|
# -----------------------------------
|
||||||
# If these can't be found, update the path to the file
|
# If these can't be found, update the path to the file
|
||||||
# -----------------------------------
|
# -----------------------------------
|
||||||
SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
scriptPath="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
if [ -f "${SCRIPTDIR}/lib/utils.sh" ]; then
|
if [ -f "${scriptPath}/lib/utils.sh" ]; then
|
||||||
source "${SCRIPTDIR}/lib/utils.sh"
|
source "${scriptPath}/lib/utils.sh"
|
||||||
else
|
else
|
||||||
echo "Please find the file util.sh and add a reference to it in this script. Exiting."
|
echo "Please find the file util.sh and add a reference to it in this script. Exiting."
|
||||||
exit 1
|
exit 1
|
||||||
@@ -66,28 +67,15 @@ force=0
|
|||||||
strict=0
|
strict=0
|
||||||
debug=0
|
debug=0
|
||||||
|
|
||||||
|
# Set Temp Directory
|
||||||
# Set Local Variables
|
|
||||||
# -----------------------------------
|
# -----------------------------------
|
||||||
# A set of variables used by many scripts
|
|
||||||
# -----------------------------------
|
|
||||||
|
|
||||||
# Set Script name and location variables
|
|
||||||
scriptName=`basename ${0}` # Full name
|
|
||||||
scriptBasename="$(basename ${scriptName} .sh)" # Strips '.sh' from name
|
|
||||||
scriptPath="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
||||||
|
|
||||||
# Set time stamp
|
|
||||||
now=$(date +"%m-%d-%Y %r")
|
|
||||||
# Set hostname
|
|
||||||
thisHost=$(hostname)
|
|
||||||
|
|
||||||
# Create temp directory with three random numbers and the process ID
|
# Create temp directory with three random numbers and the process ID
|
||||||
# in the name. This directory is removed automatically at exit.
|
# in the name. This directory is removed automatically at exit.
|
||||||
tmpDir="/tmp/${scriptName}.$RANDOM.$RANDOM.$RANDOM.$$"
|
# -----------------------------------
|
||||||
(umask 077 && mkdir "${tmpDir}") || {
|
tmpDir="/tmp/${scriptName}.$RANDOM.$RANDOM.$RANDOM.$$"
|
||||||
die "Could not create temporary directory! Exiting."
|
(umask 077 && mkdir "${tmpDir}") || {
|
||||||
}
|
die "Could not create temporary directory! Exiting."
|
||||||
|
}
|
||||||
|
|
||||||
# Logging
|
# Logging
|
||||||
# -----------------------------------
|
# -----------------------------------
|
||||||
@@ -102,14 +90,12 @@ logFile="$HOME/Library/Logs/${scriptBasename}.log"
|
|||||||
|
|
||||||
function mainScript() {
|
function mainScript() {
|
||||||
############## Begin Script Here ###################
|
############## Begin Script Here ###################
|
||||||
|
####################################################
|
||||||
|
|
||||||
|
|
||||||
echo -n
|
echo -n
|
||||||
|
|
||||||
|
####################################################
|
||||||
|
############### End Script Here ####################
|
||||||
############## End Script Here ###################
|
|
||||||
}
|
}
|
||||||
|
|
||||||
############## Begin Options and Usage ###################
|
############## Begin Options and Usage ###################
|
||||||
|
|||||||
Reference in New Issue
Block a user