Skip to content

Instantly share code, notes, and snippets.

@voor
Last active March 24, 2017 15:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save voor/5f048b0c61d7db8f0fa3bd820fc87e51 to your computer and use it in GitHub Desktop.
Save voor/5f048b0c61d7db8f0fa3bd820fc87e51 to your computer and use it in GitHub Desktop.
Check atom for latest release and update it if one exists.
#!/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
@voor
Copy link
Author

voor commented Mar 24, 2017

You can run this without downloading it with the following:

bash < <(curl -s https://gist.githubusercontent.com/voor/5f048b0c61d7db8f0fa3bd820fc87e51/raw/53b28d9a3235a1f18ee03e2c1a8146d778448429/update-atom.sh)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment