<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[iRedMail — PostLoginScript]]></title>
	<link rel="self" href="http://www.iredmail.org/forum/feed-atom-topic4344.xml" />
	<updated>2013-01-24T16:14:50Z</updated>
	<generator>PunBB</generator>
	<id>http://www.iredmail.org/forum/topic4344-postloginscript.html</id>
		<entry>
			<title type="html"><![CDATA[Re: PostLoginScript]]></title>
			<link rel="alternate" href="http://www.iredmail.org/forum/post20016.html#p20016" />
			<content type="html"><![CDATA[<p>WEBMAIL uses IMAP protocol, you cannot recognize which imap connection comes from webmail or other mail clients.</p>]]></content>
			<author>
				<name><![CDATA[ZhangHuangbin]]></name>
				<uri>http://www.iredmail.org/forum/user2.html</uri>
			</author>
			<updated>2013-01-24T16:14:50Z</updated>
			<id>http://www.iredmail.org/forum/post20016.html#p20016</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: PostLoginScript]]></title>
			<link rel="alternate" href="http://www.iredmail.org/forum/post20005.html#p20005" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>ZhangHuangbin wrote:</cite><blockquote><p>Thanks very much for your sharing. <img src="http://www.iredmail.org/forum/img/smilies/smile.png" width="15" height="15" alt="smile" /></p></blockquote></div><p>How i can correct the protocol?</p><p>I want that it&#039;s POP or IMAP or WEBMAIL if it&#039;s possibile.</p>]]></content>
			<author>
				<name><![CDATA[cedbiella]]></name>
				<uri>http://www.iredmail.org/forum/user31496.html</uri>
			</author>
			<updated>2013-01-24T11:49:32Z</updated>
			<id>http://www.iredmail.org/forum/post20005.html#p20005</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: PostLoginScript]]></title>
			<link rel="alternate" href="http://www.iredmail.org/forum/post20004.html#p20004" />
			<content type="html"><![CDATA[<p>Thanks very much for your sharing. <img src="http://www.iredmail.org/forum/img/smilies/smile.png" width="15" height="15" alt="smile" /></p>]]></content>
			<author>
				<name><![CDATA[ZhangHuangbin]]></name>
				<uri>http://www.iredmail.org/forum/user2.html</uri>
			</author>
			<updated>2013-01-24T11:37:29Z</updated>
			<id>http://www.iredmail.org/forum/post20004.html#p20004</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: PostLoginScript]]></title>
			<link rel="alternate" href="http://www.iredmail.org/forum/post20002.html#p20002" />
			<content type="html"><![CDATA[<p>finally i got it works, the problem was in the script because postgres use PGPASSFILE to use comman line not like MySql.</p><p>Now i get in database this record:</p><p>Last Login Date&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; IP&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Protocol</p><p>2013-01-24 09:32:42.032582&nbsp; &nbsp; 192.168.4.83&nbsp; &nbsp; /usr/lib/dovecot/script-login&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />2013-01-24 09:32:40.979952&nbsp; &nbsp; 127.0.0.1&nbsp; &nbsp; /usr/lib/dovecot/script-login&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />2013-01-24 09:32:35.908215&nbsp; &nbsp; 192.168.17.46&nbsp; &nbsp; /usr/lib/dovecot/script-login&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />2013-01-24 09:32:33.941375&nbsp; &nbsp; 192.168.17.46&nbsp; &nbsp; /usr/lib/dovecot/script-login&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />2013-01-24 09:32:26.071862&nbsp; &nbsp; 192.168.4.151&nbsp; &nbsp; /usr/lib/dovecot/script-login&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />The protocol is not correct.<br />My script was:<br /></p><div class="codebox"><pre><code>#!/usr/bin/env bash

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

VMAIL_DB_NAME=&#039;vmail&#039;
#
if [ X&quot;${USER}&quot; != X&quot;dump-capability&quot; ]; then
sqlstring=&quot;UPDATE mailbox SET lastloginipv4=&#039;$IP&#039;,lastlogindate=NOW(),lastloginprotocol=&#039;${1}&#039; WHERE username=&#039;$USER&#039;;&quot;
su - postgres -c &quot;psql -w vmail &gt;/dev/null 2&gt;&amp;1 &lt;&lt;EOF
       UPDATE mailbox SET
       lastloginipv4=&#039;$IP&#039;,
       lastlogindate=NOW(),
       lastloginprotocol=&#039;${1}&#039;
       WHERE username=&#039;$USER&#039;;
EOF&quot;
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 &amp; Ubuntu:
#    exec /usr/lib/dovecot/${1} $*
    exec ${1} $*
fi</code></pre></div><p>I take off almost all comment, it&#039;s simplest to read.</p>]]></content>
			<author>
				<name><![CDATA[cedbiella]]></name>
				<uri>http://www.iredmail.org/forum/user31496.html</uri>
			</author>
			<updated>2013-01-24T08:41:45Z</updated>
			<id>http://www.iredmail.org/forum/post20002.html#p20002</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: PostLoginScript]]></title>
			<link rel="alternate" href="http://www.iredmail.org/forum/post19956.html#p19956" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>cedbiella wrote:</cite><blockquote><p>but the clients cannot receive and send mail.</p></blockquote></div><p>Then client should have some error message. Paste it here.<br />And paste related log triggered by this client in Dovecot log file.</p>]]></content>
			<author>
				<name><![CDATA[ZhangHuangbin]]></name>
				<uri>http://www.iredmail.org/forum/user2.html</uri>
			</author>
			<updated>2013-01-20T15:30:58Z</updated>
			<id>http://www.iredmail.org/forum/post19956.html#p19956</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: PostLoginScript]]></title>
			<link rel="alternate" href="http://www.iredmail.org/forum/post19954.html#p19954" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>ZhangHuangbin wrote:</cite><blockquote><p>Please paste error message here to help troubleshoot.</p><p>Did you simply append new lines in dovecot.conf? That might not work, because it must contain duplicate settings.</p></blockquote></div><br /><p>I see no error message, the service seem to start correctly, but the clients cannot receive and send mail.</p>]]></content>
			<author>
				<name><![CDATA[cedbiella]]></name>
				<uri>http://www.iredmail.org/forum/user31496.html</uri>
			</author>
			<updated>2013-01-20T11:13:26Z</updated>
			<id>http://www.iredmail.org/forum/post19954.html#p19954</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: PostLoginScript]]></title>
			<link rel="alternate" href="http://www.iredmail.org/forum/post19880.html#p19880" />
			<content type="html"><![CDATA[<p>Please paste error message here to help troubleshoot.</p><p>Did you simply append new lines in dovecot.conf? That might not work, because it must contain duplicate settings.</p>]]></content>
			<author>
				<name><![CDATA[ZhangHuangbin]]></name>
				<uri>http://www.iredmail.org/forum/user2.html</uri>
			</author>
			<updated>2013-01-16T11:45:28Z</updated>
			<id>http://www.iredmail.org/forum/post19880.html#p19880</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: PostLoginScript]]></title>
			<link rel="alternate" href="http://www.iredmail.org/forum/post19857.html#p19857" />
			<content type="html"><![CDATA[<p>Hello, if i put the lines in dovecot.conf, the service don&#039;t start.</p><p>If i put only the code below the service start but postlogin not start.</p><p>If i uncomment the line&nbsp; #executable = imap imap-postlogin under protocol imap service don&#039;t start.</p><p>How i change the dovecot.conf to make it work?</p><p>Thanks in advance</p><br /><br /><div class="codebox"><pre><code>service imap-postlogin {
  # all post-login scripts are executed via script-login binary
  executable = script-login /usr/local/bin/trackLastLogin.sh

  # the script process runs as the user specified here (v2.0.14+):
  #user = $default_internal_user
  #user = $default_internal_user
  # this UNIX socket listener must use the same name as given to imap executable
  unix_listener imap-postlogin {
  }
}
###### Fine Righe Vito

protocol lda {
    # Reference: http://wiki2.dovecot.org/LDA
    mail_plugins = quota sieve autocreate
    auth_socket_path = /var/run/dovecot/auth-master
    log_path = /var/log/sieve.log
    lda_mailbox_autocreate = yes
    postmaster_address = root
}
protocol imap {
    imap_client_workarounds = tb-extra-mailbox-sep
    mail_plugins = quota imap_quota autocreate
    #executable = imap imap-postlogin
}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[cedbiella]]></name>
				<uri>http://www.iredmail.org/forum/user31496.html</uri>
			</author>
			<updated>2013-01-15T08:32:23Z</updated>
			<id>http://www.iredmail.org/forum/post19857.html#p19857</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: PostLoginScript]]></title>
			<link rel="alternate" href="http://www.iredmail.org/forum/post19854.html#p19854" />
			<content type="html"><![CDATA[<p>iRedMail doesn&#039;t use config files under /etc/dovecot/conf.d/, please update /etc/dovecot/dovecot.conf instead.</p>]]></content>
			<author>
				<name><![CDATA[ZhangHuangbin]]></name>
				<uri>http://www.iredmail.org/forum/user2.html</uri>
			</author>
			<updated>2013-01-15T03:30:47Z</updated>
			<id>http://www.iredmail.org/forum/post19854.html#p19854</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: PostLoginScript]]></title>
			<link rel="alternate" href="http://www.iredmail.org/forum/post19846.html#p19846" />
			<content type="html"><![CDATA[<p>ok i&#039;ve controlled the script and it&#039;s ok.</p><p>As wiki say i&#039;ve modified the /etc/dovecot/conf.d/10-master.conf</p><div class="codebox"><pre><code>service imap {
  # Most of the memory goes to mmap()ing files. You may need to increase this
  # limit if you have huge mailboxes.
  #vsz_limit = 256M
executable = imap imap-postlogin

  # Max. number of IMAP processes (connections)
  #process_limit = 1024
}

service pop3 {
  # Max. number of POP3 processes (connections)
  #process_limit = 1024
}

# The service name below doesn&#039;t actually matter.
service imap-postlogin {
  # all post-login scripts are executed via script-login binary
  executable = script-login /usr/local/bin/trackLastLogin.sh
  # the script process runs as the user specified here (v2.0.14+):
  #user = $default_internal_user
  # this UNIX socket listener must use the same name as given to imap executable
  unix_listener imap-postlogin {
  }
}</code></pre></div><p>but i have no success.</p><p>the script work good.</p><p>May you help me?</p>]]></content>
			<author>
				<name><![CDATA[cedbiella]]></name>
				<uri>http://www.iredmail.org/forum/user31496.html</uri>
			</author>
			<updated>2013-01-14T14:32:13Z</updated>
			<id>http://www.iredmail.org/forum/post19846.html#p19846</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: PostLoginScript]]></title>
			<link rel="alternate" href="http://www.iredmail.org/forum/post19800.html#p19800" />
			<content type="html"><![CDATA[<p>i think that the problem is the psql command that not accept the password.<br />I&#039;m looking for a solution, the env variable PGPASSWORD seems non function.</p>]]></content>
			<author>
				<name><![CDATA[cedbiella]]></name>
				<uri>http://www.iredmail.org/forum/user31496.html</uri>
			</author>
			<updated>2013-01-10T10:37:50Z</updated>
			<id>http://www.iredmail.org/forum/post19800.html#p19800</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: PostLoginScript]]></title>
			<link rel="alternate" href="http://www.iredmail.org/forum/post19799.html#p19799" />
			<content type="html"><![CDATA[<p>Why not just try to print values of variables in your trackLastLogin.sh in a plain text file first? So that you can verify whether you have correct data.</p><p>Dovecot wiki site has detailed tutorial: <a href="http://wiki2.dovecot.org/PostLoginScripting">http://wiki2.dovecot.org/PostLoginScripting</a></p>]]></content>
			<author>
				<name><![CDATA[ZhangHuangbin]]></name>
				<uri>http://www.iredmail.org/forum/user2.html</uri>
			</author>
			<updated>2013-01-10T09:55:33Z</updated>
			<id>http://www.iredmail.org/forum/post19799.html#p19799</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[PostLoginScript]]></title>
			<link rel="alternate" href="http://www.iredmail.org/forum/post19795.html#p19795" />
			<content type="html"><![CDATA[<p>==== Required information ====<br />- iRedMail version: Pro 1.1 <br />- Store mail accounts in which backend (LDAP/MySQL/PGSQL): PGSQL<br />- Linux/BSD distribution name and version: Ubuntu 12.04 LTS<br />- Related log if you&#039;re reporting an issue: <br />==== </p><p>Hi, i&#039;ve a problem with the implementation of postloginscript.</p><p>I just want to update the lastlogindate in vmail db, but i&#039;ve no found information about dovecot 2.x and backend DB PGSQL.</p><p>I had copy the script trackLastLogin.sh and paste it in /usr/local/bin.</p><p>I&#039;ve changed the /etc/dovecot/conf.d/10-master.conf in </p><p>service imap {<br />&nbsp; # Most of the memory goes to mmap()ing files. You may need to increase this<br />&nbsp; # limit if you have huge mailboxes.<br />&nbsp; #vsz_limit = 256M<br />executable = imap imap-postlogin</p><p>&nbsp; # Max. number of IMAP processes (connections)<br />&nbsp; #process_limit = 1024<br />}</p><p>service pop3 {<br />&nbsp; # Max. number of POP3 processes (connections)<br />&nbsp; #process_limit = 1024<br />}</p><p># The service name below doesn&#039;t actually matter.<br />service imap-postlogin {<br />&nbsp; # all post-login scripts are executed via script-login binary<br />&nbsp; executable = script-login /usr/local/bin/trackLastLogin.sh</p><p>&nbsp; # the script process runs as the user specified here (v2.0.14+):<br />&nbsp; user = $default_internal_user<br />&nbsp; # this UNIX socket listener must use the same name as given to imap executable<br />&nbsp; unix_listener imap-postlogin {<br />&nbsp; }<br />}</p><p>what&#039;s wrong?</p><p>Thanks in advance</p>]]></content>
			<author>
				<name><![CDATA[cedbiella]]></name>
				<uri>http://www.iredmail.org/forum/user31496.html</uri>
			</author>
			<updated>2013-01-09T15:59:31Z</updated>
			<id>http://www.iredmail.org/forum/post19795.html#p19795</id>
		</entry>
</feed>
