mirror of
https://github.com/natelandau/shell-scripting-templates.git
synced 2025-11-09 13:43:46 -05:00
Better sourcing of lib files
This commit is contained in:
@@ -34,12 +34,14 @@ scriptTemplateVersion="1.0.1" # Version of scriptTemplate.sh
|
||||
# -----------------------------------
|
||||
# If these can't be found, update the path to the file
|
||||
# -----------------------------------
|
||||
if [ -f "../lib/utils.sh" ]; then
|
||||
source "../lib/utils.sh"
|
||||
SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
if [ -f "${SCRIPTDIR}/../lib/utils.sh" ]; then
|
||||
source "${SCRIPTDIR}/../lib/utils.sh"
|
||||
else
|
||||
echo "Please find the file util.sh and add a reference to it in this script. Exiting."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# trapCleanup Function
|
||||
# -----------------------------------
|
||||
# Any actions that should be taken if the script is prematurely
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
if [ -f "../lib/utils.sh" ]; then
|
||||
source "../lib/utils.sh"
|
||||
SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
if [ -f "${SCRIPTDIR}/../lib/utils.sh" ]; then
|
||||
source "${SCRIPTDIR}/../lib/utils.sh"
|
||||
else
|
||||
echo "You must have utils.sh to run. Exiting."
|
||||
exit 0
|
||||
echo "Please find the file util.sh and add a reference to it in this script. Exiting."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
# Confirm we have Dropbox
|
||||
hasDropbox
|
||||
|
||||
|
||||
@@ -33,12 +33,14 @@ 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 [ -f "../lib/utils.sh" ]; then
|
||||
source "../lib/utils.sh"
|
||||
SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
if [ -f "${SCRIPTDIR}/../lib/utils.sh" ]; then
|
||||
source "${SCRIPTDIR}/../lib/utils.sh"
|
||||
else
|
||||
echo "Please find the file util.sh and add a reference to it in this script. Exiting."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# trapCleanup Function
|
||||
# -----------------------------------
|
||||
# Any actions that should be taken if the script is prematurely
|
||||
|
||||
@@ -32,12 +32,14 @@ scriptTemplateVersion="1.0.1" # Version of scriptTemplate.sh
|
||||
# -----------------------------------
|
||||
# If these can't be found, update the path to the file
|
||||
# -----------------------------------
|
||||
if [ -f "../lib/utils.sh" ]; then
|
||||
source "../lib/utils.sh"
|
||||
SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
if [ -f "${SCRIPTDIR}/../lib/utils.sh" ]; then
|
||||
source "${SCRIPTDIR}/../lib/utils.sh"
|
||||
else
|
||||
echo "Please find the file util.sh and add a reference to it in this script. Exiting."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# trapCleanup Function
|
||||
# -----------------------------------
|
||||
# Any actions that should be taken if the script is prematurely
|
||||
|
||||
@@ -33,12 +33,14 @@ scriptTemplateVersion="1.1.0" # Version of scriptTemplate.sh
|
||||
# -----------------------------------
|
||||
# If these can't be found, update the path to the file
|
||||
# -----------------------------------
|
||||
if [ -f "../lib/utils.sh" ]; then
|
||||
source "../lib/utils.sh"
|
||||
SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
if [ -f "${SCRIPTDIR}/../lib/utils.sh" ]; then
|
||||
source "${SCRIPTDIR}/../lib/utils.sh"
|
||||
else
|
||||
echo "Please find the file util.sh and add a reference to it in this script. Exiting."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# trapCleanup Function
|
||||
# -----------------------------------
|
||||
# Any actions that should be taken if the script is prematurely
|
||||
|
||||
@@ -11,13 +11,15 @@
|
||||
# ##################################################
|
||||
|
||||
# Source global utilities
|
||||
if [ -f "../lib/utils.sh" ]; then
|
||||
source "../lib/utils.sh"
|
||||
SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
if [ -f "${SCRIPTDIR}/../lib/utils.sh" ]; then
|
||||
source "${SCRIPTDIR}/../lib/utils.sh"
|
||||
else
|
||||
echo "You must have utils.sh to run. Exiting."
|
||||
exit
|
||||
echo "Please find the file util.sh and add a reference to it in this script. Exiting."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
seek_confirmation "Do you want to run the Dropbox script to install it first?"
|
||||
if is_confirmed; then
|
||||
if is_file "./dropbox.sh"; then
|
||||
|
||||
@@ -32,12 +32,14 @@ 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 [ -f "../lib/utils.sh" ]; then
|
||||
source "../lib/utils.sh"
|
||||
SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
if [ -f "${SCRIPTDIR}/../lib/utils.sh" ]; then
|
||||
source "${SCRIPTDIR}/../lib/utils.sh"
|
||||
else
|
||||
echo "Please find the file util.sh and add a reference to it in this script. Exiting."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# trapCleanup Function
|
||||
# -----------------------------------
|
||||
# Any actions that should be taken if the script is prematurely
|
||||
|
||||
@@ -32,12 +32,14 @@ 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 [ -f "../lib/utils.sh" ]; then
|
||||
source "../lib/utils.sh"
|
||||
SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
if [ -f "${SCRIPTDIR}/../lib/utils.sh" ]; then
|
||||
source "${SCRIPTDIR}/../lib/utils.sh"
|
||||
else
|
||||
echo "Please find the file util.sh and add a reference to it in this script. Exiting."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# trapCleanup Function
|
||||
# -----------------------------------
|
||||
# Any actions that should be taken if the script is prematurely
|
||||
|
||||
@@ -32,12 +32,14 @@ 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 [ -f "../lib/utils.sh" ]; then
|
||||
source "../lib/utils.sh"
|
||||
SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
if [ -f "${SCRIPTDIR}/../lib/utils.sh" ]; then
|
||||
source "${SCRIPTDIR}/../lib/utils.sh"
|
||||
else
|
||||
echo "Please find the file util.sh and add a reference to it in this script. Exiting."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# trapCleanup Function
|
||||
# -----------------------------------
|
||||
# Any actions that should be taken if the script is prematurely
|
||||
|
||||
Reference in New Issue
Block a user