Skip to content

Instantly share code, notes, and snippets.

@seraphyn
Created September 7, 2016 07:23
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 seraphyn/6d5281ad4a37680c526d520a21b520b1 to your computer and use it in GitHub Desktop.
Save seraphyn/6d5281ad4a37680c526d520a21b520b1 to your computer and use it in GitHub Desktop.
Automatic update for the editor atom
#!/bin/bash
wget -q https://github.com/atom/atom/releases/latest -O /tmp/latest
MATCHEDROW=$(awk -F '[<>]' '/href=".*atom-amd64.deb/' /tmp/latest)
LATEST=$(echo $MATCHEDROW | grep -o -P '(?<=href=").*(?=" rel)')
VER_LATEST=$(echo $MATCHEDROW | rev | cut -d"/" -f 2 | rev | sed 's/v//g')
VER_INST=$(dpkg -l atom | tail -n1 | tr -s ' ' | cut -d" " -f 3)
if [ "$VER_LATEST" != "$VER_INST" ]; then
wget --progress=bar -q "https://github.com/$LATEST" -O /tmp/atom-amd64.deb --show-progress
dpkg -i /tmp/atom-amd64.deb
echo "Atom has been update from $VER_LATEST to $VER_INST"
logger -t atom-update "Atom has been update from $VER_LATEST to $VER_INST"
else
echo "Atom version $VER_INST is the latest version, no update require"
logger -t atom-update "Atom version $VER_INST is the latest version, no update require"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment