#!/bin/bash # Define directories and files REPO_DIR="$HOME/GR-Jukebox" VERSION_FILE_PATH="$REPO_DIR/version.txt" INSTALLED_VERSION_FILE="$HOME/version.txt" # Function to get version from a file get_version() { if [[ -f "$1" ]]; then cat "$1" else echo "0" fi } # Read the currently installed version and the version in the repository INSTALLED_VERSION=$(get_version "$INSTALLED_VERSION_FILE") REPO_VERSION=$(get_version "$VERSION_FILE_PATH") # Check network connectivity to github.com while ! ping -c 1 -W 1 git-codecommit.us-east-2.amazonaws.com > /dev/null; do echo "Waiting for amazonaws.com - network interface might be down..." sleep 1 done # Fetch and compare the latest version on GitHub without pulling all files cd "$REPO_DIR" git fetch origin REMOTE_VERSION=$(git show origin/master:version.txt) if [[ "$INSTALLED_VERSION" != "$REMOTE_VERSION" ]]; then echo "New version available on AWS. Starting download in background." # Pull the latest changes from the remote repository ( git pull origin master & ) fi