Seafile is an open source Dropbox alternative that offer encryption on client-side (data is stored encrypted on the server and server don't have password). This article mostly follows Seafile manual installation process and describe how to install Seafile in a Debian chroot running on a Synology DiskStation NAS.

Install packages

As a reference, Seafile documentation to install this software from source is available from https://manual.seafile.com/build_seafile/server.html. This procedure follows the official documentation to install Seafile 6.0.x with details specific to Debian distribution and packages; it assume you already set up a Debian chroot on Synology and you are running a Debian Jessie.

Install development libraries

Most of libraries are available as debian packages:

~$ aptitude libevent-dev libcurl4-openssl-dev libglib2.0-dev uuid-dev intltool libsqlite3-dev libarchive-dev libtool libjansson-dev valac libfuse-dev

Only exception is libevhtp: a special version of this library is required.

~$ mkdir libs 
~$ cd libs
~$ wget https://github.com/ellzey/libevhtp/archive/1.1.6.zip

Decompress library and use cmake to compile and install it.

~$ aptitude install cmake
~$ cmake .
~$ make
~$ sudo make install

Next install packages for seahub, the Python web front end. Some python libraries aren't available from Debian packages and Seafile 6.0.x require Django 1.8.

~$ aptitude install python2.7 python-simplejson python-chardet gunicorn python-imaging python-six
~$ # Some python lib aren't available from Debian.
~$ aptitude install python-pip
~$ pip install django==1.8
~$ pip install https://github.com/haiwen/django-constance/archive/bde7f7c.zip # django-constance
~$ pip install django-compressor==1.4
~$ pip install django-statici18n==1.1.3
~$ pip install pytz==2014.3
~$ pip install flup==1.0.2
~$ pip install djangorestframework==3.6.2
~$ pip install django-post_office==2.0.8
~$ pip install openpyxl==2.4.5
~$ pip install django-picklefield==0.3.2

Prepare Seafile projects

Add user and prepare project layout. Fill ORGANIZATION_NAME with anything more suitable to describe your Seafile installation (company or domain name).

~$ ORGANIZATION_NAME=
~$ adduser seafile
~$ su seafile
~$ cd
~$ mkdir -p $ORGANIZATION_NAME/seafile-server
~$ cd $ORGANIZATION_NAME/seafile-server

Get the source. This time, replace VERSION with Seafile latest version. I used version 3.1-latest for libsearpc and version 6.0.8 for seafile.

~$ mkdir src
~$ cd src
~$ VERSION=3.1-latest
~$ wget https://github.com/haiwen/libsearpc/archive/v${VERSION}.tar.gz
~$ tar xf v${VERSION}.tar.gz
~$ rm v${VERSION}.tar.gz
~$ VERSION=6.0.8
~$ wget https://github.com/haiwen/ccnet-server/archive/v${VERSION}-server.tar.gz
~$ tar xf v${VERSION}-server.tar.gz
~$ rm v${VERSION}-server.tar.gz
~$ wget https://github.com/haiwen/seafile-server/archive/v${VERSION}-server.tar.gz
~$ tar xf v${VERSION}-server.tar.gz
~$ rm v${VERSION}-server.tar.gz
~$ cd ..
~$ wget https://github.com/haiwen/seahub/archive/v${VERSION}-server.tar.gz
~$ tar xf v${VERSION}-server.tar.gz
~$ rm v${VERSION}-server.tar.gz
~$ mv seahub-${VERSION}-server seahub

Compile Seafile

Build and install seafile projects. Autogen, configure and make commands can be run as user seafile but "make install" command require root privileges.

~$ VERSION=3.1-latest
~$ cd src/libsearpc-${VERSION}
~$ ./autogen.sh
~$ ./configure
~$ make
~$ make install
~$ VERSION=6.0.8
~$ ~$ cd ../ccnet-server-${VERSION}-server
~$ ./autogen.sh
~$ ./configure --without-mysql --without-postgresql # `export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig` if libsearpc is not found
~$ make
~$ make install
~$
~$ cd ../seafile-server-${VERSION}-server

The seafile-controller executable require a small fix. At startup, this program define its configuration, bin and pids folders based on binary location. Being installed in /usr/local/bin instead of being in seafile-server subfolder, the startup fails. To fix it, edit init_seafile_path in controller/seafile-controller.c:

static void
init_seafile_path (char *config_dir)
{
topdir = g_path_get_dirname (config_dir);
installpath = g_build_filename (topdir, "seafile-server", NULL);
}

You also have to update the call to init_seafile_path in the first line of the seaf_controller_init function:

static int
seaf_controller_init (SeafileController *ctl,
char *config_dir,
char *seafile_dir,
char *logdir,
gboolean cloud_mode)
{
init_seafile_path (config_dir);

Now complete compilation of seafile-server with this small fix.

~$ ./autogen.sh
~$ ./configure --without-mysql --without-postgresql
~$ make
~$ make install

Deploy Seafile

As seafile user, go to top directory and start Seafile setup script

~$ cd ~/$ORGANIZATION_NAME
~$ export PYTHONPATH=/home/seafile/$ORGANIZATION_NAME/seafile-server/seahub/thirdpart
~$ seafile-admin setup

Answer some questions and finally start seafile

~$ seafile-admin setup

Seafile should now be launched and accessible from your NAS

Seafile auto startup

The seafile-admin command must be launched by user seafile from the top directory. As seafile user, create a script to launch this command.

~$ cd ~/$ORGANIZATION_NAME/
~$ cat >> start_seafile.sh << EOF
~$ #!/bin/bash
~$ cd `dirname $0`
~$ seafile-admin start
~$ EOF
~$ chmod +x start_seafile.sh

Then as root install sudo

~$ aptitude install sudo

Latest part is to add this script to the Synology boot sequence. If you already have a S99chrootDebian.sh script, just append to it:

~$ cat >> /usr/local/etc/rc.d/S99chrootDebian.sh << EOF
~$ # Start seafile
~$ chroot \$CHROOT /usr/bin/sudo -u seafile /bin/bash /home/seafile/<organization_name>/start_seafile.sh
~$ EOF
~$ chmod 755 /usr/local/etc/rc.d/S99chrootDebian.sh

Comments   

# cmake libevhtp failsthanatos 2017-04-07 14:54
hey there,
found your guide and wanted to try it, but I'm failing miserably when it comes to the libevhtp library.
cmake . gives me the following error and I don'T know how to fix this:

Code:root@array:/libs# cd libevhtp-1.1.6/
root@array:/libs/libevhtp-1.1.6# cmake .
CMake Error: CMake was unable to find a build program corresponding to "Unix Makefiles". CMAKE_MAKE_PROGRAM is not set. You probably need to select a different build tool.
CMake Error: Error required internal CMake variable not set, cmake may be not be built correctly.
Missing variable is:
CMAKE_C_COMPILER_ENV_VAR
CMake Error: Error required internal CMake variable not set, cmake may be not be built correctly.
Missing variable is:
CMAKE_C_COMPILER
CMake Error: Could not find cmake module file:/libs/libevhtp-1.1.6/CMakeFiles/CMakeCCompiler.cmake
CMake Error: Error required internal CMake variable not set, cmake may be not be built correctly.
Missing variable is:
CMAKE_CXX_COMPILER_ENV_VAR
CMake Error: Error required internal CMake variable not set, cmake may be not be built correctly.
Missing variable is:
CMAKE_CXX_COMPILER
CMake Error: Could not find cmake module file:/libs/libevhtp-1.1.6/CMakeFiles/CMakeCXXCompiler.cmake
CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
-- Configuring incomplete, errors occurred!
root@array:/libs/libevhtp-1.1.6#


any help appreciated,
cheers
Reply
# neo73 2017-05-30 09:29
Hi thanatos, thanks for your feedback.
I might have missed a few packages here.
Please check you have the packages make and gcc installed on your system using:
Code:dpkg -l | grep -e make -e gcc
If not just run aptitude install make gcc and you should be able to resume libevhtp compilation
Reply
# MrAti 2019-02-10 16:21
Thanks for the super easy guide, managed to install it 6.5 seconds, went supper smooth.

Kudos to you and Seafile as well.

It is a shame though that seafile made it too easy to install this brilliant piece of software.
Now every single Synology owner will have it on their NAS. too bad
Reply