Last active
August 23, 2016 01:27
-
-
Save laubstein/daeb4c1cc1cf768c2f4054774ce1280a to your computer and use it in GitHub Desktop.
Atom autoupdate
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 | |
dolog() { | |
logger -t atom-update "$*" | |
echo "$*" | |
} | |
dolog "Atom auto update started `date`" | |
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 | |
dolog "New version found at https://github.com/$LATEST" | |
wget -q "https://github.com/$LATEST" -O /tmp/atom-amd64.deb | |
dpkg -i /tmp/atom-amd64.deb | |
dolog "Atom has been update from $VER_INST to $VER_LATEST" | |
else | |
dolog "Atom version $VER_INST is the latest version, no update require" | |
fi | |
dolog "Atom-beta auto update started `date`" | |
wget -q https://github.com/atom/atom/releases -O /tmp/latest | |
MATCHEDROW=$(awk -F '[<>]' '/href=".*atom-amd64.deb/' /tmp/latest | grep beta | head -1) | |
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-beta | tail -n1 | tr -s ' ' | cut -d" " -f 3) | |
if [ "$VER_LATEST" != "$VER_INST" ] | |
then | |
dolog "New version found at https://github.com/$LATEST" | |
wget -q "https://github.com/$LATEST" -O /tmp/atom-amd64.deb | |
dpkg -i /tmp/atom-amd64.deb | |
dolog "Atom has been update from $VER_INST to $VER_LATEST" | |
else | |
dolog "Atom version $VER_INST is the latest version, no update require" | |
fi | |
dolog "Atom auto update finished `date`" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment