mirror of
https://github.com/natelandau/shell-scripting-templates.git
synced 2025-11-16 17:03:48 -05:00
Tweaks to syncTemplate.sh
This commit is contained in:
@@ -8,6 +8,17 @@
|
||||
#
|
||||
# ##################################################
|
||||
|
||||
# scriptPath
|
||||
# ------------------------------------------------------
|
||||
# This function will populate the variable SOURCEPATH with the
|
||||
# full path of the script being run.
|
||||
# Note: The function must be run within the script before using
|
||||
# the variable
|
||||
# ------------------------------------------------------
|
||||
function scriptPath() {
|
||||
SCRIPTPATH=$( cd "$( dirname "$0" )" && pwd )
|
||||
}
|
||||
|
||||
# readFile
|
||||
# ------------------------------------------------------
|
||||
# Function to read a line from a file.
|
||||
|
||||
@@ -14,7 +14,7 @@ while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symli
|
||||
SOURCE="$(readlink "$SOURCE")"
|
||||
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
|
||||
done
|
||||
SCRIPTPATH="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
|
||||
SOURCEPATH="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
|
||||
|
||||
# Write the list of utility files to be sourced
|
||||
FILES="
|
||||
@@ -26,8 +26,8 @@ FILES="
|
||||
# Source the Utility Files
|
||||
for file in $FILES
|
||||
do
|
||||
if [ -f "$SCRIPTPATH/$file" ]; then
|
||||
source "$SCRIPTPATH/$file"
|
||||
if [ -f "$SOURCEPATH/$file" ]; then
|
||||
source "$SOURCEPATH/$file"
|
||||
else
|
||||
e_error "$file does not exist. Exiting"
|
||||
Exit 1
|
||||
|
||||
Reference in New Issue
Block a user