diff --git a/install b/install index 7c25b2a400..0fd84f77cb 100755 --- a/install +++ b/install @@ -40,34 +40,21 @@ if [ -z "$DIRECTORY" ] || [ "$DIRECTORY" == "$HOME" ] || [ "$DIRECTORY" == bash fi downloaded=0 #track if pi-apps was downloaded this time -#Re-download pi-apps folder if local git repo is over 1 months out of date -if [ -d "$DIRECTORY" ];then - #first compare local git repo's last-commit-time with the current system time (Unix epoch time format) - current_git_date="$(cd "$DIRECTORY"; git show -s --format=%ct)" - current_local_date="$(date +%s)" - if [ -z "$current_git_date" ] || [ "$current_local_date" -gt $(($current_git_date + 30*60*60*24)) ];then - - #if local git repo's last-commit-time is 3 months older than current system time, now compare the local git repo's last-commit-time with the online repo's modification time to avoid false positives. - #This two-tiered approach prevents unnecessary GitHub API calls and speeds up script's execution for normal usage. - - command -v curl >/dev/null || sudo apt install -y curl - upstream_git_date="$(curl https://api.github.com/repos/Botspot/pi-apps/commits/master 2>&1 | grep '"date":' | tail -n 1 | sed 's/"date"://g' | xargs date +%s -d 2>/dev/null)" - - if [[ "$upstream_git_date" =~ ^[0-9]+$ ]] && ([ -z "$current_git_date" ] || [ "$upstream_git_date" -gt $(($current_git_date + 30*60*60*24)) ]);then - rm -rf ~/pi-apps-forced-update - - echo "Reinstalling Pi-Apps..." - downloaded=1 - output="$(git clone --depth 1 https://github.com/Botspot/pi-apps ~/pi-apps-forced-update 2>&1)" - if [ $? != 0 ] || [ ! -d "$DIRECTORY" ];then - error "Pi-Apps download failed!\ngit clone output was: $output" - fi - cp -af "${DIRECTORY}/data" ~/pi-apps-forced-update - cp -af "${DIRECTORY}/apps" ~/pi-apps-forced-update - rm -rf "$DIRECTORY" - mv -f ~/pi-apps-forced-update "$DIRECTORY" - fi +#Re-download pi-apps folder in all cases if pi-apps already exists +#users expect to use the install script to "restore" a working pi-apps install in incase their local version is somehow not working or corrupted +if [ -d "$DIRECTORY" ];then + rm -rf ~/pi-apps-forced-update + + echo "Reinstalling Pi-Apps..." + downloaded=1 + output="$(git clone --depth 1 https://github.com/Botspot/pi-apps ~/pi-apps-forced-update 2>&1)" + if [ $? != 0 ] || [ ! -d "$DIRECTORY" ];then + error "Pi-Apps download failed!\ngit clone output was: $output" fi + cp -af "${DIRECTORY}/data" ~/pi-apps-forced-update + cp -af "${DIRECTORY}/apps" ~/pi-apps-forced-update + rm -rf "$DIRECTORY" + mv -f ~/pi-apps-forced-update "$DIRECTORY" #if pi-apps folder does not exist, download it elif [ ! -d "$DIRECTORY" ];then