Quantcast
Channel: iRedMail — iRedMail Support
Viewing all articles
Browse latest Browse all 43293

Re: PostLoginScript

$
0
0

finally i got it works, the problem was in the script because postgres use PGPASSFILE to use comman line not like MySql.

Now i get in database this record:

Last Login Date                          IP                              Protocol

2013-01-24 09:32:42.032582    192.168.4.83    /usr/lib/dovecot/script-login                                                                                                                                                                                                                                 
2013-01-24 09:32:40.979952    127.0.0.1    /usr/lib/dovecot/script-login                                                                                                                                                                                                                                 
2013-01-24 09:32:35.908215    192.168.17.46    /usr/lib/dovecot/script-login                                                                                                                                                                                                                                 
2013-01-24 09:32:33.941375    192.168.17.46    /usr/lib/dovecot/script-login                                                                                                                                                                                                                                 
2013-01-24 09:32:26.071862    192.168.4.151    /usr/lib/dovecot/script-login                                                                                                                                                                                                                                 
The protocol is not correct.
My script was:

#!/usr/bin/env bash

# $USER -> login username. It should be a valid email address.
# $IP   -> remote ip address (IPv4).
# ${1}  -> mail protocol: imap, pop3

VMAIL_DB_NAME='vmail'
#
if [ X"${USER}" != X"dump-capability" ]; then
sqlstring="UPDATE mailbox SET lastloginipv4='$IP',lastlogindate=NOW(),lastloginprotocol='${1}' WHERE username='$USER';"
su - postgres -c "psql -w vmail >/dev/null 2>&1 <<EOF
       UPDATE mailbox SET
       lastloginipv4='$IP',
       lastlogindate=NOW(),
       lastloginprotocol='${1}'
       WHERE username='$USER';
EOF"
fi

# Execute POP3/IMAP process.
if [ -f /etc/redhat-release ]; then
    # RHEL/CentOS.
    exec /usr/libexec/dovecot/${1} $*
elif [ -f /etc/debian_version ]; then
    # Debian & Ubuntu:
#    exec /usr/lib/dovecot/${1} $*
    exec ${1} $*
fi

I take off almost all comment, it's simplest to read.


Viewing all articles
Browse latest Browse all 43293

Trending Articles