self update fixes

This commit is contained in:
Heavybullets8 2022-07-20 06:38:51 -06:00
parent d3fe6a6954
commit 3eb9a1a28c

View File

@ -6,13 +6,13 @@
args=("$@") args=("$@")
self_update() { self_update() {
SCRIPT=$(readlink -f "$0") script=$(readlink -f "$0")
SCRIPTPATH=$(dirname "$SCRIPT") script_path=$(dirname "$script")
SCRIPTNAME="heavy_script.sh" script_name="heavy_script.sh"
cd $SCRIPTPATH cd "$script_path" || exit
git fetch &> /dev/null git fetch &> /dev/null
if git diff --name-only origin/main | grep -q "$SCRIPTNAME" ; then if git diff --name-only origin/main | grep -q "$script_name" ; then
echo "Found a new version of HeavyScript, updating myself..." echo "Found a new version of HeavyScript, updating myself..."
git reset --hard -q git reset --hard -q
git pull --force -q git pull --force -q
@ -24,7 +24,7 @@ if git diff --name-only origin/main | grep -q "$SCRIPTNAME" ; then
((count++)) ((count++))
done done
sleep 5 sleep 5
exec bash "$SCRIPTNAME" "${args[@]}" exec bash "$script_name" "${args[@]}"
# Now exit this old instance # Now exit this old instance
exit exit