Skip to content

Instantly share code, notes, and snippets.

@Cxarli
Created March 14, 2016 17:28
Show Gist options
  • Save Cxarli/d6e6498ea4eebd58eb7d to your computer and use it in GitHub Desktop.
Save Cxarli/d6e6498ea4eebd58eb7d to your computer and use it in GitHub Desktop.
Atom Updater
#!/bin/bash
downloadurl=`curl -i "https://atom.io/download/deb" 2>/dev/null | grep "Location: " | cut -d' ' -f2 `
version=`echo "$downloadurl" | grep -Eo "v([0-9]+\.){1,}[0-9]+"`
# Check if file exists
if [ -e .atom-version ]; then
curver=`cat .atom-version`
else
curver="unknown"
fi
echo "Latest version is $version."
echo "Current version is $curver."
echo
if [ "$curver" = "$version" ]; then
# Same version as downloaded version
echo "You're already using the latest version!"
else
# Download new version
if [ -e "atom-amd64-$version.deb" ]; then
echo "Latest version already downloaded."
else
echo "Downloading new version..."
wget -O "atom-amd64-$version.deb" "$downloadurl"
fi
echo
# Install
echo "Installing new version..."
dpkg -i "atom-amd64-$version.deb"
exitcode=$?
echo
if [ $exitcode -ne 0 ]; then
# Failed to Install
echo "[$exitcode] Failed to install atom. Are you running as root?"
else
# Update version file
echo "Succesfully installed latest version!"
echo "$version" > .atom-version
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment