Skip to content

Instantly share code, notes, and snippets.

@aanton
Last active September 1, 2016 07:00
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 aanton/e68e0184eb8f8817f3be305271ecf290 to your computer and use it in GitHub Desktop.
Save aanton/e68e0184eb8f8817f3be305271ecf290 to your computer and use it in GitHub Desktop.
Atom auto-update script for Debian/Ubuntu Linux
#!/bin/bash
if [ $EUID != 0 ]; then
echo "You must be root to run this script" 1>&2
exit 1
fi
URL_RELEASES="https://github.com/atom/atom/releases/latest"
NEW_RELEASE=$(curl -sL $URL_RELEASES | egrep -o 'href="([^"#]+)atom-amd64.deb"' | cut -d'"' -f2 | sort | uniq)
NEW_VERSION=$(echo $NEW_RELEASE | egrep -o '[0-9]+\.[0-9]+\.[0-9]+')
CURRENT_VERSION=$(atom --version | fgrep Atom | awk '{print $3}')
if [[ -z "$NEW_VERSION" ]]; then
echo "New version could not be detected from $URL_RELEASES"
elif [[ $NEW_VERSION == $CURRENT_VERSION ]]; then
echo "Current version $CURRENT_VERSION is the latest available"
else
echo "Current version $CURRENT_VERSION is not the latest available $NEW_VERSION -> Updating ..."
wget --progress=bar -q "https://github.com$NEW_RELEASE" -O /tmp/atom-amd64.deb -q --show-progress
dpkg -i /tmp/atom-amd64.deb
rm /tmp/atom-amd64.deb
fi
exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment