#!/bin/bash

# Create our freepbx-ucp logrotate file
cat <<- EOF > /etc/logrotate.d/freepbx-ucp
/var/log/asterisk/ucp_*.log {
	size 50M
	missingok
	rotate 5
	dateext
	dateformat -%Y%m%d%s
	notifempty
	dateext
	sharedscripts
	create 0640 asterisk asterisk
	su asterisk asterisk
	postrotate
		/usr/sbin/fwconsole pm2 --reload-logs -q
	endscript
}
EOF

# Delete ucpnode logrotate if it exists
file="/etc/logrotate.d/freepbx-ucpnode"

if [ -f $file ] ; then
    rm -f $file
fi
