self update + regex fixes

This commit is contained in:
Heavybullets8 2022-07-20 06:16:33 -06:00
parent 61b8ab3444
commit e696674486

View File

@ -12,7 +12,7 @@ SCRIPTNAME="$0"
cd $SCRIPTPATH cd $SCRIPTPATH
git fetch &> /dev/null git fetch &> /dev/null
[[ -n $(git diff --name-only origin/main | grep $SCRIPTNAME) ]] && { if git diff --name-only origin/main | grep -q $SCRIPTNAME ; 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
@ -20,7 +20,7 @@ git fetch &> /dev/null
count=0 count=0
for i in "${args[@]}" for i in "${args[@]}"
do do
[[ "$i" == "--self-update" ]] && unset "args[$count]" && break [[ "$i" == "--self-update" ]] && unset "args[$count]" && args+=("--updated") && break
((count++)) ((count++))
done done
sleep 5 sleep 5
@ -28,11 +28,13 @@ git fetch &> /dev/null
# Now exit this old instance # Now exit this old instance
exit exit
} else
echo -e "HeavyScript is already the latest version.\n" echo -e "HeavyScript is already the latest version\n"
fi
} }
help(){ help(){
[[ $help == "true" ]] && clear -x [[ $help == "true" ]] && clear -x
echo "Basic Utilities" echo "Basic Utilities"
@ -217,7 +219,7 @@ export -f sync
update_apps(){ update_apps(){
mapfile -t array < <(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,container_images_update_available,status' | grep -E ",true(,|$)" | sort) mapfile -t array < <(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,container_images_update_available,status' | grep -E ",true(,|\b)" | sort)
[[ -z $array ]] && echo -e "\nThere are no updates available" && return 0 || echo -e "\n${#array[@]} update(s) available" [[ -z $array ]] && echo -e "\nThere are no updates available" && return 0 || echo -e "\n${#array[@]} update(s) available"
[[ -z $timeout ]] && echo -e "\nDefault Timeout: 500" && timeout=500 || echo -e "\nCustom Timeout: $timeout" [[ -z $timeout ]] && echo -e "\nDefault Timeout: 500" && timeout=500 || echo -e "\nCustom Timeout: $timeout"
[[ "$timeout" -le 120 ]] && echo "Warning: Your timeout is set low and may lead to premature rollbacks or skips" [[ "$timeout" -le 120 ]] && echo "Warning: Your timeout is set low and may lead to premature rollbacks or skips"
@ -389,6 +391,9 @@ do
delete-backup) delete-backup)
deleteBackup="true" deleteBackup="true"
;; ;;
updated)
self_updated="true"
;;
*) *)
echo -e "Invalid Option \"--$OPTARG\"\n" && help echo -e "Invalid Option \"--$OPTARG\"\n" && help
exit exit
@ -455,6 +460,7 @@ done
#Continue to call functions in specific order #Continue to call functions in specific order
[[ "$help" == "true" ]] && help [[ "$help" == "true" ]] && help
[[ $self_updated == "true" ]] && echo -e "HeavyScript has been updated\n"
[[ "$self_update" == "true" ]] && self_update [[ "$self_update" == "true" ]] && self_update
[[ "$deleteBackup" == "true" ]] && deleteBackup && exit [[ "$deleteBackup" == "true" ]] && deleteBackup && exit
[[ "$dns" == "true" ]] && dns && exit [[ "$dns" == "true" ]] && dns && exit