Wednesday, March 16, 2011

How to install Trac on a Synology DS209+II

These are some short notes on how I (successfully) installed Trac on a Synology DS209+II. The process should be similar for many other Synology servers. Please comment on any errors you find or snags you run into.

I modified my Synology server from the original Synology setup:

Configuration of Apache for Subversion

I appended following lines to /opt/etc/apache2/httpd.conf:

# Subversion
Include etc/apache2/conf.d/mod_dav_svn.conf

Also, I created a file /opt/etc/apache2/conf.d/mod_dav_svn.conf with following contents:

LoadModule dav_svn_module     libexec/mod_dav_svn.so
LoadModule authz_svn_module   libexec/mod_authz_svn.so

<Location /svn>
   DAV svn
   SVNParentPath /volume1/svn
   AuthType Basic
   AuthName "Subversion repository"
   AuthUserFile /volume1/svn/svn-auth-file
   Require valid-user
</Location>

# allow Apache to be used for authenticating Trac
<Directory /opt/share/www/trac>
   AuthType Basic
   AuthName "Subversion repository"
   AuthUserFile /volume1/svn/svn-auth-file
   Require valid-user
</Directory>

This expects a file /volume1/svn/svn-auth-file to be present. That file contains the passwords used for Subversion (and, via Apache, Trac authentication). This file is generated with apaches htpasswd -c command. I used the cm too, to force md5 hashing of the passwords. Also, I added the folder /opt/share/www/trac` - this is used later on for Trac authentication, as I instruct Apache to authenticate this URL and tell Trac to use it for authentication.

Trac configuration

I am running Trac version 0.11.7. The Trac environments can be found at /volume1/trac-env. They are called "MYTRAC1" and "MYTRAC2". Access to them is via the following URLs:

Trac is run using tracd. This is configured to start automatically on system start by creation of the following file: /opt/etc/init.d/S81trac:

#!/bin/sh
# run tracd
/opt/bin/tracd -d -p 8888 -auth=*,/volume1/svn/svn-auth-file,myserver.example.com -e /volume1/trac-env

The file must be set to executable for root (see documentation for chmod), so that it will be run at system start.

Trac configuration files can be found at

  • /volume1/trac-env/MYTRAC1/conf/trac.ini
  • /volume1/trac-env/MYTRAC2/conf/trac.ini

Authentication via Apache

Authentication is done with the AccountManager plugin for trac (http://trac-hacks.org/wiki/AccountManagerPlugin). The website has a good explanation on how that works. See the copies of the trac.ini files for reference. I'd like to point out the last section:

[account-manager]
password_store = HttpAuthStore
authentication_url = http://myserver.example.com:8000/trac

This is where we tell Trac to use our Apache Server for authentication.

Backup

Backing up Trac

Trac is backed up with the trac-admin hotcopy command. The configuration of the backup is in /etc/crontab. It is done by executing the script /volume1/trac-env/tracbackup:

#!/bin/sh

/opt/bin/trac-admin /v9olume1/trac-env/MYTRAC1 hotcopy `date +/volumeUSB1/usbshare/TracBackup/%Y%m%d_trac_hotcopy_MYTRAC1`
/opt/bin/trac-admin /v9olume1/trac-env/MYTRAC2 hotcopy `date +/volumeUSB1/usbshare/TracBackup/%Y%m%d_trac_hotcopy_MYTRAC2`

# make sure other computers connecting to the share
# can delete these files
chmod 777 /volumeUSB1/usbshare/TracBackup/*

FIXME: these still have to be deleted regularly. I do this from my PC, so as to keep the complexity on the server minimal.

Backing up Subversion

Subversion is backed up with the svnadmin dump command, since this can then be read in from other subversion versions. The configuration of the backup is in /etc/crontab. It is done by executing the script /volume1/svn/svnbackup:

#!/bin/sh

/opt/bin/svnadmin dump /volume1/svn/MYREPO1 > `date +/volumeUSB1/usbshare/SvnBackup/%Y%m%d_svn_dump_MYREPO1`
/opt/bin/svnadmin dump /volume1/svn/MYREPO2 > `date +/volumeUSB1/usbshare/SvnBackup/%Y%m%d_svn_dump_MYREPO2`

# make sure other computers connecting to the share
# can delete these files
chmod 777 /volumeUSB1/usbshare/SvnBackup/*

FIXME: these still have to be deleted regularly. I do this from my PC, so as to keep the complexity on the server minimal.

10 comments:

  1. thank you!
    These instructions were quite helpful.
    Note though that there's a typo. I think you meant to say "DAV svn" rather than "DAV svnp".

    ReplyDelete
  2. thanks enderash, fixed the typo!

    ReplyDelete
  3. Hi Daren

    great guide, though I have some problem and would really appreciate if you could advice some . Or maybe someone else here...

    I have read your guide, and the guide in http://www.nslu2-linux.org/wiki/HowTo/RunTrac

    I have Trac running e.g. http://myds211j:8888/tractest but it looks more like static pages, and I can not login. When I click the login button on top I got error:

    Trac Error
    Authentication information not available. Please refer to the installation documentation.
    TracGuide — The Trac User and Administration Guide


    What do you think is wrong?

    Is it possible for you to make this guide more detailed ?

    ReplyDelete
  4. Hi Danny,

    I'm afraid I'm not much of an expert when it comes to configuring systems, let alone remote support. I don't think I can help you. Maybe you missed a step? Did you create the authentication file "svn-auth-file" using htpasswd? Omitting that sounds like it might generate your error.

    Daren.

    ReplyDelete
  5. Hi Daren

    thanks for the reply.

    I read all over the web, this is the only syno+trac guide I ve seen.

    Yes, I did the svn-auth-file and e.g. this is what it contains:

    testusr:$apr1$8AyGz5m8$ghOCUwyJPEFu81yfHeTjl0

    :\

    ReplyDelete
  6. Danny, I'm sorry. I don't think I can help you here. Also, I don't think I know enough about Synology, Trac or Apache to be of much assistance. I did the same as you: Collecting the information out there. The guide contains all the steps I did, as far as my notes go. Since you have a Trac Error, maybe you can try contacting the Trac community for help on this?

    ReplyDelete
  7. Hi Daren

    thanks again,

    just to check with you,
    In the conf.d/mod_dav_svn.conf the
    SVNParentPath /opt/share/svn
    is given, is it what you use?
    Even though you have the svn in /volume1/svn ?

    I didnt have that /op/share/svn folder, so I created it and put the svn-auth-file in it.

    But I cant see anywhere where you use /volume1/svn ?

    many thanks for all your time!

    ReplyDelete
  8. danny, I think you may have found something here :) I had /opt/share/svn mapped (symbolic link) to /volume1/svn. I am now updating the post to reflect this. Could you try either changing all mentions of /opt/share/svn or using a symbolic link?

    ReplyDelete
  9. Hi Daren,
    thank you very much for your description on this topic.
    Unfortunately I can not find
    - libexec/mod_dav_svn.so
    - libexec/mod_authz_svn.so
    on the apache2 installation for my DS107+...

    Do you know if this is a matter of the version for DS107+ or did they take these modules out of the package? How can I get them?

    Best Regards
    Hathor27

    ReplyDelete
    Replies
    1. Hi Hathor27,

      I'm sorry, I don't really follow the synology stuff - but I guess it is just a problem with the the DS107+... have you tried the forums?

      Best Regards,
      Daren

      Delete