# /etc/logrotate.d/proftpd-basic
#
# ::do_not_edit::
# ::maintainer::
#
/var/log/proftpd/proftpd.log 
/var/log/proftpd/controls.log 
/var/log/proftpd/tls.log 
{
	#no, damn ... use defaults
	#weekly
	#rotate 7
	missingok
	compress
	delaycompress
	notifempty
	create 640 root adm
	sharedscripts
	postrotate
		# reload could be not sufficient for all logs, a restart is safer
		#
		#[k] 2016.09.08
		#	restart seems to stop but NOT to restart the daemon
		#
		#invoke-rc.d proftpd restart 2>/dev/null >/dev/null || true
		#
		#[k] 2017.02.03
		#	output redirect to catch errors ...
		#
		invoke-rc.d proftpd stop >>/var/log/logrotate.log 2>&1 || true
		sleep 2
		invoke-rc.d proftpd start >>/var/log/logrotate.log 2>&1 || true
	endscript
}

/var/log/proftpd/xferlog
/var/log/proftpd/xferreport
{
	#no, damn ... use defaults
	#monthly
	#rotate 7
	missingok
	compress
	delaycompress
	notifempty
	create 640 root adm
	sharedscripts
	prerotate
	endscript
	postrotate
		# reload could be not sufficient for all logs, a restart is safer
		#
		#[k] 2016.09.08
		#	restart seems to stop but NOT to restart the daemon
		#
		#invoke-rc.d proftpd restart 2>/dev/null >/dev/null || true
		#
		#[k] 2017.02.03
		#	output redirect to catch errors ...
		#
		invoke-rc.d proftpd stop >>/var/log/logrotate.log 2>&1 || true
		sleep 2
		invoke-rc.d proftpd start >>/var/log/logrotate.log 2>&1 || true
		# run ftpstats on past transfer log
		#[ku]
		#  2018.04.05 kanna
		#  - xferlog.0 doesn't exists, first file produced by logrotate is .1, not .0
		#    (since? where is set this behaviour?)
		#
		#ftpstats -a -r -l 2 -d -h -f /var/log/proftpd/xferlog.0 2>/dev/null >/var/log/proftpd/xferreport || true
		#ftpstats -a -r -l 2 -d -h -f /var/log/proftpd/xferlog.1 2>/dev/null >/var/log/proftpd/xferreport || true
		ftpstats -a -r -l 2 -d -h -f /var/log/proftpd/xferlog.1 2>>/var/log/logrotate.log >/var/log/proftpd/xferreport || true
	endscript
}
