Last active
September 1, 2016 07:00
-
-
Save aanton/e68e0184eb8f8817f3be305271ecf290 to your computer and use it in GitHub Desktop.
Atom auto-update script for Debian/Ubuntu Linux
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
#!/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