PORTNAME=	cacti
DISTVERSION=	1.2.31
CATEGORIES=	net-mgmt www
MASTER_SITES=	http://www.cacti.net/downloads/ \
		ftp://ftpmirror.uk/freebsd-ports/cacti/
PKGNAMESUFFIX=	${PHP_PKGNAMESUFFIX}

MAINTAINER=	rodrigo@FreeBSD.org
COMMENT=	Web-driven graphing interface for RRDTool
WWW=		https://www.cacti.net/

LICENSE=	GPLv2+
LICENSE_FILE=	${WRKSRC}/LICENSE

RUN_DEPENDS=	rrdtool:databases/rrdtool \
		snmpwalk:net-mgmt/net-snmp

USES=		cpe gettext mysql php:flavors,web shebangfix

USE_PHP=	ctype filter gd gettext gmp intl ldap mbstring pcntl pdo \
		pdo_mysql posix session simplexml sockets xml zlib
SHEBANG_FILES=	scripts/3com_cable_modem.pl scripts/diskfree.pl \
		scripts/linux_memory.pl scripts/loadavg.pl \
		scripts/loadavg_multi.pl scripts/ping.pl \
		scripts/query_unix_partitions.pl scripts/unix_processes.pl \
		scripts/unix_tcp_connections.pl scripts/unix_users.pl \
		scripts/weatherbug.pl scripts/webhits.pl
NO_ARCH=	yes
NO_BUILD=	yes
SUB_FILES=	pkg-message

CACTIDIR?=	share/cacti
CACTIUSER?=	cacti
CACTIGROUP?=	cacti

USERS?=		${CACTIUSER}
GROUPS?=	${CACTIGROUP}

PLIST_SUB=	CACTIDIR=${CACTIDIR} \
		CACTIGROUP=${CACTIGROUP} \
		CACTIUSER=${CACTIUSER}
SUB_LIST=	CACTIDIR=${CACTIDIR} \
		CACTIGROUP=${CACTIGROUP} \
		CACTIUSER=${CACTIUSER}

post-patch:
	@${FIND} ${WRKSRC} -name \*.orig -delete; \
	${MV} ${WRKSRC}/include/config.php.dist ${WRKSRC}/include/config.php.sample
	${RM} -r ${WRKSRC}/log ${WRKSRC}/rra

do-install:
	${MKDIR} ${STAGEDIR}/${PREFIX}/${CACTIDIR}
	${MKDIR} ${STAGEDIR}/var/log/cacti
	${MKDIR} ${STAGEDIR}/var/db/cacti/rra
	${MKDIR} ${STAGEDIR}/var/db/cacti/scripts
	cd ${WRKSRC} && ${COPYTREE_SHARE} . ${STAGEDIR}${PREFIX}/${CACTIDIR} "! -name \.mdl*"

.include <bsd.port.mk>
