diff options
author | demon <demon@FreeBSD.org> | 2006-02-06 20:24:19 +0800 |
---|---|---|
committer | demon <demon@FreeBSD.org> | 2006-02-06 20:24:19 +0800 |
commit | c09b5d0db1147df277adb44ef8e8c818c5cce2c0 (patch) | |
tree | 71eeee625da8b622637ab25c4bc58202ded5f0dd /net-mgmt/mrtg | |
parent | 9a0b9790be48b1b774bbfd27c0f43c3a9f86339c (diff) | |
download | freebsd-ports-gnome-c09b5d0db1147df277adb44ef8e8c818c5cce2c0.tar.gz freebsd-ports-gnome-c09b5d0db1147df277adb44ef8e8c818c5cce2c0.tar.zst freebsd-ports-gnome-c09b5d0db1147df277adb44ef8e8c818c5cce2c0.zip |
Install rcNG script to run mrtg in daemon mode.
Submitted by: Jan Srzednicki <w@expro.pl>
Diffstat (limited to 'net-mgmt/mrtg')
-rw-r--r-- | net-mgmt/mrtg/Makefile | 11 | ||||
-rw-r--r-- | net-mgmt/mrtg/files/mrtg_daemon.sh.in | 30 | ||||
-rw-r--r-- | net-mgmt/mrtg/pkg-install | 49 | ||||
-rw-r--r-- | net-mgmt/mrtg/pkg-plist | 1 |
4 files changed, 91 insertions, 0 deletions
diff --git a/net-mgmt/mrtg/Makefile b/net-mgmt/mrtg/Makefile index d777ccd9391c..c51019375be4 100644 --- a/net-mgmt/mrtg/Makefile +++ b/net-mgmt/mrtg/Makefile @@ -30,6 +30,9 @@ CONFIGURE_ARGS= --with-gd-lib=${LOCALBASE}/lib \ USE_PERL5= YES MAKE_ENV+= PERL=${PERL} +USE_RC_SUBR= mrtg_daemon.sh +SUB_LIST+= PERL=${PERL} + GNU_CONFIGURE= YES CONFIGURE_ENV= PERL=${PERL} @@ -50,6 +53,9 @@ RUN_DEPENDS+= ${SITE_PERL}/IO/Socket/INET6.pm:${PORTSDIR}/net/p5-IO-INET6 post-patch: ${RM} ${WRKSRC}/lib/mrtg2/BER.pm ${WRKSRC}/lib/mrtg2/SNMP_*.pm +pre-install: + @PKG_PREFIX=${PREFIX} ${SH} ${PKGINSTALL} ${PKGNAME} PRE-INSTALL + do-install: ${MKDIR} -m 755 ${PREFIX}/etc/mrtg ${MKDIR} -m 755 ${DATADIR} @@ -70,12 +76,17 @@ do-install: done post-install: + @PKG_PREFIX=${PREFIX} ${SH} ${PKGINSTALL} ${PKGNAME} POST-INSTALL .if !defined(BATCH) @${ECHO} "" @${ECHO} "############################################################################" @${ECHO} "# Please create a MRTG config file in ${PREFIX}/etc/mrtg #" @${ECHO} "# A configuration file can be automatically generated with cfgmaker #" @${ECHO} "# A sample configuration file is installed as mrtg.cfg.sample #" + @${ECHO} "# #" + @${ECHO} "# To enable MRTG in daemon mode, put the following to your /etc/rc.conf or #" + @${ECHO} "# /etc/rc.conf.local file: #" + @${ECHO} "# mrtg_daemon_enable=\"YES\" #" @${ECHO} "############################################################################" .endif diff --git a/net-mgmt/mrtg/files/mrtg_daemon.sh.in b/net-mgmt/mrtg/files/mrtg_daemon.sh.in new file mode 100644 index 000000000000..467b13c7fd19 --- /dev/null +++ b/net-mgmt/mrtg/files/mrtg_daemon.sh.in @@ -0,0 +1,30 @@ +#!/bin/sh +# +# $FreeBSD$ + +# +# PROVIDE: mrtg_daemon +# REQUIRE: DAEMON +# KEYWORD: FreeBSD + +. %%RC_SUBR%% + + +name="mrtg_daemon" +rcvar=`set_rcvar` + +load_rc_config $name + +: ${mrtg_daemon_enable="NO"} +: ${mrtg_daemon_pidfile="/var/run/mrtg/mrtg.pid"} +: ${mrtg_daemon_user="mrtg"} +: ${mrtg_daemon_config="%%PREFIX%%/etc/mrtg/mrtg.cfg"} + +: ${mrtg_daemon_flags="--pid-file $mrtg_daemon_pidfile --lock-file /var/run/mrtg/lockfile --confcache-file /var/run/mrtg/confcache --user $mrtg_daemon_user --group $mrtg_daemon_user --daemon $mrtg_daemon_config"} + +command="%%PREFIX%%/bin/mrtg" +command_interpreter="%%PERL%%" +pidfile=${mrtg_daemon_pidfile} + +run_rc_command "$1" + diff --git a/net-mgmt/mrtg/pkg-install b/net-mgmt/mrtg/pkg-install new file mode 100644 index 000000000000..5aee623c9c0e --- /dev/null +++ b/net-mgmt/mrtg/pkg-install @@ -0,0 +1,49 @@ +#!/bin/sh +# $FreeBSD$ +# + +case "$2" in + +PRE-INSTALL) + USER=mrtg + GROUP=${USER} + UID=279 + GID=${UID} + + if ! pw groupshow "${GROUP}" 2>/dev/null 1>&2; then + if pw groupadd ${GROUP} -g ${GID}; then + echo "Added group \"${GROUP}\"." + else + echo "Adding group \"${GROUP}\" failed..." + exit 1 + fi + fi + + if ! pw usershow "${USER}" 2>/dev/null 1>&2; then + if pw useradd ${USER} -u ${UID} -g ${GROUP} -h - \ + -s "/sbin/nologin" -d "/nonexistent" \ + -c "MRTG daemon"; \ + then + echo "Added user \"${USER}\"." + else + echo "Adding user \"${USER}\" failed..." + exit 1 + fi + fi + ;; + +POST-INSTALL) + rundir=/var/run/mrtg + + if [ ! -d "$rundir" ]; then + mkdir -p $rundir + echo "Created directory: ${rundir}" + fi + + chown -R mrtg:mrtg $rundir + chmod 0700 $rundir + ;; + +esac + +exit 0 diff --git a/net-mgmt/mrtg/pkg-plist b/net-mgmt/mrtg/pkg-plist index ebfb6449cc41..1f4ce619a48b 100644 --- a/net-mgmt/mrtg/pkg-plist +++ b/net-mgmt/mrtg/pkg-plist @@ -80,3 +80,4 @@ etc/mrtg/mrtg.cfg.sample @dirrm etc/mrtg %%PORTDOCS%%@dirrm %%DOCSDIR%% @dirrm %%DATADIR%% +@unexec rmdir /var/run/mrtg |