diff --git a/files/scripts/development-branch/update.sh b/files/scripts/development-branch/update.sh index e815e00..3217f28 100644 --- a/files/scripts/development-branch/update.sh +++ b/files/scripts/development-branch/update.sh @@ -7,25 +7,47 @@ # Author URI: https://cryinkfly.com # # License: MIT # # Copyright (c) 2020-2022 # -# Time/Date: 09:30/17.02.2022 # -# Version: 0.0.3 # +# Time/Date: 11:15/17.02.2022 # +# Version: 0.0.4 # #################################################################################################### # Path: /$HOME/.config/fusion-360/bin/update.sh ############################################################################################################################################################### -# ALL FUNCTIONS ARE ARRANGED HERE: # -############################################################################################################################################################### + +# Window Title (Launcher) +program_name="Autodesk Fusion 360 for Linux - Launcher" # I will change this value as soon as a new version of Autodesk Fusion 360 is available. # A value of 0 means that there is no update and a value of 1 will notify the user that there is an update. get_update=0 -function setupact-check { +# Domain Name +domain="www.github.com" + +############################################################################################################################################################### +# ALL FUNCTIONS ARE ARRANGED HERE: # +############################################################################################################################################################### + +# Check the connection to the server of GitHub. +function setupact-check-connection { + ping -c 5 $domain 2>/dev/null 1>/dev/null + if [ "$?" = 0 ]; then + echo "Host found" + else + echo "Host not found" + setupact-no-connection-warning + # Skip the update proecess ... (Still in Progress!) +fi +} + +# Checks if there is an update for Autodesk Fusion 360. +function setupact-check-update { if [ $get_update -eq 1 ]; then setupact-get-update else - # echo "Do nothing!" + echo "Do nothing!" + setupact-no-update-info fi } @@ -36,19 +58,16 @@ function setupact-check { function setupact-get-update { pc_date=$(date +%u) if [ $pc_date -eq 1 ]; then - # echo "Monday" - setupact-get-f360exe - setupact-update + echo "Monday" + setupact-update-question elif [ $pc_date -eq 3 ]; then - # echo "Wednesday" - setupact-get-f360exe - setupact-update + echo "Wednesday" + setupact-update-question elif [ $pc_date -eq 5 ]; then - # echo "Friday" - setupact-get-f360exe - setupact-update + echo "Friday" + setupact-update-question else - # echo "Do nothing!" + setupact-no-update-info fi } @@ -65,10 +84,87 @@ function setupact-update { # ALL DIALOGS ARE ARRANGED HERE: # ############################################################################################################################################################### -# Still in Progress! +# The user get a informationt that no newer version of Autodesk Fusion 360 was found! +function setupact-no-update-info { + zenity --info \ + --text="No newer version was found, so your Autodesk fusion 360 is up to date!" \ + --width=400 \ + --height=100 +} + +############################################################################################################################################################### + +# The user get a informationt that there is no connection to the server! +function setupact-no-connection-warning { + zenity --warning \ + --text="The connection to the server could not be established! The search for new updates has been skipped! Please check your internet connection!" \ + --width=400 \ + --height=100 +} + +############################################################################################################################################################### + +# The user will be asked if he wants to update or not. +function setupact-update-question { + zenity --question \ + --title="$program_name" \ + --text="A new version has been released! Would you like to update now?" \ + --width=400 \ + --height=100 + answer=$? + + if [ "$answer" -eq 0 ]; then + echo "Do nothing!" + elif [ "$answer" -eq 1 ]; then + setupact-get-f360exe + setupact-update + fi +} + +############################################################################################################################################################### + +# A progress bar is displayed here. +function setupact-progressbar { + ( +echo "5" ; sleep 1 +echo "# Connecting to the server ..." ; sleep 5 +setupact-check-connection +echo "25" ; sleep 1 +echo "# Check for updates ..." ; sleep 3 +setupact-check-update +echo "75" ; sleep 1 +) | +zenity --progress \ + --title="$program_name" \ + --text="Checking if there is a new version of Autodesk fusion 360 available ..." \ + --width=400 \ + --height=100 \ + --percentage=0 + +if [ "$?" = 0 ] ; then + setupact-update-solved +elif [ "$?" = 1 ] ; then + zenity --question \ + --title="$program_name" \ + --text="Are you sure you want to skip checking for an Autodesk Fusion 360 update?" \ + --width=400 \ + --height=100 + answer=$? + + if [ "$answer" -eq 0 ]; then + echo "Do nothing!" + elif [ "$answer" -eq 1 ]; then + setupact-progressbar + fi +elif [ "$?" = -1 ] ; then + zenity --error \ + --text="An unexpected error occurred!" + exit; +fi +} ############################################################################################################################################################### # THE INSTALLATION PROGRAM IS STARTED HERE: # ############################################################################################################################################################### -setupact-check +setupact-progressbar