Modernizing port, several improvements were done:

* Use options helpers
* Create user/group
* Create necessary directories
* Remove unnecessary dependencies
* Add newsyslog conf
* Pet portlint
* Bump PORTREVISION

PR:		218509
Submitted by:	Danilo G. Baio (dbaio) <dbaio@bsd.com.br>
Approved by:	nistor@snickers.org (maintainer)
Sponsored by:	Rubicon Communications (Netgate)
Differential Revision:	https://reviews.freebsd.org/D10312
This commit is contained in:
Renato Botelho 2017-04-25 13:10:30 +00:00
parent fc5fea77c2
commit b5aa345939
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=439381
6 changed files with 58 additions and 49 deletions

2
GIDs
View File

@ -836,7 +836,7 @@ chronyd:*:849:
# free: 892
# free: 893
# free: 894
# free: 895
snmptt:*:895:
istat:*:896:
znc:*:897:
ufdb:*:898:

2
UIDs
View File

@ -841,7 +841,7 @@ chronyd:*:849:849::0:0:chronyd user:/nonexistent:/usr/sbin/nologin
# free: 892
# free: 893
# free: 894
# free: 895
snmptt:*:895:895::0:0:SNMPTT User:/var/spool/snmptt:/usr/sbin/nologin
istat:*:896:896::0:0:istatserver user:/nonexistent:/usr/sbin/nologin
znc:*:897:897::0:0:ZNC User:/nonexistent:/usr/sbin/nologin
ufdb:*:898:898::0:0:ufdb user:/nonexistent:/usr/sbin/nologin

View File

@ -2,6 +2,7 @@
PORTNAME= snmptt
PORTVERSION= 1.4
PORTREVISION= 1
CATEGORIES= net-mgmt
MASTER_SITES= SF/${PORTNAME}/${PORTNAME}/${PORTNAME}_${PORTVERSION}
DISTNAME= ${PORTNAME}_${PORTVERSION}
@ -9,21 +10,24 @@ DISTNAME= ${PORTNAME}_${PORTVERSION}
MAINTAINER= nistor@snickers.org
COMMENT= SNMP trap handler/translator/swiss-army-knife
NO_BUILD= yes
LICENSE= GPLv2
USES= perl5 shebangfix tar:tgz
USE_RC_SUBR= snmptt
LICENSE_FILE= ${WRKSRC}/COPYING
RUN_DEPENDS= net-snmp>=0:net-mgmt/net-snmp \
p5-Config-IniFiles>=0:devel/p5-Config-IniFiles \
p5-Text-Balanced>=0:textproc/p5-Text-Balanced \
p5-Text-ParseWords>=0:textproc/p5-Text-ParseWords \
p5-Time-HiRes>=0:devel/p5-Time-HiRes
p5-Config-IniFiles>=0:devel/p5-Config-IniFiles
DOCS= faqs.html index.html layout1.css snmptt.html \
NO_BUILD= yes
NO_ARCH= yes
USES= perl5 shebangfix tar:tgz
USE_RC_SUBR= snmptt
SUB_LIST= PERL=${PERL}
PORTDOCS= faqs.html index.html layout1.css snmptt.html \
snmpttconvert.html snmpttconvertmib.html
USERS= snmptt
GROUPS= snmptt
OPTIONS_DEFINE= DOCS
SCRIPTS= snmptt snmptt-net-snmp-test snmpttconvert \
@ -31,19 +35,24 @@ SCRIPTS= snmptt snmptt-net-snmp-test snmpttconvert \
SHEBANG_FILES= ${SCRIPTS}
post-patch:
${REINPLACE_CMD} -e "s|/var/run|/var/run/${PORTNAME}|" \
-e "s|/etc|${PREFIX}/etc|" ${WRKSRC}/snmptt.ini
do-install:
.for _SCRIPT in ${SCRIPTS}
@${INSTALL_SCRIPT} ${WRKSRC}/${_SCRIPT} ${STAGEDIR}${PREFIX}/sbin
.endfor
cd ${WRKSRC} && ${INSTALL_SCRIPT} ${SCRIPTS} ${STAGEDIR}${PREFIX}/sbin
${MKDIR} ${STAGEDIR}${PREFIX}/etc/snmp
${INSTALL_DATA} ${WRKSRC}/snmptt.ini ${STAGEDIR}${PREFIX}/etc/snmp/snmptt.ini.sample
${INSTALL_DATA} ${WRKSRC}/examples/snmptt.conf.generic ${STAGEDIR}${PREFIX}/etc/snmp/snmptt.conf.generic.sample
${INSTALL_DATA} ${WRKSRC}/examples/snmptt.conf.generic \
${STAGEDIR}${PREFIX}/etc/snmp/snmptt.conf.generic.sample
${INSTALL_DATA} ${FILESDIR}/newsyslog-snmptt.conf \
${STAGEDIR}${PREFIX}/etc/snmp/newsyslog-snmptt.conf.sample
@${MKDIR} ${STAGEDIR}/var/log/${PORTNAME}
@${MKDIR} ${STAGEDIR}/var/run/${PORTNAME}
@${MKDIR} ${STAGEDIR}/var/spool/${PORTNAME}
${MKDIR} ${STAGEDIR}${DOCSDIR}
.for _DOC in ${DOCS}
${INSTALL_MAN} ${WRKSRC}/docs/${_DOC} ${STAGEDIR}${DOCSDIR}
.endfor
do-install-DOCS-on:
@${MKDIR} ${STAGEDIR}${DOCSDIR}
cd ${WRKSRC}/docs && ${INSTALL_DATA} ${PORTDOCS} ${STAGEDIR}${DOCSDIR}
.include <bsd.port.mk>

View File

@ -0,0 +1,10 @@
# configuration file for newsyslog for snmptt
#
# see newsyslog.conf(5) for details
#
# logfilename [owner:group] mode count size when flags [/pid_file] [sig_num]
/var/log/snmptt/snmptt.debug snmptt:snmptt 644 3 1024 * JC /var/run/snmptt/snmptt.pid
/var/log/snmptt/snmptt.log snmptt:snmptt 644 3 * $W6D0 JC
/var/log/snmptt/snmptthandler.debug snmptt:snmptt 644 3 1024 * JC
/var/log/snmptt/snmpttunknown.log snmptt:snmptt 644 3 1024 * JC
/var/log/snmptt/snmpttsystem.log snmptt:snmptt 644 3 1024 * JC

View File

@ -9,36 +9,27 @@
#
# Add the following lines to /etc/rc.conf to enable snmptt:
#
# snmptt_enable="YES"
# snmptt_flags="<set as needed>"
#
# See snmptt documentation for flags.
# snmptt_enable: Set to NO by default. Set it to YES to enable it.
# snmptt_user: The user account snmptt runs as what
# you want it to be. It uses 'snmptt' user by
# default.
# snmptt_flags: See snmptt documentation for flags.
#
. /etc/rc.subr
name=snmptt
rcvar=snmptt_enable
rcvar=${name}_enable
command=%%PREFIX%%/sbin/${name}
command_args=">/dev/null --daemon"
pidfile=/var/run/${name}.pid
# XXX: Makes assumptions about the interpreter path and version. However,
# USE_PERL5 should guarantee that this path is valid. In any event, we
# don't sed-ify the #! operators.
procname=/usr/bin/perl
required_files=%%PREFIX%%/etc/snmp/${name}.ini
# set defaults
snmptt_enable=${snmptt_enable:-"NO"}
stop_postcmd=stop_postcmd
stop_postcmd()
{
rm -f $pidfile
}
command_args="--daemon > /dev/null 2>&1"
command_interpreter=%%PERL%%
load_rc_config ${name}
: ${snmptt_enable:="NO"}
: ${snmptt_user:="snmptt"}
required_files=%%PREFIX%%/etc/snmp/${name}.ini
run_rc_command "$1"

View File

@ -1,3 +1,4 @@
@sample etc/snmp/newsyslog-snmptt.conf.sample etc/newsyslog.conf.d/snmptt.conf
@sample etc/snmp/snmptt.conf.generic.sample
@sample etc/snmp/snmptt.ini.sample
sbin/snmptt
@ -5,9 +6,7 @@ sbin/snmptt-net-snmp-test
sbin/snmpttconvert
sbin/snmpttconvertmib
sbin/snmptthandler
%%DOCSDIR%%/faqs.html
%%DOCSDIR%%/index.html
%%DOCSDIR%%/layout1.css
%%DOCSDIR%%/snmptt.html
%%DOCSDIR%%/snmpttconvert.html
%%DOCSDIR%%/snmpttconvertmib.html
%%PORTDOCS%%@dir %%DOCSDIR%%
@dir(snmptt,snmptt,775) /var/log/snmptt
@dir(snmptt,snmptt,775) /var/run/snmptt
@dir(snmptt,snmptt,700) /var/spool/snmptt