54

Automatic update of Atom feature is not yet supported for Ubuntu. From their GitHub repository:

Currently only a 64-bit version is available.

Download atom-amd64.deb from the Atom releases page. Run sudo dpkg --install atom-amd64.deb on the downloaded package. Launch Atom using the installed atom command. The Linux version does not currently automatically update so you will need to repeat these steps to upgrade to future releases.

I tried using Webupd8 PPA but it doesn't work for me.

Josh Pinto
  • 8,089
Igor V.
  • 948
  • 2
  • 9
  • 16

12 Answers12

70

TL;DR If you do not want to use the PPA, you can use a script to download and automatically install via cron.


  1. Create a new file atom-auto-update

    sudo nano /usr/local/bin/atom-auto-update
    
  2. Add the following lines

    #!/bin/bash
    wget -q https://github.com/atom/atom/releases/latest -O /tmp/latest
    wget -q $(awk -F '[<>]' '/href=".*atom-amd64.deb/ {match($0,"href=\"(.*.deb)\"",a); print "https://github.com/" a[1]} ' /tmp/latest) -O /tmp/atom-amd64.deb
    dpkg -i /tmp/atom-amd64.deb
    
  3. Save the file and make it executable

    sudo chmod +x /usr/local/bin/atom-auto-update
    
  4. Test the script

    sudo atom-auto-update
    
  5. Create a cronjob for the script

    sudo crontab -e
    
  6. Add this line

    e.g.: at 10 am every week

    0 10 * * 1 /usr/local/bin/atom-auto-update
    

    e.g.: at 10 am every day

    0 10 * * * /usr/local/bin/atom-auto-update      
    

Explanation

  • wget -q https://github.com/atom/atom/releases/latest -O /tmp/latest

    Download the site with the latest version information

  • wget -q $(awk -F '[<>]' '/href=".*atom-amd64.deb/ {match($0,"href=\"(.*.deb)\"",a); print "https://github.com/" a[1]} ' /tmp/latest) -O /tmp/atom-amd64.deb

    1. … awk -F '[<>]' '/href=".*atom-amd64.deb/ {match($0,"href=\"(.*.deb)\"",a); print "https://github.com/" a[1]} ' /tmp/latest …

      Extract the download link

    2. wget -q $( … ) -O /tmp/atom-amd64.deb

      Download the DEB file

  • dpkg -i /tmp/atom-amd64.deb

    Install the DEB file

A.B.
  • 92,125
21

A.B's Answer is a nice solution! I added show progress bar option in the bash code to notify progress: 

#!/bin/bash
wget -q https://github.com/atom/atom/releases/latest -O /tmp/latest
wget --progress=bar -q 'https://github.com'$(cat /tmp/latest | grep -o -E 'href="([^"#]+)atom-amd64.deb"' | cut -d'"' -f2 | sort | uniq) -O /tmp/atom-amd64.deb -q --show-progress
dpkg -i /tmp/atom-amd64.deb
smerlin
  • 103
whiite
  • 311
5

As the previous answer with minor modification, to let updating on start-up, here is the procedure

  1. Create file by running the command:

     sudo nano /usr/local/bin/atom-update  
    

    then type the below script (use text-editor like "gedit" or "mousepad" instead of "nano" is more convenient) and then save it.

    #!/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_INST to $VER_LATEST" 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

  2. To make the file executable:

     sudo chmod +x /usr/local/bin/atom-update
    
  3. Now you could manually update Atom by typing the command:

     sudo atom-update
    
  4. Login to your root, and then add the below row to /etc/rc.local (sudo nano /etc/rc.local) just before exit 0 command:

     /usr/local/bin/atom-update  
    

This will let the atom update script execute every time you turn on your PC.

  1. To check that the script has run properly on start up, restart your PC and open the terminal then type:

     cat /var/log/syslog | grep 'atom.*'  
    

You will see the log message accordingly.

Pablo Bianchi
  • 17,371
Chukiat
  • 51
  • 1
  • 3
3

Building on A.B's answer, I've added version checking to avoid unnecessary download/install:

#!/bin/bash

TMP_DIR=$(mktemp -d)

TMP_LATEST="${TMP_DIR}/latest"
TMP_FILE="${TMP_DIR}/atom-amd64.deb"

wget -q https://github.com/atom/atom/releases/latest -O ${TMP_LATEST}
LATEST=$(awk -F '[<>]' '/href=".*atom-amd64.deb/ {match($0,"href=\"(.*.deb)\"",a); print "https://github.com/" a[1]} ' ${TMP_LATEST})
VER_LATEST=$(echo $LATEST | 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 -q $LATEST -O $TMP_FILE
  VER_DOWN=$(dpkg-deb -f $TMP_FILE Version)
  if [ "$VER_DOWN" != "$VER_INST" ]; then
    dpkg -i $TMP_FILE
  fi
fi

rm -rf "${TMP_DIR}"

Edit: I should clarify that this would replace the content of the /usr/local/bin/atom-auto-update script which A.B's answer mentions. The other steps of the answer are the same.

hordur
  • 111
3

Well, another more elegant version with support of beta branch, if script launched with beta argument: $ update-atom beta

#!/bin/bash
DLPATH="https://atom.io/download/deb"
DLDEST="$HOME/Downloads/atom-amd64.deb"

if ! [ -z "$1" ] && [ $1=="beta" ];  then
  echo "Updating beta"
  DLPATH="$DLPATH?channel=beta"
  DLDEST="$HOME/Downloads/atom-amd64-beta.deb"
else
  echo "Updating stable"
fi

rm -f $DLDEST
wget -O $DLDEST $DLPATH 
sudo dpkg -i $DLDEST
muru
  • 207,228
2

Installing Atom via a snap will ensure you always have the latest version:

sudo snap install atom --classic
Jorge Castro
  • 73,717
1

I have written a Python script which can be used to update the 64 bits DEB package from GitHub. You can save the following content as update-atom, for example in /etc/cron.hourly or /etc/cron.daily:

#!/usr/bin/env python

import os
import requests


def msg(text):
    """Give message to user."""
    os.system('notify-send "Atom updater" "{}"'.format(text))


def current():
    """Get current version."""
    f = os.popen("apt show atom 2>/dev/null | grep Ver")
    return f.read().split(' ')[1].strip()


def latest():
    """Get latest version."""
    upd_url = 'https://github.com/atom/atom/releases/latest'
    final = requests.get(upd_url).url
    return final.split('tag/v')[1]


def compare(cv, lv):
    """Compare versions."""
    return lv.split('.') > cv.split('.')


def upgrade(version):
    """Perform upgrade."""
    tempfile = '/tmp/atom.deb'
    url = (
        'https://github.com/atom/atom/releases/download/'
        'v{}/atom-amd64.deb'.format(version)
    )
    code = os.system(
        'rm -f {} && '
        'wget "{}" -O {} && '
        'dpkg -i {}'.format(tempfile, url, tempfile, tempfile)
    )
    return code == 0

if __name__ == '__main__':
    cv = current()
    try:
        lv = latest()
    except requests.exceptions.ConnectionError:
        print 'No network'
        exit(0)
    print 'Current version', cv
    print 'Latest version', lv
    result = compare(cv, lv)
    if result:
        print 'A new version is available!'
        msg('Updating Atom to version {}...'.format(lv))
        if upgrade(lv):
            msg('Update completed.')
        else:
            msg('Problem during update.')
    else:
        print 'Atom is updated.'
1

For a less ubuntu-specific approach, I wrote a small atom package that check for new versions at startup (or you can check manually with a handy command within Atom).

It's platform independent (so it works on any linux distro, windows, etc...).

You can configure a few things like only monitoring the stable channel or the beta too, having notifications, what type, and if they should be dismissable, etc...).

It does not (at least for now!) automatically update the package. I may add that feature in the future if there is enough interest in it.

Feedback welcome, best as tickets on github.

mac
  • 308
0

A couple of mods to the python script by Andrea Lazzarotto to remove the dependency on notify-send which other Ubuntu variants don't have by default and handle the case where there isn't already a copy of atom installed. Also, it should be noted there are other dependencies you'll need too:

sudo apt-get install python-requests git gvfs-bin

I also had to run the following to get some other sub-dependencies...

sudo apt-get -f install

#!/usr/bin/env python
import os
import requests

def msg(text):
  """Give message to user."""
  os.system('notify-send "Atom updater" "{}"'.format(text)
  + ' 2>/dev/null '
  +'|| echo "{}"'.format(text))

def current():
    """Get current version."""
    f = os.popen("apt show atom 2>/dev/null | grep Ver")
    result = f.read()
    if result:
      return result.split(' ')[1].strip()
    return "0.0"

def latest():
    """Get latest version."""
    upd_url = 'https://github.com/atom/atom/releases/latest'
    final = requests.get(upd_url).url
    return final.split('tag/v')[1]

def compare(cv, lv):
    """Compare versions."""
    return lv.split('.') > cv.split('.')

def upgrade(version):
    """Perform upgrade."""
    tempfile = '/tmp/atom.deb'
    url = (
        'https://github.com/atom/atom/releases/download/'
        'v{}/atom-amd64.deb'.format(version)
    )
    code = os.system(
        'rm -f {} && '
        'wget "{}" -O {} && '
        'dpkg -i {}'.format(tempfile, url, tempfile, tempfile)
    )
    return code == 0

if __name__ == '__main__':
    cv = current()
    try:
        lv = latest()
    except requests.exceptions.ConnectionError:
        print 'No network'
        exit(0)
    print 'Current version', cv
    print 'Latest version', lv
    result = compare(cv, lv)
    if result:
        print 'A new version is available!'
        msg('Updating Atom to version {}...'.format(lv))
        if upgrade(lv):
            msg('Update completed.')
        else:
            msg('Problem during update.')
    else:
        msg('Atom is updated.')
muru
  • 207,228
0

If you're building from sources, I do this via a small script:

cd "/home/YOUR_USER/gitmisc/atom/"
git pull
cd script/
sudo ./build --install                   
0

May 6, 2016

Andy Richardson made atom-updater-linux. It's atom package, you can have it on your atom by running:

apm install atom-updater-linux

consult the repository for more information

0

Yet another custom (Python) script to help updating atom: https://gist.github.com/DusanMadar/8f094ef647a0ad54cff1