Skip to content

Instantly share code, notes, and snippets.

@bittracker
Created February 20, 2018 14:15
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 bittracker/0c2792d16c1fd11ede57890ef861420a to your computer and use it in GitHub Desktop.
Save bittracker/0c2792d16c1fd11ede57890ef861420a to your computer and use it in GitHub Desktop.
Simple (Auto) update Script for Atom on Debian Based Systems
#!/bin/bash
if [ $UID -ne 0 ]; then
echo "Root Permissons required!"
sudo $0
exit $?
fi
TMP_DIR="/home/bt/tmp"
CURRENT_VERSION="$(atom --version | awk '/Atom/ { printf "%s", $3 }')"
wget -q https://github.com/atom/atom/releases/latest -O /tmp/latest
DL=$(awk -F '[<>]' '/href=".*atom-amd64.deb/ {match($0,"href=\"(.*.deb)\"",a); print "https://github.com" a[1]} ' /tmp/latest)
NEW_VERSION=$(echo $DL | awk 'match($0, "[0-9].[0-9]{1,2}.[0-9]{1,3}", a) {print a[0]}')
if [ $CURRENT_VERSION != $NEW_VERSION ]; then
echo "Update required..."
echo "v$CURRENT_VERSION --> v$NEW_VERSION"
wget -q --show-progress $DL -O "$TMP_DIR/atom_${NEW_VERSION}_amd64.deb"
if [ $? -eq 0 ]; then
echo "Setup..."
dpkg -i "$TMP_DIR/atom_${NEW_VERSION}_amd64.deb"
if [ $? -eq 0 ]; then
echo done
exit 0
fi
fi
echo
echo "Update has been faild! :-("
exit 1
else
echo "Your current Atom Installation is up to date! (v$CURRENT_VERSION)"
exit 0
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment