Skip to content

Instantly share code, notes, and snippets.

@ledakis
Last active May 19, 2020 12:46
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 ledakis/790a01c7e2b6c00a2d472c824a8eeec4 to your computer and use it in GitHub Desktop.
Save ledakis/790a01c7e2b6c00a2d472c824a8eeec4 to your computer and use it in GitHub Desktop.
I have set up my own code-server (https://github.com/cdr/code-server) and the auto update fails, so here is a script to pull the latest x64 release and install it.
#!/usr/bin/env bash
set -e
INSTALL_DIR="/usr/lib/code-server/"
echo Install dir: $INSTALL_DIR
temp_dir=$(mktemp -d)
old_dir=$(pwd)
cd $temp_dir
curl -L --output code-server.tar.gz $(curl -s https://api.github.com/repos/cdr/code-server/releases/latest | jq -r '.assets[] | select(.name|contains("linux-amd64"))| .browser_download_url')
tar xzf code-server.tar.gz -C $INSTALL_DIR --strip-components=1
echo Updated, new version:
code-server --version
cd $old_dir
echo "Done"
@ledakis
Copy link
Author

ledakis commented May 8, 2020

Requires the INSTALL_DIR to exist, and jq installed.

@ledakis
Copy link
Author

ledakis commented May 8, 2020

Works like that. Maybe the curl could have been silent 🤷‍♂️

bash update_code.sh                                                                                                    
Install dir: /usr/lib/code-server/
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   650  100   650    0     0   2249      0 --:--:-- --:--:-- --:--:--  2249
100 66.0M  100 66.0M    0     0  19.1M      0  0:00:03  0:00:03 --:--:-- 21.5M
Updated, new version:
3.2.0 fd36a99a4c78669970ebc4eb05768293b657716f
Done   

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment