testing new self update
This commit is contained in:
		@@ -3,8 +3,6 @@
 | 
				
			|||||||
#If no argument is passed, kill the script.
 | 
					#If no argument is passed, kill the script.
 | 
				
			||||||
[[ -z "$*" || "-" == "$*" || "--" == "$*"  ]] && echo "This script requires an argument, use --help for help" && exit
 | 
					[[ -z "$*" || "-" == "$*" || "--" == "$*"  ]] && echo "This script requires an argument, use --help for help" && exit
 | 
				
			||||||
 | 
					
 | 
				
			||||||
echo "yep"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
args=("$@")
 | 
					args=("$@")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
self_update() {
 | 
					self_update() {
 | 
				
			||||||
@@ -14,23 +12,27 @@ SCRIPTNAME="$0"
 | 
				
			|||||||
cd $SCRIPTPATH
 | 
					cd $SCRIPTPATH
 | 
				
			||||||
git fetch &> /dev/null 
 | 
					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..."
 | 
					    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"
 | 
					    echo -e "Running the new version...\n"
 | 
				
			||||||
    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
 | 
				
			||||||
    exec bash "$SCRIPTNAME" "${args[@]}"
 | 
					    exec bash "$SCRIPTNAME" "${args[@]}"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # Now exit this old instance
 | 
					    # Now exit this old instance
 | 
				
			||||||
    exit 1
 | 
					    exit
 | 
				
			||||||
    }
 | 
					elif [[ $self_update == "true" ]]; then
 | 
				
			||||||
    echo -e "Already the latest version.\n"
 | 
					    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 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 -t 150 --mount"
 | 
				
			||||||
echo "bash /mnt/tank/scripts/heavy_script.sh --dns"
 | 
					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 "bash /mnt/tank/scripts/heavy_script.sh --delete-backup"
 | 
				
			||||||
echo
 | 
					echo
 | 
				
			||||||
exit
 | 
					exit
 | 
				
			||||||
@@ -218,7 +220,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"
 | 
				
			||||||
@@ -269,7 +271,7 @@ do
 | 
				
			|||||||
        else #user must not be using -S, just update
 | 
					        else #user must not be using -S, just update
 | 
				
			||||||
            echo -e "\n$app_name"
 | 
					            echo -e "\n$app_name"
 | 
				
			||||||
            [[ "$verbose" == "true" ]] && echo "Updating.."
 | 
					            [[ "$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
 | 
					        fi
 | 
				
			||||||
    else
 | 
					    else
 | 
				
			||||||
        echo -e "\n$app_name\nMajor Release, update manually"
 | 
					        echo -e "\n$app_name\nMajor Release, update manually"
 | 
				
			||||||
@@ -372,10 +374,10 @@ do
 | 
				
			|||||||
    case $opt in
 | 
					    case $opt in
 | 
				
			||||||
      -)
 | 
					      -)
 | 
				
			||||||
          case "${OPTARG}" in
 | 
					          case "${OPTARG}" in
 | 
				
			||||||
            help)
 | 
					             help)
 | 
				
			||||||
                  help="true"
 | 
					                  help="true"
 | 
				
			||||||
                  ;;
 | 
					                  ;;
 | 
				
			||||||
     self-update)
 | 
					      self-update)
 | 
				
			||||||
                  self_update="true"
 | 
					                  self_update="true"
 | 
				
			||||||
                  ;;
 | 
					                  ;;
 | 
				
			||||||
              dns)
 | 
					              dns)
 | 
				
			||||||
@@ -390,6 +392,9 @@ do
 | 
				
			|||||||
    delete-backup)
 | 
					    delete-backup)
 | 
				
			||||||
                  deleteBackup="true"
 | 
					                  deleteBackup="true"
 | 
				
			||||||
                  ;;
 | 
					                  ;;
 | 
				
			||||||
 | 
					          updated)
 | 
				
			||||||
 | 
					                  self_update="true"
 | 
				
			||||||
 | 
					                  ;;
 | 
				
			||||||
                *)
 | 
					                *)
 | 
				
			||||||
                  echo -e "Invalid Option \"--$OPTARG\"\n" && help
 | 
					                  echo -e "Invalid Option \"--$OPTARG\"\n" && help
 | 
				
			||||||
                  exit
 | 
					                  exit
 | 
				
			||||||
@@ -455,8 +460,8 @@ done
 | 
				
			|||||||
[[ "$update_all_apps" == "true" && "$update_apps" == "true" ]] && echo -e "-U and -u cannot BOTH be called" && exit
 | 
					[[ "$update_all_apps" == "true" && "$update_apps" == "true" ]] && echo -e "-U and -u cannot BOTH be called" && exit
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#Continue to call functions in specific order
 | 
					#Continue to call functions in specific order
 | 
				
			||||||
[[ "$self_update" == "true" ]] && self_update
 | 
					 | 
				
			||||||
[[ "$help" == "true" ]] && help
 | 
					[[ "$help" == "true" ]] && help
 | 
				
			||||||
 | 
					[[ "$self_update" == "true" ]] && self_update
 | 
				
			||||||
[[ "$deleteBackup" == "true" ]] && deleteBackup && exit
 | 
					[[ "$deleteBackup" == "true" ]] && deleteBackup && exit
 | 
				
			||||||
[[ "$dns" == "true" ]] && dns && exit
 | 
					[[ "$dns" == "true" ]] && dns && exit
 | 
				
			||||||
[[ "$restore" == "true" ]] && restore && exit
 | 
					[[ "$restore" == "true" ]] && restore && exit
 | 
				
			||||||
@@ -464,4 +469,4 @@ done
 | 
				
			|||||||
[[ "$number_of_backups" -ge 1 ]] && backup
 | 
					[[ "$number_of_backups" -ge 1 ]] && backup
 | 
				
			||||||
[[ "$sync" == "true" ]] && sync
 | 
					[[ "$sync" == "true" ]] && sync
 | 
				
			||||||
[[ "$update_all_apps" == "true" || "$update_apps" == "true" ]] && update_apps
 | 
					[[ "$update_all_apps" == "true" || "$update_apps" == "true" ]] && update_apps
 | 
				
			||||||
[[ "$prune" == "true" ]] && prune
 | 
					[[ "$prune" == "true" ]] && prune
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user