Subject: [alpine-aports] [PATCH 1/2] main/dovecot: upgrade to 2.2.23, update init and logrotate scripts

From: Valery Kartel <[email-masked]>
Date: Mon, 4 Apr 2016 10:08:06 +0300

---
 main/dovecot/APKBUILD          | 20 +++++++-------
 main/dovecot/dovecot.initd     | 59 +++++++++++++++---------------------------
 main/dovecot/dovecot.logrotate |  2 +-
 3 files changed, 32 insertions(+), 49 deletions(-)

diff --git a/main/dovecot/APKBUILD b/main/dovecot/APKBUILD
index 2ba4986..b8de78c 100644
--- a/main/dovecot/APKBUILD
+++ b/main/dovecot/APKBUILD
@@ -3,7 +3,7 @@
 # Contributor: Michael Mason <[email-masked]>
 # Maintainer: Natanael Copa <[email-masked]>
 pkgname=dovecot
-pkgver=2.2.22
+pkgver=2.2.23
 pkgrel=0
 pkgdesc="IMAP and POP3 server"
 url="http://www.dovecot.org/"
@@ -143,15 +143,15 @@ sql() {
 	_mv $(cd "$pkgdir" && find etc/dovecot -name '*-sql.conf*')
 }
 
-md5sums="bc8057bd5bdfa0f8e80e2fef1082a241  dovecot-2.2.22.tar.gz
+md5sums="0d2855c19b0603b417cd70613b4a9f36  dovecot-2.2.23.tar.gz
 49f7a03284cc657857fe2ae22b8c82a0  hide-dl-errors.patch
-1a88280b65efb6cb7f70bc5a88bf264c  dovecot.logrotate
-ddd77573827e0662be21303fb795eef3  dovecot.initd"
-sha256sums="c7a9db3c4ae9d9b4da920d2c82669700a0d407934501b405f37f89cc0b706ec7  dovecot-2.2.22.tar.gz
+df6d43508a82903a97e3a2a5b8436d3d  dovecot.logrotate
+f0c227ab4e2593f6d410440b82103de1  dovecot.initd"
+sha256sums="5d834be43fe8f6f61d9b0fb139bf1db2a4da313aeebd7bf09e4bf6bcb1c9e441  dovecot-2.2.23.tar.gz
 d6accdd6e271647c01ab8fa0a9491ee822486484961e2d5c252bf70e816d2bfa  hide-dl-errors.patch
-2ac04bb7b5c503cd87ba044482e651dbe5c9d84a4268891fb2aa9ba26e62f833  dovecot.logrotate
-3f74548051297cedc7f8d203f1d1d9dc904fe89004b54b52921d2050520daa6f  dovecot.initd"
-sha512sums="ea02ae491e90c0b9de7c7320901c8f7235193303fb194805564582d30e630002f21f7195e5c5b99ff3ea1fadf95ddd43c2f7bb4d24067e0e5f40a66e9eb90012  dovecot-2.2.22.tar.gz
+d0fef8cd8200549877d7594cf458d6b33f05b31f95f1fd9a8368e8471c082735  dovecot.logrotate
+1a3c845c216bb6f9633d27a8c1c0d01b591942c463bddb5ae835f162bd7fb4bf  dovecot.initd"
+sha512sums="704d86dcef8b217a54db1d1ae3c1e0d6303827fedd7150aec83e805512cd1c5befc88da44660e7a40765ad6800c14d399f8c7621e84125a7732d68fee7f18d82  dovecot-2.2.23.tar.gz
 1e9a1f2990019236546c7be581a4d6d0b430110d27a00bc3298f5c154ef9a4aadefa193d02a017912f826d771058fd5c6ef6cb454e14f0d15749fa8f3a68c64a  hide-dl-errors.patch
-58756fa06a063777ef7c4d1e67b63adbde5462264e14bd7a3187a318f498fff21ac2a8d53bb216f56fef4588206e14112da79542b6dfdf503988786f27bb6544  dovecot.logrotate
-d7f67991e11979da91162eb64a0b924655d0ac155d97bcc42a40c758003d60b7c096945544e6b321aa8ecb3416fe17b14b5898f1dba5e5a4b3e4c9c21295c8cb  dovecot.initd"
+9f19698ab45969f1f94dc4bddf6de59317daee93c9421c81f2dbf8a7efe6acf89689f1d30f60f536737bb9526c315215d2bce694db27e7b8d7896036a59c31f0  dovecot.logrotate
+6ec75a8396f4d826390e69aa8177593573eaf0e0ab537b2a4720573e04c92ff615f39e1559b48313b2cd2f03704cd977bb594a568ecc5dd22e38926c12f3c48c  dovecot.initd"
diff --git a/main/dovecot/dovecot.initd b/main/dovecot/dovecot.initd
index 880a39f..92959c6 100644
--- a/main/dovecot/dovecot.initd
+++ b/main/dovecot/dovecot.initd
@@ -1,57 +1,40 @@
 #!/sbin/openrc-run
 
+[ "${SVCNAME}" != "${SVCNAME##*.}" ] && instance=${SVCNAME##*.}
+
 description="Secure POP3/IMAP server"
-description_reload="Reload configuration"
 
-extra_started_commands="reload"
+cfgfile=/etc/dovecot/dovecot${instance:+.$instance}.conf
+pidfile=$(doveconf -c $cfgfile -h base_dir 2>/dev/null)/master.pid
+command=/usr/sbin/dovecot
+command_args=${instance:+-c $cfgfile}
+required_files="$cfgfile"
+extra_started_commands="reload reopen"
+description_reload="Reload configuration"
+description_reopen="Reopen log files"
 
 depend() {
 	need localmount net
-	before exim postfix
+	before mta
 	after bootmisc firewall ldap mysql ntp-client ntpd postgresql saslauthd slapd
 	use logger
 }
 
-checkconfig() {
-	DOVECOT_INSTANCE=${SVCNAME##*.}
-	if [ -n "${DOVECOT_INSTANCE}" -a "${SVCNAME}" != "dovecot" ]; then
-		DOVECOT_CONF=/etc/dovecot/dovecot.${DOVECOT_INSTANCE}.conf
-	else
-		DOVECOT_CONF=/etc/dovecot/dovecot.conf
-	fi
-	if [ ! -e ${DOVECOT_CONF} ]; then
-		eerror "You will need an ${DOVECOT_CONF} first"
-		return 1
-	fi
-	if [ -x /usr/sbin/dovecot ]; then
-		DOVECOT_BASEDIR=$(/usr/sbin/dovecot -c ${DOVECOT_CONF} -a | grep '^base_dir = ' | sed 's/^base_dir = //')
-	else
-		eerror "dovecot not executable"
-		return 1
-	fi
-	DOVECOT_BASEDIR=${DOVECOT_BASEDIR:-/run/dovecot}
-	DOVECOT_PIDFILE=${DOVECOT_BASEDIR}/master.pid
-	checkpath --directory --owner dovecot:dovecot --mode 0755 \
-		${DOVECOT_BASEDIR}
-}
-
-start() {
-	checkconfig || return 1
-	ebegin "Starting ${SVCNAME}"
-	start-stop-daemon --start --exec /usr/sbin/dovecot --pidfile "${DOVECOT_PIDFILE}" -- -c "${DOVECOT_CONF}"
+start_pre() {
+	ebegin
+	doveconf -c $cfgfile -x >/dev/null && \
+		checkpath --directory ${pidfile%/*}
 	eend $?
 }
 
-stop() {
-	checkconfig || return 1
-	ebegin "Stopping ${SVCNAME}"
-	start-stop-daemon --stop --exec /usr/sbin/dovecot --pidfile "${DOVECOT_PIDFILE}"
+reload() {
+	ebegin "Reloading ${SVCNAME} configs and restarting auth/login processes"
+	start_pre && start-stop-daemon --signal HUP --pidfile $pidfile
 	eend $?
 }
 
-reload() {
-	checkconfig || return 1
-	ebegin "Reloading ${SVCNAME} configs and restarting auth/login processes"
-	start-stop-daemon --signal HUP --exec /usr/sbin/dovecot --pidfile "${DOVECOT_PIDFILE}"
+reopen() {
+	ebegin "Reopening ${SVCNAME} log files"
+	start-stop-daemon --signal USR1 --pidfile $pidfile
 	eend $?
 }
diff --git a/main/dovecot/dovecot.logrotate b/main/dovecot/dovecot.logrotate
index 89255f8..b1a4087 100644
--- a/main/dovecot/dovecot.logrotate
+++ b/main/dovecot/dovecot.logrotate
@@ -7,6 +7,6 @@
 	notifempty
 	sharedscripts
 	postrotate
-		/etc/init.d/dovecot --quiet --ifstarted reload
+		/etc/init.d/dovecot --quiet --ifstarted reopen
 	endscript
 }
-- 
2.8.0

---
Unsubscribe:  [email-masked]
Help:         [email-masked]
---

---

From: Natanael Copa <[email-masked]>
Date: Mon, 16 May 2016 17:34:52 +0200

Hi,

sorry for late response

On Mon,  4 Apr 2016 10:08:06 +0300

>  3 files changed, 32 insertions(+), 49 deletions(-)

...

> +		checkpath --directory ${pidfile%/*}

Should the pidfile directory not be owned by dovecot:dovecot?

-nc

---

---

From: Valery Kartel <[email-masked]>
Date: Mon, 16 May 2016 19:04:09 +0300

Hi,

Pid dir must be owned by root:root, because ownership of all sockets are
setted up by master process and their ownerships and access modes are
setted up in dovecot's config file.
16 трав. 2016 18:34 "Natanael Copa" <[email-masked]> пише:

> >  main/dovecot/dovecot.initd     | 59
> +++++++++++++++---------------------------
> > -     start-stop-daemon --start --exec /usr/sbin/dovecot --pidfile
> "${DOVECOT_PIDFILE}" -- -c "${DOVECOT_CONF}"
> > +start_pre() {
> > +     ebegin