Seafile 5 on Synology DSM 4

This post explains how to install Seafile 5 on Debian Jessie chroot on top of Synology DSM 4. The instructions are based on the official Seafile Server for Raspberry Pi how to. However, the original guide is for an older version (Seafile 4.1) and some of its steps have changed and are missing/incomplete. Deviations are mentioned explicitly.

In November 2014, I set up ownCloud 7 on my Synology RS409 through SynoCommunity as a personal backup server. My experience from the beginning were very mixed, which is to be expected for such an old piece of hardware (2009). Nonetheless, for over one and a half years, ownCloud served me well by backing up over 200GB of personal data and making it selectively available across different machines.

Since a month or so ownCloud has rendered my Synology completely unusable, specifically the httpd and mysql processes were eating up my RAM and CPU, to the point where connections to it got dropped continuously. Other services on the Synology, like MediaServer, were also affected and became useless. Finally, a repair/upgrade attempt within the Package Manager broke ownCloud completely.

Thus started my quest for something new! There is a plethora of ownCloud alternatives out there (even apart from Dropbox, Google Drive, S3), like BitTorrent Sync, MEGA, Syncthing, and many more. There are many good posts on the web that list all the differences, so I will not reiterate those here.

My file hosting solution needs to be self-hosted, FOSS, mature, stable, and do selective syncing. Moreover it needs to excel at its core function. Other features are not a priority. In fact with ownCloud I used CalDAV and CardDAV, but found it to be painfully slow. So, for me it would be preferable to off load these to a secondary (more capable) server. Seafile stands out with a number of very strong features:

  • Robust and differential file syncing
  • Selective syncing of libraries
  • Multi-platform & WebDAV
  • Strong client-side encryption

These features should all reduce demand for my precious resources (CPU, RAM and data).

The post assumes you already have a Debian Chroot on your Synology. Posting the instruction here would distract too much (maybe for a separate post). For most of you lucky Synology owners out there, Debian should be available on the SynoCommunity repository. It wasn’t showing up for me though. This either had to do with my architecture (supposed to be supported) or my very old DSM version 4.2. There are however some excellent (older) guides here and here (French). I applied these to get an armel Debian Jessie (both guides are for Squeeze) chroot, but the steps are roughly the same.

Prepare the system

The first step is to prepare the system such that all the necessary components can be build. In the original (Raspberry) guide not all packages are mentioned that are needed to build Seafile. These are part of the third apt-get install “batch”.

sudo apt-get install build-essential cmake re2c flex python-setuptools valac uuid-dev intltool
sudo apt-get install libevent-dev libcurl4-openssl-dev libglib2.0-dev libsqlite3-dev libmysqlclient-dev libarchive-dev libtool libjansson-dev libfuse-dev
sudo apt-get install git libssl-dev libonig-dev libldap2-dev

All the following commands assume that we prepare Seafile in a few folders inside your home directory. Feel free to modify these names. Next we need to build and install the libevhtp and libzdb libraries.

cd ~/dev
git clone https://www.github.com/haiwen/libevhtp.git
cd libevhtp/
cmake -DEVHTP_DISABLE_SSL=OFF -DEVHTP_BUILD_SHARED=ON .
make
sudo make install
cd ~/dev
git clone https://www.github.com/haiwen/libzdb.git
cd libzdb

The guide will tell to run autogen.sh next, but there are a few issues with these instructions. First autogen.sh is not marked as an executable. Even though libtool was install through apt-get above, the autogen.sh script complained that it wasn’t throwing:

**Error**: You must have `libtool' installed to compile ccnet.
Get ftp://ftp.gnu.org/pub/gnu/libtool-1.4.tar.gz
(or a newer version if it is available)

To solve these problems, make autgen executable and open it with your favorite editor

chmod +x autogen.sh
nano autogen.sh

and change the line that reads : ${LIBTOOL=libtool} to : ${LIBTOOL=libtoolize}

#!/bin/bash
# Run this to generate all the initial makefiles, etc.

: ${AUTOCONF=autoconf}
: ${AUTOHEADER=autoheader}
: ${AUTOMAKE=automake}
: ${ACLOCAL=aclocal}
if test "${TERM_PROGRAM}" != "Apple_Terminal" ; then
  : ${LIBTOOLIZE=libtoolize}
else
  : ${LIBTOOLIZE=glibtoolize}
fi
: ${LIBTOOL=libtoolize}

srcdir=`dirname $0`
test -z "$srcdir" && srcdir=.

The variable ${LIBTOOLIZE} seems to be set properly, but not used in the script. Save your changes. From here we can continue building and installing the last of the needed system libraries. Lastly make sure to update the library cache.

./autogen.sh
./configure
make
make install
ldconfig

Get all Python libraries

Prepare and install all needed Python libraries. This guide uses the exact same versions as the Seafile 4.1 guide. I have not tried any newer version or installing these libraries through something like pip. Although it is reasonable to assume that others approaches would work too. The only deviation from the guide is that the seahub_thirdpart directory add to the regular PATH variable too.

mkdir -p ~/dev/seahub_thirdpart
cd /tmp
wget https://pypi.python.org/packages/source/p/pytz/pytz-2016.1.tar.gz
wget https://www.djangoproject.com/m/releases/1.8/Django-1.8.10.tar.gz
wget https://pypi.python.org/packages/source/d/django-statici18n/django-statici18n-1.1.3.tar.gz
wget https://pypi.python.org/packages/source/d/djangorestframework/djangorestframework-3.3.2.tar.gz
wget https://pypi.python.org/packages/source/d/django_compressor/django_compressor-1.4.tar.gz
wget https://pypi.python.org/packages/source/j/jsonfield/jsonfield-1.0.3.tar.gz
wget https://pypi.python.org/packages/source/d/django-post_office/django-post_office-2.0.6.tar.gz
wget http://pypi.python.org/packages/source/g/gunicorn/gunicorn-19.4.5.tar.gz
wget http://pypi.python.org/packages/source/f/flup/flup-1.0.2.tar.gz
wget https://pypi.python.org/packages/source/c/chardet/chardet-2.3.0.tar.gz
wget https://labix.org/download/python-dateutil/python-dateutil-1.5.tar.gz
wget https://pypi.python.org/packages/source/s/six/six-1.9.0.tar.gz
wget https://pypi.python.org/packages/source/d/django-picklefield/django-picklefield-0.3.2.tar.gz
wget -O django_constance.zip https://github.com/haiwen/django-constance/archive/bde7f7c.zip
wget https://pypi.python.org/packages/source/j/jdcal/jdcal-1.2.tar.gz
wget https://pypi.python.org/packages/source/e/et_xmlfile/et_xmlfile-1.0.1.tar.gz
wget https://pypi.python.org/packages/source/o/openpyxl/openpyxl-2.3.0.tar.gz
cd ~/dev/seahub_thirdpart/
export PATH="${HOME}"/dev/seahub_thirdpart:$PATH
export PYTHONPATH=.
easy_install -d . /tmp/pytz-2016.1.tar.gz
easy_install -d . /tmp/Django-1.8.10.tar.gz
easy_install -d . /tmp/django-statici18n-1.1.3.tar.gz
easy_install -d . /tmp/djangorestframework-3.3.2.tar.gz
easy_install -d . /tmp/django_compressor-1.4.tar.gz
easy_install -d . /tmp/jsonfield-1.0.3.tar.gz
easy_install -d . /tmp/django-post_office-2.0.6.tar.gz
easy_install -d . /tmp/gunicorn-19.4.5.tar.gz
easy_install -d . /tmp/flup-1.0.2.tar.gz
easy_install -d . /tmp/chardet-2.3.0.tar.gz
easy_install -d . /tmp/python-dateutil-1.5.tar.gz
easy_install -d . /tmp/six-1.9.0.tar.gz
easy_install -d . /tmp/django-picklefield-0.3.2.tar.gz
easy_install -d . /tmp/django_constance.zip
easy_install -d . /tmp/jdcal-1.2.tar.gz
easy_install -d . /tmp/et_xmlfile-1.0.1.tar.gz
easy_install -d . /tmp/openpyxl-2.3.0.tar.gz

Build Seafile components

Next we need to prepare libsearpc, ccnet, seafile, seahub, seafobj, and seafdav. Apart from libsearpc, all components should have the same version number. We also need to temporarily add the following directories to the PKG_CONFIG_PATH.

export PKG_CONFIG_PATH="${HOME}"/dev/seafile/lib:"${HOME}"/dev/libsearpc:"${HOME}"/dev/ccnet:"${PKG_CONFIG_PATH}"

For each component, get the source files from GitHub, switch to the specific version and build.

cd ~/dev
git clone https://github.com/haiwen/libsearpc.git
cd libsearpc
git reset --hard v3.0-latest
./autogen.sh
./configure
make dist
cd ~/dev
git clone https://github.com/haiwen/ccnet.git
cd ccnet/
git reset --hard v5.1.1-server
./autogen.sh
./configure
make dist
cd ~/dev
git clone https://github.com/haiwen/seafile.git
cd seafile
git reset --hard v5.1.1-server
/autogen.sh
./configure
make dist
cd ~/dev
git clone https://github.com/haiwen/seahub.git
cd seahub
git reset --hard v5.1.1-server
./tools/gen-tarball.py --version=5.1.1 --branch=HEAD
cd ~/dev
git clone https://github.com/haiwen/seafobj.git
cd seafobj
git reset --hard v5.1.1-server
make dist
cd ~/dev
git clone https://github.com/haiwen/seafdav.git
cd seafdav
git reset --hard v5.1.1-server
make

Package and deploy Seafile

Now all the components have been (finally) prepared, the Seafile server package can be build.

mkdir ~/seafile-sources
cp ~/dev/libsearpc/libsearpc-1.2.2.tar.gz ~/seafile-sources
cp ~/dev/ccnet/ccnet-5.1.1.tar.gz ~/seafile-sources
cp ~/dev/seafile/seafile-5.1.1.tar.gz ~/seafile-sources
cp ~/dev/seahub/seahub-5.1.1.tar.gz ~/seafile-sources
cp ~/dev/seafobj/seafobj.tar.gz ~/seafile-sources
cp ~/dev/seafdav/seafdav.tar.gz ~/seafile-sources
mkdir ~/seafile-server-pkgs
~/dev/seafile/scripts/build/build-server.py --libsearpc_version=1.2.2 --ccnet_version=5.1.1 --seafile_version=5.1.1 --version=5.1.1 --srcdir= --thirdpartdir="${HOME}"/dev/seahub_thirdpart --srcdir="${HOME}"/seafile-sources --outputdir="${HOME}"/seafile-server-pkgs

With Seafile successfully build and packaged, you can follow the official deployment guide. The steps are summarized below, where you should replace myseafile with a name of your choosing, such as the server name.

mkdir -p ~/myseafile/installed
cd ~/myseafile
cp ~/seafile-server-pkgs/seafile-server_5.1.1_pi.tar.gz .
tar -xvf seafile-server_5.1.1_pi.tar.gz
mv seafile-server_5.1.1_pi.tar.gz installed/
cd seafile-server-5.1.1/
./setup-seafile.sh
./seafile.sh start
./seahub.sh start

You will be prompted with some instructions on the screen, follow these. The Seafile and Seahub servers should be available on your Synology’s IP address.

Recent Posts

Categories

koffieanon Written by:

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.