Searching for this answer has failed me, perhaps because I'm not asking for it in the right way.
I'm basically looking to use something (wget or curl for example) to retrieve the 2nd line of a text file hosted on github. The whole purpose of this is to determine if the script being used is the most up to date version and automatically update it if not.
Right now, this is how I achieve that...
sudo wget -q https://raw.githubusercontent.com/Wade821/PiDrawpile/master/drawpile-installer-official-build-from-sources sudo chmod 777 "$dpinstallloc/Programs" -R echo dpcheckversion=$(grep -m 1 "drawpilescriptversion=" "$dpinstallloc/Programs/$scriptname" | cut -c 23-26) currentscriptname="$(basename "$(test -L "$0" && readlink "$0" || echo "$0")")" if [[ "$drawpilescriptversion" < "$dpcheckversion" ]]; then echo "Newest Script is using version $dpcheckversion." echo "Newer version of script available, the old script has been copied over" echo "the old script. Please re-run this script to use newest version." cd "$dpinstallloc" sudo rm -rf "$SCRIPTDIR/$currentscriptname" sudo cp "$dpinstallloc/Programs/$scriptname" "$SCRIPTDIR/$currentscriptname" sudo chmod 777 "$SCRIPTDIR/$currentscriptname" sudo rm -rf "$dpinstallloc/Programs/$scriptname" echo "Terminating script in 30 seconds." echo sleep 30s exit elif [[ "$drawpilescriptversion" = "$dpcheckversion" ]]; then echo "Script is newest version available." sudo rm -rf "$dpinstallloc/Programs/$scriptname" elif [[ "$drawpilescriptversion" > "$dpcheckversion" ]]; then echo "It appears the creator of the script has failed to update github with the newest version." echo "Please contact him to update the script there by emailing him at (redacted, minimizing number of posted locations for now)" echo echo "Script in use: $drawpilescriptversion" echo "Github Script: $dpcheckversion" echo echo "Pausing script for 30 seconds before continuing." sudo rm -rf "$dpinstallloc/Programs/$scriptname" sleep 30s else echo "Unable to determine script version, proceeding with script." fi
And while this isn't a particularly bad method, it's not the most efficient since the entire file needs to be downloaded every time. If I could somehow limit it to downloading the specified file line, that would make things faster overall. If no such method exists, I suppose I'll stick with this unless someone has a better idea on how to manage this.
Edit: I should also clarify the script in question is to compile and run a server of the program called Drawpile for use on a Raspberry Pi. Due to differences in versions of available packages, changes sometimes must be made to source code in order to compile successfully. Other times, as new features are added, new packages need to be installed. The idea of a self updating script is to prevent unnecessary reports of "this doesn't work" when in fact an update is available as the user reuses a script or updates the server. Thus, being that this is for end users, using the developer API authentication through github or the token is not a desirable result as that would create a security issue. As such, the solution should not require authentication.