LJ Archive

Listing 11. qturnd.sh

#!/bin/sh
# file: /var/qmail/qturn/bin/qturnd.sh
# qturn server: send mail to remote with maildirqmtp
# wcm, 2001.12.24 - 2001.12.24
# ===
# Installation in brief:
#
# 1. See installation of qturn.run
# 2. mkdir /var/qmail/qturn/ipaccess
# 3. For each remote client (static) IP address setup for qturn
#    service, create matching /var/qmail/qturn/$TCPREMOTEIP file.
#
#    Example:
#      echo 'dabola' >/var/qmail/qturn/ipaccess/10.0.10.242
#      echo 'kissidougou' >/var/qmail/qturn/ipaccess/10.0.10.243
#      etc.
#
# 4. Setup qmail Maildir for each qturn client.
#
#    Example:
#      mkdir /var/qmail/qturn/kissidougou
#      cd    /var/qmail/qturn/kissidougou
#      maildirmake .QMAIL.PPP
#      chown -R qturn .QMAIL.PPP
#      echo './kissidougou/.QMAIL.PPP/' > \
#        /var/qmail/qturn/.qmail-kissidougou-default
#
# 5. Setup qmail "virtualdomains" for each remote client.
#
#    Example:
#      echo 'kissidougou.DOMAIN.NGO:qturn-kissidougou' >> \
#        /var/qmail/control/virtualdomains
#
# 6. Install this file into /var/qmail/qturn/bin/qturnd.sh
#    and make executable.
#
if [ -f /var/qmail/qturn/ipaccess/$TCPREMOTEIP ] ; then
    QTURNDIR=`cat /var/qmail/qturn/ipaccess/$TCPREMOTEIP`
    IPOK=1
else
    QTURNDIR=""
    IPOK=0
fi

if [ $IPOK -eq 1 ] ; then
    echo "Connection from $TCPREMOTEIP"
    if [ -d /var/qmail/qturn/$QTURNDIR ] ; then
        echo "Forwarding messages from qturn-${QTURNDIR}- ..."
        cd /var/qmail/qturn/$QTURNDIR
        /usr/local/bin/maildirqmtp \
            .QMAIL.PPP  qturn-${QTURNDIR}-  $TCPREMOTEIP  2>&1
        echo "Done."
        ERROR=0
    else
        echo "Server configuration error."
        ERROR=1
    fi
else
    ERROR=1
fi

exit $ERROR

# end file qturnd.sh
LJ Archive