#!/bin/bash # authenticator, optionally set in /etc/default/bincimap, needs to be a # checkpassword-style program. It defaults to checkpassword. test -f /usr/sbin/bincimap-up || exit 0 test -f /usr/sbin/bincimapd || exit 0 test -f /usr/bin/tcpserver || exit 0 test -f /usr/sbin/stunnel && usestunnel=1 if [ -f /etc/default/bincimap ]; then . /etc/default/bincimap fi if [ ! -x "${authenticator}" ]; then authenticator="`which checkpassword`" if [ ! -x "${authenticator}" ]; then echo "authenticator not found." exit 1 fi fi case "$1" in start) echo -n "Starting Binc IMAP Daemon:" echo -n " imap" start-stop-daemon --start --quiet --pidfile \ /var/run/tcpserver_bincimap.pid --make-pidfile --background --exec \ /usr/bin/tcpserver -- -R -H 0 imap2 /usr/sbin/bincimap-up \ --conf=/etc/bincimap/bincimap.conf --logtype=syslog -- \ "${authenticator}" /usr/sbin/bincimapd if [ -n "${usestunnel}" ]; then echo -n " imaps" start-stop-daemon --start --quiet --pidfile \ /var/run/tcpserver_bincimap_ssl.pid --make-pidfile --background \ --exec /usr/bin/tcpserver -- -R -H 0 993 /usr/sbin/stunnel -f \ -p /etc/ssl/certs/imapd.pem -l \ /usr/sbin/bincimap-up -- bincimap-up-ssl --disable-starttls=yes \ --conf=/etc/bincimap/bincimap.conf --logtype=syslog -- \ "${authenticator}" /usr/sbin/bincimapd fi echo "." ;; stop) echo -n "Stopping Binc IMAP Daemon:" echo -n " imap" start-stop-daemon --stop --quiet --oknodo --pidfile \ /var/run/tcpserver_bincimap.pid --exec /usr/bin/tcpserver if [ -n "${usestunnel}" ]; then echo -n " imaps" start-stop-daemon --stop --quiet --oknodo --pidfile \ /var/run/tcpserver_bincimap_ssl.pid --exec /usr/bin/tcpserver fi echo "." ;; restart) $0 stop sleep 2 $0 start ;; *) echo "Usage: $0 {start|stop|restart}" exit 1 esac exit 0