ports/103555: irc/bopm cleanup and general changes

Jeremy Chadwick freebsd at jdc.parodius.com
Sun Sep 24 09:50:09 UTC 2006


>Number:         103555
>Category:       ports
>Synopsis:       irc/bopm cleanup and general changes
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          update
>Submitter-Id:   current-users
>Arrival-Date:   Sun Sep 24 09:50:08 GMT 2006
>Closed-Date:
>Last-Modified:
>Originator:     Jeremy Chadwick
>Release:        FreeBSD 6.2-PRERELEASE i386
>Organization:
Parodius Networking
>Environment:
System: FreeBSD icarus.home.lan 6.2-PRERELEASE FreeBSD 6.2-PRERELEASE #0: Fri Sep 22 17:14:52 PDT 2006 root at icarus.home.lan:/usr/obj/usr/src/sys/ICARUS i386
>Description:
	I decided to update irc/bopm with numerous changes:

	* Use rc.subr instead of the old stock sh script framework.
	  This is what prompted me to update the port in the first place.
	* Clean up (and enhance) many of the REINPLACE_CMD entries.
	* Make heavy use of the SUB_FILES framework.
	* Edit bopm.conf.sample file to refer to our path scheme.
	* Deal with bopm.conf in a more appropriate manner; simply
	  install bopm.conf.sample and do not touch bopm.conf ever.
	  This is the way many other ports do it, and I agree with it.
	* Now uses /var/log/bopm for pid and logs.  Defining this
	  via configure --localstatefile allows bopm to run without
	  the -d flag.
	* Replace pkg-install.in pw useradd/groupadd stuff from the
	  example in databases/mysql50-server.  Looks cleaner.
	* Clean up directories via pkg-deinstall.
	* Shut down daemon via killall via pkg_delete.

	Also, if the current maintainer is unavailable or does not
	respond, I can take ownership of this port.

	All changes tested on FreeBSD 6.x.
>How-To-Repeat:
	n/a
>Fix:
	Apply below patch.  If a tarball is needed, let me know.
	Committer should make note of the following:

	* Files that need $FreeBSD CVS ID tags:
		files/bopm.in
		files/pkg-deinstall.in
		files/pkg-install.in


diff -ruN bopm.orig/Makefile bopm/Makefile
--- bopm.orig/Makefile	Fri Aug 18 10:29:59 2006
+++ bopm/Makefile	Sun Sep 24 02:36:18 2006
@@ -7,28 +7,46 @@
 
 PORTNAME=	bopm
 PORTVERSION=	3.1.2
+PORTREVISION=	1
 CATEGORIES=	irc
 MASTER_SITES=	http://static.blitzed.org/www.blitzed.org/bopm/files/ \
 		ftp://rusunix.org/pub/FreeBSD/distfiles/
 
 MAINTAINER=	aquatique-ports at rambler.ru
-COMMENT=	Open proxy monitor and blocker, designed for use with ircds
+COMMENT=	Open proxy and DNSBL monitor, designed for use with ircds
 
-GNU_CONFIGURE=	yes
-CONFIGURE_TARGET=--build=${MACHINE_ARCH}-portbld-freebsd${OSREL}
-CONFIGURE_ARGS=	--sysconfdir=${PREFIX}/etc
+LOGDIR=		/var/log/${PORTNAME}
+
+GNU_CONFIGURE=		yes
+CONFIGURE_TARGET=	--build=${MACHINE_ARCH}-portbld-freebsd${OSREL}
+CONFIGURE_ARGS=		--sysconfdir=${PREFIX}/etc --localstatedir=${LOGDIR}
 
 USE_LDCONFIG=	yes
+USE_RC_SUBR=	bopm
 
-post-patch:
-	@${REINPLACE_CMD} -e 's,^[[:space:]]*$$(mkinstalldirs) $$(localstatedir),,' ${WRKSRC}/Makefile.in
-	@${REINPLACE_CMD} -e 's,= bopm.conf.sample,= ,' ${WRKSRC}/Makefile.in
+SUB_FILES=	pkg-message pkg-install pkg-deinstall
+PLIST_SUB=	LOGDIR=${LOGDIR}
+SUB_LIST=	LOGDIR=${LOGDIR}
 
-pre-install:
-	@${SH} ${PKGINSTALL} ${PKGNAME} PRE-INSTALL
+pre-su-install:
+	@${SETENV} "PKG_PREFIX=${PREFIX}" ${SH} ${PKGINSTALL} ${PKGNAME} PRE-INSTALL
+
+post-patch:
+	@${REINPLACE_CMD} \
+		-e 's,data_DATA = bopm.conf.sample,data_DATA =,g' \
+		-e 's,$(sysconfdir)/bopm.conf,$(sysconfdir)/bopm.conf.sample,g' \
+		${WRKSRC}/Makefile.in
+	@${REINPLACE_CMD} \
+		-e 's,/some/path/bopm.pid,${LOGDIR}/bopm.pid,g' \
+		-e 's,/some/path/scan.log,${LOGDIR}/scan.log,g' \
+		${WRKSRC}/bopm.conf.sample
 
 post-install:
-	@${INSTALL_SCRIPT} -m 555 ${FILESDIR}/bopm.sh.sample ${PREFIX}/etc/rc.d
+	@${SETENV} "PKG_PREFIX=${PREFIX}" ${SH} ${PKGINSTALL} ${PKGNAME} POST-INSTALL
+	@${CHOWN} bopm:bopm ${LOGDIR}
+	@${CHMOD} 750 ${LOGDIR}
+	@${CHOWN} bopm:bopm ${PREFIX}/etc/bopm.conf.sample
+	@${CHMOD} 640 ${PREFIX}/etc/bopm.conf.sample
 	@${CAT} ${PKGMESSAGE}
 
 .include <bsd.port.mk>
diff -ruN bopm.orig/files/bopm.in bopm/files/bopm.in
--- bopm.orig/files/bopm.in	Wed Dec 31 16:00:00 1969
+++ bopm/files/bopm.in	Sun Sep 24 02:36:18 2006
@@ -0,0 +1,38 @@
+#!/bin/sh
+
+# PROVIDE: bopm
+# REQUIRE: DAEMON
+# KEYWORD: shutdown
+
+#
+# Add the following line to /etc/rc.conf to enable bopm:
+# bopm_enable (bool):	Set to "NO" by default.
+#			Set it to "YES" to enable bopm.
+# bopm_config (str):	Default to "%%PREFIX%%/etc/bopm.conf"
+#			Configuration file for bopm.
+# bopm_flags (str):	Custom flags passed to the bopm
+#			daemon (default empty).
+#
+. %%RC_SUBR%%
+
+name="bopm"
+rcvar=`set_rcvar`
+
+load_rc_config $name
+
+: ${bopm_enable="NO"}
+: ${bopm_config="%%PREFIX%%/etc/bopm.conf"}
+: ${bopm_flags=""}
+
+bopm_user="bopm"
+pidfile="%%LOGDIR%%/bopm.pid"
+required_files="${bopm_config}"
+
+# NOTE: bopm behaves differently with or without the -d flag.
+# If you choose to use -d, you will probably need to redirect
+# stdout and stderr to appropriate places.
+#
+command="%%PREFIX%%/bin/bopm"
+command_args="${bopm_flags} &"
+
+run_rc_command "$1"
diff -ruN bopm.orig/files/bopm.sh.sample bopm/files/bopm.sh.sample
--- bopm.orig/files/bopm.sh.sample	Fri Aug  6 00:46:51 2004
+++ bopm/files/bopm.sh.sample	Wed Dec 31 16:00:00 1969
@@ -1,24 +0,0 @@
-#!/bin/sh
-
-PREFIX=$(expr $0 : "\(/.*/\)etc/rc\.d/$(basename $0)\$")
-
-BOPM=${PREFIX}bin/bopm
-
-case "$1" in
-start)
-	if [ -x $BOPM ]; then
-		su bopm -c $BOPM -d >/dev/null 2>&1
-		echo -n ' bopm'
-	fi
-	;;
-stop)
-#	kill `cat ${PREFIX}/etc/ircd-hybrid-ru/ircd.pid` >/dev/null 2>&1
-	killall bopm >/dev/null 2>&1
-	echo -n ' bopm'
-	;;
-*)
-	echo "Usage: `basename $0` {start|stop}" >&2
-	;;
-esac
-
-exit 0
diff -ruN bopm.orig/files/pkg-deinstall.in bopm/files/pkg-deinstall.in
--- bopm.orig/files/pkg-deinstall.in	Wed Dec 31 16:00:00 1969
+++ bopm/files/pkg-deinstall.in	Sun Sep 24 02:36:18 2006
@@ -0,0 +1,17 @@
+#!/bin/sh
+
+#-----------------------------------------------------------------------
+if [ "x$2" = "xPOST-DEINSTALL" ]; then
+#-----------------------------------------------------------------------
+
+if [ -d %%LOGDIR%% ]
+then
+  rm -f %%LOGDIR%%/bopm.pid 2>/dev/null
+  rmdir %%LOGDIR%% 2>/dev/null || echo "The logs in %%LOGDIR%% will remain untouched after the port is deinstalled."
+fi
+
+#-----------------------------------------------------------------------
+fi
+#-----------------------------------------------------------------------
+
+exit 0
diff -ruN bopm.orig/files/pkg-install.in bopm/files/pkg-install.in
--- bopm.orig/files/pkg-install.in	Wed Dec 31 16:00:00 1969
+++ bopm/files/pkg-install.in	Sun Sep 24 02:36:18 2006
@@ -0,0 +1,48 @@
+#!/bin/sh
+
+# This script is a modified copy of the pkg-install script 
+# from the ircd-hybrid-ru port.
+
+PATH=/bin:/usr/bin:/usr/sbin
+
+#-----------------------------------------------------------------------
+if [ "x$2" = "xPRE-INSTALL" ]; then
+#-----------------------------------------------------------------------
+
+USER=bopm
+GROUP=${USER}
+UID=717
+GID=${UID}
+SHELL=/bin/sh
+HOMEDIR=/nonexistent
+GECOS="Blitzed Open Proxy Monitor"
+
+if pw group show "${GROUP}" 2>/dev/null; then
+	echo "You already have a group \"${GROUP}\", so I will use it."
+else
+	if pw groupadd ${GROUP} -g ${GID}; then
+		echo "Added group \"${GROUP}\"."
+	else
+		echo "Adding group \"${GROUP}\" failed..."
+		exit 1
+	fi
+fi
+
+if pw user show "${USER}" 2>/dev/null; then
+	echo "You already have a user \"${USER}\", so I will use it."
+else
+	if pw useradd ${USER} -u ${UID} -g ${GROUP} -h - \
+		-d ${HOMEDIR} -s ${SHELL} -c "${GECOS}"
+	then
+		echo "Added user \"${USER}\"."
+	else
+		echo "Adding user \"${USER}\" failed..."
+		exit 1
+	fi
+fi
+
+#-----------------------------------------------------------------------
+fi
+#-----------------------------------------------------------------------
+
+exit 0
diff -ruN bopm.orig/files/pkg-message.in bopm/files/pkg-message.in
--- bopm.orig/files/pkg-message.in	Wed Dec 31 16:00:00 1969
+++ bopm/files/pkg-message.in	Sun Sep 24 02:36:18 2006
@@ -0,0 +1,13 @@
+-----------------------------------------------------------------
+bopm has been installed.  Here are some installation details:
+
+user bopm (uid 717) and group bopm (gid 717) have been added
+to passwd(5) and group(5).
+
+bopm sample conf: %%PREFIX%%/etc/bopm.conf.sample
+bopm rc script:   %%PREFIX%%/etc/rc.d/bopm
+bopm log dir:     %%LOGDIR%%
+
+Please be sure to create %%PREFIX%%/etc/bopm.conf before
+starting this daemon.
+-----------------------------------------------------------------
diff -ruN bopm.orig/pkg-deinstall bopm/pkg-deinstall
--- bopm.orig/pkg-deinstall	Fri Aug  6 00:46:51 2004
+++ bopm/pkg-deinstall	Wed Dec 31 16:00:00 1969
@@ -1,54 +0,0 @@
-#! /bin/sh
-
-ask() {
-    local question default answer
-
-    question=$1
-    default=$2
-    if [ -z "${PACKAGE_BUILDING}" -a -z "${BATCH}" ]; then
-	read -p "${question} [${default}]? " answer
-    fi
-    echo ${answer:-${default}}
-}
-
-yesno() {
-    local question default answer
-
-    question=$1
-    default=$2
-    while :; do
-	answer=$(ask "${question}" "${default}")
-	case "${answer}" in
-	[Yy]*)	return 0;;
-	[Nn]*)	return 1;;
-	esac
-	echo "Please answer yes or no."
-    done
-}
-
-delete_account() {
-    local u
-
-    u=$1
-    if yesno "Do you want me to remove user \"${u}\"" n; then
-	pw userdel -n ${u}
-	echo "Done."
-    fi
-}
-
-case $2 in
-
-DEINSTALL)
-    if ps -axc | grep -qw bopm; then
-	if yesno "bopm is still running. Shall I stop it?" y; then
-	    killall bopm
-	    sleep 2
-	else
-	    echo "OK ... I hope you know what you are doing."
-	fi
-    fi
-
-    delete_account bopm
-    ;;
-
-esac
diff -ruN bopm.orig/pkg-descr bopm/pkg-descr
--- bopm.orig/pkg-descr	Fri Aug  6 00:46:51 2004
+++ bopm/pkg-descr	Sun Sep 24 02:36:18 2006
@@ -1,7 +1,7 @@
- bopm is an open-source open proxy monitor, designed for use
- with hybrid-based ircds, although it can be used with slight
- modification on any server which has +c to show connects to
- opers and that supports KLINEs in order to K-LINE incoming
- connects from open proxies
+bopm is an open-source proxy monitor, designed for use
+with IRC daemons such as Bahamut, Hybrid/ratbox, Unreal,
+Dancer, and any other which supports +c to show client
+connects to opers; bopm will KLINE clients it considers
+on an open proxy.  bopm also supports DNSBL lookups.
 
-WWW: http://blitzed.org/bopm/
+WWW: http://wiki.blitzed.org/BOPM
diff -ruN bopm.orig/pkg-install bopm/pkg-install
--- bopm.orig/pkg-install	Fri Aug  6 00:46:51 2004
+++ bopm/pkg-install	Wed Dec 31 16:00:00 1969
@@ -1,68 +0,0 @@
-#!/bin/sh
-
-# This script is a modified copy of the pkg-install script 
-# from the ircd-hybrid-ru port.
-
-if [ "x$2" != "xPRE-INSTALL" ]; then
-	exit 0;
-fi
-
-
-if ! which -s pw ; then
-	cat <<EOF
-Your system does not include the "pw" utility.  You should upgrade
-to a newer version of FreeBSD.  Without "pw" this script will not
-run.
-EOF
-	exit 1
-fi
-
-uid=717
-user=bopm
-gid=$uid
-group=$user
-gecos="Blitzed Open Proxy Monitor" 
-shell="/bin/sh"
-home="/nonexistent"
-
-echo ""
-if pw groupshow $group 2> /dev/null ; then
-	echo "You already have a group \"$group\", so I will use it."
-else
-	if pw groupshow $gid 2> /dev/null ; then
-		echo "You already have a gid \"$gid\".  Please create a user \"$group\""
-		echo "with a default group of \"$group\"."
-		exit 1
-	fi
-	echo "You need a group \"$group\"."
-	if which -s pw ; then
-		pw groupadd $group -g $gid || exit
-		echo "Done."
-	else
-		echo "Please create it, and try again."
-		if ! pw usershow $user 2> /dev/null ; then
-			echo "While you're at it, please create a user \"$user\""
-			echo 'too, with a default group of "$group".'
-		fi
-		exit 1
-	fi
-fi
-
-if pw usershow $user 2> /dev/null ; then
-	echo "You already have a user \"$user\", so I will use it."
-else
-        if pw usershow $uid 2> /dev/null ; then
-                echo "You already have a uid \"$uid\".  Please create a user \"$user\""
-                echo "with a default group of \"$group\"."
-                exit 1
-        fi
-	echo "You need a user \"$user\"."
-	if which -s pw; then
-		pw useradd $user -g $group -u $uid -h - -d $home \
-			-s "$shell" -c "$gecos" || exit
-		echo "Done."
-	else
-		echo "Please create it, and try again."
-		exit 1
-	fi
-fi
diff -ruN bopm.orig/pkg-message bopm/pkg-message
--- bopm.orig/pkg-message	Fri Aug  6 00:46:51 2004
+++ bopm/pkg-message	Wed Dec 31 16:00:00 1969
@@ -1,17 +0,0 @@
-
-----------------------------------------------------
-
-This port uses now UID/GID - 717
-
-bopm has been installed.
-
-This port create user bopm and group bopm
-
-You should now edit bopm.conf it to suit your needs.
-
-You may then start the bopm by running:
- cd /usr/local/etc/rc.d/ && \
- cp bopm.sh.sample bopm.sh && \
- /usr/local/etc/rc.d/bopm.sh start
-
-----------------------------------------------------
diff -ruN bopm.orig/pkg-plist bopm/pkg-plist
--- bopm.orig/pkg-plist	Sat Jan 21 18:15:50 2006
+++ bopm/pkg-plist	Sun Sep 24 02:36:18 2006
@@ -1,6 +1,7 @@
+ at unexec /bin/echo "===>" Stopping bopm...
+ at unexec /usr/bin/killall bopm 2>/dev/null || true
 bin/bopm
-etc/bopm.conf
-etc/rc.d/bopm.sh.sample
+etc/bopm.conf.sample
 include/opm.h
 include/opm_error.h
 include/opm_types.h
@@ -9,6 +10,3 @@
 lib/libopm.so
 lib/libopm.la
 lib/libopm.a
- at exec mkdir -m 755 /var/log/bopm
- at exec chown bopm:bopm /var/log/bopm
- at dirrmtry var/log/bopm
>Release-Note:
>Audit-Trail:
>Unformatted:



More information about the freebsd-ports-bugs mailing list