Our Blog

Stuff about the modern world…

Seafile Client on Synology Diskstation

Posted by Christoph Haas on 19 11 2015. 2 Kommentare zu Seafile Client on Synology Diskstation

I have been using Seafile as an ownCloud replacement for a while now. ownCloud is a great software, but the synchronisation performance is very weak. And in my opinion they do not really concentrate on their main business – file synchronisation – instead they are developing many other features and leave the sync stuff incomplete.

As I just need a file sync solution (Calendar, Mail and Contacs are handled via Zarafa very well) I stumbled across Seafile. It looks really promising and also the sync speed is significantly better then with ownCloud.

Synchronisation clients are available for nearly every platform – except Synology Diskstation. But I wanted to sync my Diskstation with the Seafile Server – and managed to do it.

At first I have tried the Synology Cloud Sync – using the WebDAV option to sync files to Seafile. This solution has one big downside: file timestamps get altered after they where synced to Seafile. Also the lack of syncing more then one folder (which will be fixed in DSM 6.0) made me look for another solution.

Seafile-CLI

Seafile offers a CLI client for Linux. The problem is, that this Client does not run on DSM directly. So here comes a tutorial to setup Seafile-Cli on a Synology Diskstation.
I have tested it on a DS214play – any other DS with x86 CPU should work fine.

 

Setup tutorial

To run the Seafile Client, a Debian Chroot is required.

Debian Chroot on DSM

First we need to install the Debian Chroot from https://synocommunity.com/:

Step 1

Log into your NAS as administrator and go to Main Menu → Package Center → Settings and set Trust Level to Synology Inc. and trusted publishers.

Step 2

In the Package Sources tab, click Add, type SynoCommunity as Name and http://packages.synocommunity.com/ as Location and then press OK to validate.

Step 3

Go back to the Package Center and enjoy SynoCommunity’s packages in the Community tab.

Step 4

Install the Debian Chroot package.

The package will be installed and then marked as stopped. That is completely ok for now. You should find a „Debian Chroot“ button in your app overview. Start „Debian Chroot“ from there and a small window will show you the installation status of Debian. If the status is set to „Installed“ the chroot has finished installing and is ready to use. This process might take some time.

More information can be found here: https://github.com/SynoCommunity/spksrc/wiki/Debian-Chroot

Step 4

Configure the Debian Chroot package.

To configure the Chroot you have to login as root via SSH to your NAS. After you have logged in you can start the changeroot via

/var/packages/debian-chroot/scripts/start-stop-status chroot

On the first use, it is recommended to perform some configuration operations:

apt-get update && apt-get upgrade
apt-get install locales 
dpkg-reconfigure locales                 #(for example: de-DE-UTF8, en-US-UTF8)
dpkg-reconfigure tzdata

Then leave the chroot by pressing Ctrl+D (or type exit).
Now we need to allow the chroot to access our data disk – otherwise Seafile won’t be able to sync our files.

Change the chroot startup script:

vi /var/packages/debian-chroot/scripts/start-stop-status

Add the following to the start_daemon block (~line 22 above # Start all services):

[ ! -d ${CHROOTTARGET}/volume1 ] && mkdir -p ${CHROOTTARGET}/volume1
grep -q "${CHROOTTARGET}/volume1 " /proc/mounts || mount -o bind /volume1 ${CHROOTTARGET}/volume1

And the following to the end of the stop_daemon block:

umount ${CHROOTTARGET}/volume1

 

Thats how those blocks should look like after the modification:

start_daemon ()
{
 # Mount if install is finished
 if [ -f ${INSTALL_DIR}/var/installed ]; then
 # Make sure we don't mount twice
 grep -q "${CHROOTTARGET}/proc " /proc/mounts || mount -t proc proc ${CHROOTTARGET}/proc
 grep -q "${CHROOTTARGET}/sys " /proc/mounts || mount -t sysfs sys ${CHROOTTARGET}/sys
 grep -q "${CHROOTTARGET}/dev " /proc/mounts || mount -o bind /dev ${CHROOTTARGET}/dev
 grep -q "${CHROOTTARGET}/dev/pts " /proc/mounts || mount -o bind /dev/pts ${CHROOTTARGET}/dev/pts

 [ ! -d ${CHROOTTARGET}/volume1 ] && mkdir -p ${CHROOTTARGET}/volume1
 grep -q "${CHROOTTARGET}/volume1 " /proc/mounts || mount -o bind /volume1 ${CHROOTTARGET}/volume1
 # Start all services
 ${INSTALL_DIR}/app/start.py
 fi
}

stop_daemon ()
{
 # Stop running services
 ${INSTALL_DIR}/app/stop.py

 # Unmount
 umount ${CHROOTTARGET}/dev/pts
 umount ${CHROOTTARGET}/dev
 umount ${CHROOTTARGET}/sys
 umount ${CHROOTTARGET}/proc
 umount ${CHROOTTARGET}/volume1
}

If your main disk is not called „volume1“ change the name accordingly. More information can be found here: http://www.hang321.net/en/2014/08/16/debian-chroot-on-dsm/

 

Seafile Client installation

The next step is installing the Seafile-Cli Client. The Seafile-Cli client on the Website is outdated, but the Seafile-Client also contains the latest Seafile-Cli binary. So just download the normal Seafile-Client .deb file from here: https://www.seafile.com/en/download/

Now install the downloaded deb file:

dpkg -i seafile_4.4.2_amd64.deb
apt-get install -f
dpkg -i seafile_4.4.2_amd64.deb
apt-get install python

Python is needed for Seafile-CLI to run.

In the next step we are going to configure Seafile-Cli following the official manual from here: https://seacloud.cc/group/3/wiki/seafile-cli-manual/.

mkdir -p /etc/pki/tls/certs
cp /etc/ssl/certs/ca-certificates.crt /etc/pki/tls/certs/ca-bundle.crt
ln -s /etc/pki/tls/certs/ca-bundle.crt /etc/pki/tls/cert.pem
mkdir /root/.seafile-client
seaf-cli init -d /root/.seafile-client
seaf-cli config -k enable_http_sync -v true
seaf-cli start

Now the seafile daemon is setup and ready for use.

Adding shares

If you want to add a folder to sync use the following command:

seaf-cli sync -l "<Library ID>" -s "https://seafile.yourserver.com" -d "/volume1/testing/" -u "username@mail.com"

The library ID can be found via the Seafile webinterface: click on your library and copy the id from the browser URL.

 

Autostart Seafile Client

In the last step we will configure the Seafile Service to automatically start after boot. Therefore a init script is needed:

nano /etc/init.d/seaf-cli
#! /bin/sh
### BEGIN INIT INFO
# Provides: seaf-cli 
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Simple start script for seafile cli
# Description: Should be placed in /etc/init.d.
### END INIT INFO

# Author: Sven Knuth <sven.knuth@yawc.de>

# Do NOT "set -e"

# PATH should only include /usr/* if it runs after the mountnfs.sh script
PATH=/sbin:/usr/sbin:/bin:/usr/bin
DESC="Seafile Commandline"
NAME=seaf-cli
DAEMON=/usr/bin/$NAME

USER=root

# Define LSB log_* functions.
# Depend on lsb-base (>= 3.2-14) to ensure that this file is present
# and status_of_proc is working.
. /lib/lsb/init-functions

do_start()
{
    su -c "$DAEMON start" - $USER
}

do_stop()
{
    su -c "$DAEMON stop" - $USER
}

case "$1" in
 start)
   [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
   su -c "$DAEMON status" - $USER > /dev/null 2>&1
   case "$?" in
     0) echo "$DAEMON already started" ;;
     1) do_start
   esac
   ;;
 stop)
   [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
   su -c "$DAEMON status" - $USER > /dev/null 2>&1
   case "$?" in
     1) echo "$DAEMON already stopped" ;;
     0) do_stop ;;
   esac
   ;;
 status)
   su -c "$DAEMON status" - $USER > /dev/null 2>&1
   case "$?" in
     1) echo "$DAEMON not started" ;;
     0) su -c "$DAEMON status" - $USER
   esac
   ;;
 *)

 echo "Usage: $SCRIPTNAME {start|stop|status}" >&2
 exit 3
 ;;
esac

:

The original script is from: http://wp.yawc.de/2015/01/seafile-cli-autostart/

Make the script executable:

chmod +x /etc/init.d/seaf-cli

 

DSM Chroot Manager

Open the Chroot App in DSM and switch to „Services“ on the left tab.

Add a new service:

Name: Seafile
Launch Script: /etc/init.d/seaf-cli
Status Command: ps ax | grep seaf-daemon | grep -v grep

 

Thats it – now you can sync your Diskstation to any Seafile Server with the official sync client.

 

Update:

In order to keep the user and group ownership on the NAS i found a patch for seafile that allows us to set UID and GID for each share. Thanks to denis-b:

https://github.com/denis-b/seafile.git

I have merged his changes with the latest 5.0.0 seafile client and compiled packages for Debian 8 32bit. Download: seafile-5.0.0 (newer version: seafile-5.0.7 or seafile-5.1.2 or seafile-5-1-4)

To install, you first have to remove the old seafile client by:

apt-get remove seafile

Then install the new packages by typing:

cd seafile-5.0.0
dpkg -i *.deb

And afterwards you have to reconfigure the shares.

rm -rf /root/.seafile-data
rm -rf /root/.ccnet

Now continue from the the top of this turorial but add -U <UID> -G <GID> to the seaf-cli sync command.

Comments ( 2 )

Schreibe einen Kommentar

  • Marcus Meisenberg

    Hi! Thank you for this post. Unfortunately I need some more details concerning the part "Seafile Client installation". How exactly do I downlod the deb-File. How do I get it into my NAS so that I can insall it? Regards, Marcus September 16, 2016 at 8:59 am

    • Christoph Haas

      Hi, download the deb from the given download link: https://blog.sprinternet.at/wp-content/uploads/2015/11/seafile-5.1.4.zip Store it on your NAS (maybe a samba share or upload it via sftp/scp). There you can install it via "dpkg -i *.deb" and "apt-get install -f". But this is all explained in the README.txt in the zip file. September 19, 2016 at 6:44 pm