testing new self update
This commit is contained in:
parent
993475135b
commit
ec6e0884ef
@ -3,8 +3,6 @@
|
||||
#If no argument is passed, kill the script.
|
||||
[[ -z "$*" || "-" == "$*" || "--" == "$*" ]] && echo "This script requires an argument, use --help for help" && exit
|
||||
|
||||
echo "yep"
|
||||
|
||||
args=("$@")
|
||||
|
||||
self_update() {
|
||||
@ -14,23 +12,27 @@ SCRIPTNAME="$0"
|
||||
cd $SCRIPTPATH
|
||||
git fetch &> /dev/null
|
||||
|
||||
[[ -n $(git diff --name-only origin/beta | grep $SCRIPTNAME) ]] && {
|
||||
if [[ -n $(git diff --name-only origin/main | grep $SCRIPTNAME) ]]; then
|
||||
echo "Found a new version of HeavyScript, updating myself..."
|
||||
git pull --force &> /dev/null
|
||||
git reset --hard -q
|
||||
git pull --force -q
|
||||
echo -e "Running the new version...\n"
|
||||
count=0
|
||||
for i in "${args[@]}"
|
||||
do
|
||||
[[ "$i" == "--self-update" ]] && unset "args[$count]" && break
|
||||
[[ "$i" == "--self-update" ]] && unset "args[$count]" && args+=("--updated") && break
|
||||
((count++))
|
||||
done
|
||||
sleep 5
|
||||
exec bash "$SCRIPTNAME" "${args[@]}"
|
||||
|
||||
# Now exit this old instance
|
||||
exit 1
|
||||
}
|
||||
echo -e "Already the latest version.\n"
|
||||
exit
|
||||
elif [[ $self_update == "true" ]]; then
|
||||
echo -e "HeavyScript has been updated\n"
|
||||
else
|
||||
echo -e "HeavyScript is already the latest version\n"
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
@ -59,7 +61,7 @@ echo "Examples"
|
||||
echo "bash heavy_script.sh -b 14 -i portainer -i arch -i sonarr -i radarr -t 600 -vrsUp"
|
||||
echo "bash /mnt/tank/scripts/heavy_script.sh -t 150 --mount"
|
||||
echo "bash /mnt/tank/scripts/heavy_script.sh --dns"
|
||||
echo "bash /mnt/tank/scripts/heavy_script.sh --restore"
|
||||
echo "bash heavy_script.sh --restore"
|
||||
echo "bash /mnt/tank/scripts/heavy_script.sh --delete-backup"
|
||||
echo
|
||||
exit
|
||||
@ -218,7 +220,7 @@ export -f sync
|
||||
|
||||
|
||||
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 $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"
|
||||
@ -269,7 +271,7 @@ do
|
||||
else #user must not be using -S, just update
|
||||
echo -e "\n$app_name"
|
||||
[[ "$verbose" == "true" ]] && echo "Updating.."
|
||||
cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null && echo -e "Updated\n$old_full_ver\n$new_full_ver" && after_update_actions || { echo "FAILED"; continue; }
|
||||
cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null && echo -e "Updated\n$old_full_ver\n$new_full_ver" && after_update_actions || echo "FAILED"
|
||||
fi
|
||||
else
|
||||
echo -e "\n$app_name\nMajor Release, update manually"
|
||||
@ -390,6 +392,9 @@ do
|
||||
delete-backup)
|
||||
deleteBackup="true"
|
||||
;;
|
||||
updated)
|
||||
self_update="true"
|
||||
;;
|
||||
*)
|
||||
echo -e "Invalid Option \"--$OPTARG\"\n" && help
|
||||
exit
|
||||
@ -455,8 +460,8 @@ done
|
||||
[[ "$update_all_apps" == "true" && "$update_apps" == "true" ]] && echo -e "-U and -u cannot BOTH be called" && exit
|
||||
|
||||
#Continue to call functions in specific order
|
||||
[[ "$self_update" == "true" ]] && self_update
|
||||
[[ "$help" == "true" ]] && help
|
||||
[[ "$self_update" == "true" ]] && self_update
|
||||
[[ "$deleteBackup" == "true" ]] && deleteBackup && exit
|
||||
[[ "$dns" == "true" ]] && dns && exit
|
||||
[[ "$restore" == "true" ]] && restore && exit
|
||||
|
Loading…
Reference in New Issue
Block a user