Last active
March 24, 2017 15:29
-
-
Save voor/5f048b0c61d7db8f0fa3bd820fc87e51 to your computer and use it in GitHub Desktop.
Check atom for latest release and update it if one exists.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env sh | |
set -e | |
command -v jq >/dev/null 2>&1 || { echo >&2 "I require jq but it's not installed. Aborting."; exit 1; } | |
command -v curl >/dev/null 2>&1 || { echo >&2 "I require curl but it's not installed. Aborting."; exit 1; } | |
INSTALLED_ATOM=`rpm -q --queryformat '%{version}' atom` | |
LATEST_ATOM=`curl -s https://api.github.com/repos/atom/atom/releases/latest | jq --raw-output -c '.name'` | |
COMPARE=`printf "$INSTALLED_ATOM\n$LATEST_ATOM\n" | sort -V | tail -n1` | |
if [ "$COMPARE" == "$INSTALLED_ATOM" ]; then | |
echo "Latest verion is installed, no further action" | |
else | |
echo "Newer version available: $LATEST_ATOM" | |
sudo dnf install -y `curl -s https://api.github.com/repos/atom/atom/releases/latest | jq --raw-output -c '.assets[] | select(.name | contains("atom.x86_64.rpm")) | .browser_download_url'` | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can run this without downloading it with the following: