-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhelpers.sh
32 lines (25 loc) · 889 Bytes
/
helpers.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# Determine toolpath if not set already
relativepath="./" # Define relative path to go from this script to the root level of the tool
if [[ ! -v toolpath ]]; then scriptpath=$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ); toolpath=$(realpath --canonicalize-missing ${scriptpath}/${relativepath}); fi
# Load Functions
source ${toolpath}/functions.sh
# Update Tools from anywhere
update_tools() {
# The User is passed as Optional Argument
local luser=${1-""}
if [[ -z "${luser}" ]]
then
luser=$(whoami)
fi
# Save Current Directory
currentpath=$(pwd)
# Change Directory to Toolpath
cd ${toolpath} || exit
# Do a git pull
generic_cmd "${luser}" "git" "pull"
# Reload ~/.bash_profile
homedir=$(get_homedir "${luser}")
generic_cmd "${luser}" "source" "${homedir}/.bash_profile"
# Go back to Current Path
cd ${currentpath} || exit
}