Synology DS211

From Davical
Revision as of 23:27, 30 June 2014 by Fenton (talk | contribs) (Created page, still needs formatting)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

Synology DS 211 with DSM 5.0

From Daniel via the DAViCal-General mailing list:

Experiences with installing DAViCal on a Synology DS211 with DSM 5.0. My starting point was a script previously published by CyberLine on GitHub Gist ( Unfortunately, the script would not work out of the box, so here is what I had to do. Please note that the following is not meant to be run as a script. Rather, use it as copy-paste base for your terminal.

  1. Install bootstrap package first.
  2. See:
  1. The installation of optware-devel is buggy because of a conflict between wget-ssl and wget. It is not possible to just uninstall wget, because it is needed for ipkg. So, first fetch the new wget-ssl, then remove the old and install the new:

wget ipkg remove wget && ipkg install wget-ssl_1.12-2_arm.ipk

  1. Now, install system tools and second postgres

ipkg install perl perl-dbi make sed postgresql binutils busybox optware-devel

  1. patch postgres config for non conflicting if not exists

if [ "0" == $(egrep '^port = 5433$' /opt/var/pgsql/data/postgresql.conf | wc -l) ]; then

   echo "port = 5433" >> /opt/var/pgsql/data/postgresql.conf


  1. install needed host entries for davical

if [ "0" == $(grep davical /opt/var/pgsql/data/pg_hba.conf | wc -l) ]; then

   echo -a "local   davical    davical_app   trust\nlocal   davical    davical_dba   trust" >> /opt/var/pgsql/data/pg_hba.conf


  1. start the installed postgres cluster

/opt/etc/init.d/S98postgresql start

  1. install needed perl packaged
  2. Installation of CPAN does not work out of the box ("Can't locate CPAN/Meta/"). I solved this by:

cpan CPAN::Meta

  1. This will draw in a number of other dependencies, just confirm all dialogs. This step takes a looong time!
  2. Now, the following should work:

cpan -fi CPAN YAML

  1. build the perl package for davical installation

mkdir -p /usr/local/etc/davical wget -O - | tar -xz -C /usr/local cd /usr/local/DBD-Pg-2.19.3 && perl Makefile.PL LD=/opt/bin/ld && make && make install

  1. Edit vhost file /opt/etc/apache2/conf.d/davical.vhost
       Alias /cal /opt/share/davical/htdocs
       <Directory /opt/share/davical/htdocs/>
               AllowOverride None
  1. (i.e., no php directives, no virtual host!)
  1. If you prefer a virtual host, create one in the DSM web interface linking to the sub directory "cal".
  1. check for needed open_basedir modification
  2. I did this manually in DSM web interface, adding this to the open_basedir directive:


  1. This will then be in /etc/php/conf.d/user-settings.ini
  1. append davical.vhost to the user apache if not exists

if [ "0" == $(egrep '^Include /opt/etc/apache2/conf.d/davical.vhost' /etc/httpd/conf/httpd.conf-user | wc -l) ]; then

   echo "Include /opt/etc/apache2/conf.d/davical.vhost" >> /etc/httpd/conf/httpd.conf-user


  1. restart the user apache

/usr/syno/sbin/synoservicecfg --restart httpd-user

  1. install davical if not exists

if [ ! -e "/opt/share/davical" ]; then

   wget -O - | tar -xz -C /opt/share/
   mv /opt/share/davical-1.1.1/ /opt/share/davical/


   echo "davical installation exists. nothing to do."


  1. install needed "awl" if not exists

if [ ! -e "/opt/share/awl/" ]; then

   wget -O - | tar -xz -C /opt/share/
   mv /opt/share/awl-0.53/ /opt/share/awl/


   echo "awl installation exists. nothing to do.";


  1. install davical database if not exists

if [ "0" == $(psql -p 5433 -l template1 postgres | grep davical | wc -l) ]; then

   PGPORT=5433 PGUSER=postgres /opt/share/davical/dba/


  1. adjust connect string in DAViCal config (/opt/share/davical/config/example-config.php):

$c->pg_connect[] = "dbname=davical port=5433 user=davical_app host=localhost";

  1. soft link sample config files for each interface if not exists

for ADDR in $(ip -4 addr list | grep inet | awk '{print $2}' | awk -F '/' '{print $1}'); do

   if [ ! -e "/usr/local/etc/davical/$ADDR-conf.php" ]; then
       ln -s /opt/share/davical/config/example-config.php /usr/local/etc/davical/$ADDR-conf.php


  1. Make also a softlink for possible DNS entries you want to use (.../your.domain.tld-conf.php).

Now, the installation should work. Point your browser to your diskstation IP/cal and complete DAViCal setup.

  1. Using the DSM LDAP server for user management:
  2. Add the following to your config /opt/share/davical/config/example-config.php:

$c->authenticate_hook['call'] = 'LDAP_check'; $c->authenticate_hook['config'] = array(

   'host' => 'localhost', //host name of your LDAP Server
   'port' => '389',              //port
   'protocolVersion' => '3', //Version of LDAP protocol to use
   'baseDNUsers'=> 'cn=users,dc=xxx,dc=xxx', //where to look at valid user
   'filterUsers' => 'objectClass=inetOrgPerson', //filter which must validate a user according to RFC4515, i.e. surrounded by brackets
   'baseDNGroups' => 'cn=groups,dc=xxx,dc=xxx', //where to look for groups
   'filterGroups' => 'objectClass=posixGroup', //filter with same rules as filterUsers
   'mapping_field' => array("username" => "cn",
                            "modified" => "modifyTimestamp",
                            "fullname" => "gecos" ,
                            "email" =>"mail"
                            ), //used to create the user based on his ldap properties
   'group_mapping_field' => array("username" => "cn",
                            "updated" => "modifyTimestamp",
                            "fullname" => "description" ,
                            "members" =>"memberUid"
                            ), //used to create the group based on the ldap properties
   'format_updated'=> array('Y' => array(0,4),'m' => array(4,2),'d'=> array(6,2),'H' => array(8,2),'M'=>array(10,2),'S' => array(12,2)),
 $c->do_not_sync_from_ldap = array( 'admin' => true ); // do not affect admin account on ldap sync


  1. Finally, in order to get LDAP to work, I had to edit the file /opt/share/davical/inc/Principal.php.
  2. The reason is that Postgres on my DiskStation is really old (v 8.2.13) and does not seem to support some type casting used on LDAP sync.
  3. Otherwise, on importing LDAP users, I get plenty of errors in the style "cannot write to database".
  4. So what I did was to simply comment out line 540:

// $param_name = 'cast('.$param_name.' as text)::BIT(24)';

  1. I know this is really ugly but seemed to solve my issues.