Steps to get dovecot 2.1.17 on qnap ts 119p II NAS (firmware 3.8.1 or 4.x) up and running:
dovecot has to be compiled from source:
- qnap web admin: qpkg center: available / more / Optware IPKG: install and activate it. Or with newer firmware, 4.x, follow these instructions (using HDA_DATA instead of MD0_DATA and replacing cs05q3armel = gcc-3.4.4 by cs08q1armel = gcc-4.2.3).
- enable ssh on qnap and connect as user admin
- cd /opt
- ./Optware.sh start. Or with newer firmware:
PATH=/opt/bin:/opt/sbin:$PATH - 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.17.tar.gz
tar -xzf dovecot-2.1.17.tar.gz
cd dovecot-2.1.17
(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
newer firmware 4.x:
do not use blocking=no because /etc/shadow needs a worker thread which is allowed to access /etc/shadow; so add to auth-system.conf.ext:
service auth-worker {
group = administrators
}
(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
firmware 4.x: use /dev/mtdblock5
– add executable file autorun.sh to /tmp/config:
#!/bin/sh
#
for f in /tmp/config/K*.sh; do
[ -x $f ] && $f start &
[ -x $f ] && cp $f /etc/rcK_init.d/
done
– enable autorun.sh with
/sbin/setcfg Misc Autorun TRUE
/sbin/setcfg Misc Autorun TRUE -f /tmp/config/uLinux.conf
(reference /etc/rcS.d/S98init_nas)
– 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
or simply
#!/bin/sh
/opt/bin/doveadm stop - 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)
- …