Last active
December 24, 2015 23:39
-
-
Save viktorlindgren/6881338 to your computer and use it in GitHub Desktop.
Seafile linux client update script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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