Steps to get  dovecot 2.1.12 on qnap ts 119p II NAS (firmware 3.8.1) up and running:

dovecot has to be compiled from source:

  • qnap web admin: qpkg center: available / more / Optware IPKG: install and activate it
  • enable ssh on qnap and connect as user admin
  • cd /opt
  • ./Optware.sh start
  • ipkg update
  • ipkg install mc
    (my preferred editor and file manager)
  • ipkg install libidn
    ipkg install optware-devel
    (pulls in many tools used for compilation of packages)
  • mkdir src
    cd src
    wget http://www.dovecot.org/releases/2.1/dovecot-2.1.12.tar.gz
    tar -xzf dovecot-2.1.12.tar.gz
    cd dovecot-2.1.12
    (download dovecot source)
  • export PATH=/opt/bin:/opt/sbin:$PATH
    (compilation might fail if tools in /bin or /usr/bin are used instead of the ones in /opt/bin)
    ./configure –prefix=/opt –with-storages=maildir
    make
    make install
    (if configure does not find a required library foo the run ipkg list |grep foo and install libfoo-dev with ipkg install)
  • child processes of dovecot use /lib and ignore /opt/lib
    (maybe this can be avoided with CPPFLAGS=”-I/opt/include” LDFLAGS=”-L/opt/lib -ldl” ./configure …)
    qnap firmware 3.8.1 installs libssl 0.97 in /lib but ipkg installs libssl 0.98 in /opt/lib; workaround:
    ln -s /opt/lib/libssl.so.0.9.8 /lib/
    ln -s /opt/libcrypto.so.0.9.8 /lib/
    (to be moved into dovecot startup script)
  • mkdir /opt/var/log
    addgroup dovenull
    addgroup dovecot
    adduser -D -H -G dovenull dovenull
    adduser -D -H _G dovecot dovecot
  • cd /opt/etc
    mkdir dovecot
    mkdir dovecot/conf.d
    (now copy config files from /opt/share/doc/dovecot/example-config to /opt/etc/dovecot, e.g. using mc)
    dovecot.conf: protocols = imap and listen = *
    10-auth.conf: disable_plaintext_auth = no
    10-logging.conf: log_path = /opt/var/log/dovecot.log
    10-mail.conf: mail_location = maildir:/share/dovecot/%n
    10-master.conf: unchanged
    10-ssl.conf: ssl = no and #ssl_cert… and #ssl_key… (disable ssl; might be enabled in a later step)
    20-imap.conf: unchanged
    auth-system.conf.ext: comment out the section driver = pam and uncomment the section driver = shadow
    and add args = blocking=no
    (mail users will be created with qnap web interface)
  • from qnap web interface: access control
    user-groups: create group mail
    shared folders: add folder dovecot (use automatic path and do not share it)
    shared folders: permissions for folder dovecot:
    user: create the mail user yourname with password  and add it to group mail
  • start dovecot manually
    dovecot -c /opt/etc/dovecot/dovecot.conf
    and test it with telnet as described in the dovecot wiki (with mail user yourname)
    finally try to connect with a mail client like thunderbird
  • start and stop dovecot automatically: there are optware start/stop scripts in /opt/etc/init.d
    but the qnap firmware (currently 3.8.1) does not execute them.
    – mkdir /tmp/config
    – mount /dev/mtd5 /tmp/config
    – copy K010optstartstop.sh to /tmp/config (with extension ‘.sh’, not with extension.txt; partly found here and here)
    – chmod +x /tmp/config/K010optstartstop.sh
    – umount /tmp/config
    this will execute   start/stop scripts in /opt/etc/init.d.
  • /opt/etc/init.d/S59dovecot may contain
    #!/bin/sh
    if [ -f /opt/var/run/dovecot/master.pid ] ; then
    kill `cat /opt/var/run/dovecot/master.pid`
    else
    killall dovecot 2>/dev/null
    fi
    rm -f /opt/var/run/dovecot/master.pid
    ln -s /opt/lib/libssl.so.0.9.8 /lib/
    ln -s /opt/libcrypto.so.0.9.8 /lib/
    /opt/sbin/dovecot -c /opt/etc/dovecot/dovecot.conf
  • /opt/etc/init.d/K41dovecot may contain
    #!/bin/sh
    if [ -f /opt/var/run/dovecot/master.pid ] ; then
    kill `cat /opt/var/run/dovecot/master.pid`
    else
    killall dovecot 2>/dev/null
    fi
    rm -f /opt/var/run/dovecot/master.pid
  • both scripts have to be executable
    chmod +x /opt/etc/init.d/S59dovecot
    chmod +x /opt/etc/init.d/K41dovecot

To be continued with py25-getmail to collect mails from pop3 servers
(getmail delivers mails directly into the maildir folders used by dovecot)

  • ipkg install py25-getmail
  • instructions for getmail configuration (not written for qnap)

2 Comments

  1. Blog of spblinux » Blog Archive » Nagios on NAS with realtime graphing says:

    […] Todo: configuration of sendmail on qnap; example of http authentication on qnap add start and kill script to /opt/etc/init.d/nagios and include start/stop of ndo2db (see this) […]

Leave a Reply