Skip to content

Instantly share code, notes, and snippets.

@viktorlindgren
Last active December 24, 2015 23:39
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 viktorlindgren/6881338 to your computer and use it in GitHub Desktop.
Save viktorlindgren/6881338 to your computer and use it in GitHub Desktop.
Seafile linux client update script
#!/bin/bash
# Create dirs if not exists
mkdir -p ~/bin ~/seaf-cli
cd ~/seaf-cli
# Remove any old or failed updates
rm -rf ~/seaf-cli/*.tar*
# Get download address
arch=$(uname -m | sed s/"_"/"-"/g)
regexp="http(s?):\/\/[^ \"\(\)\<\>]*seafile-cli_[\d\.\_]*$arch.tar.gz"
addr=`wget http://www.seafile.com/en/download/ -O - | grep --only-matching --perl-regexp "$regexp" | head -1`
wget $addr || (echo FAIL! No update address could be found && exit 1);
# Remove old version and cleanup some temp files
~/bin/seaf-cli stop
rm -rf ~/seafile-client/seafile-data/blocks
rm -rf ~/seaf-cli/seafile-cli-*/
# Installing the new version
tar -xf *.tar*
rm *.tar*
# Update symlink
rm ~/bin/seaf-cli
ln -s ~/seaf-cli/seafile-cli-*/seaf-cli ~/bin/seaf-cli
~/bin/seaf-cli start
cd -
echo Update completed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment