pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/net/beanstalkd beanstalkd: let the RC script work unpr...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/14a1ee55130b
branches:  trunk
changeset: 457707:14a1ee55130b
user:      khorben <khorben%pkgsrc.org@localhost>
date:      Mon Aug 30 22:29:18 2021 +0000

description:
beanstalkd: let the RC script work unprivileged

This takes advantage of the introduction of the SYSCONFBASE variable.
Tested on NetBSD/amd64.

While there, improve the general behaviour, and avoid `pkill -u` in particular
when stopping the service.

Bumps PKGREVISION.

diffstat:

 net/beanstalkd/Makefile            |   7 ++++---
 net/beanstalkd/files/beanstalkd.sh |  33 ++++++++++++++++++---------------
 2 files changed, 22 insertions(+), 18 deletions(-)

diffs (95 lines):

diff -r ddd8fd664574 -r 14a1ee55130b net/beanstalkd/Makefile
--- a/net/beanstalkd/Makefile   Mon Aug 30 21:52:41 2021 +0000
+++ b/net/beanstalkd/Makefile   Mon Aug 30 22:29:18 2021 +0000
@@ -1,6 +1,7 @@
-# $NetBSD: Makefile,v 1.2 2021/04/06 23:46:53 khorben Exp $
+# $NetBSD: Makefile,v 1.3 2021/08/30 22:29:18 khorben Exp $
 
 DISTNAME=      beanstalkd-1.12
+PKGREVISION=   1
 CATEGORIES=    net
 MASTER_SITES=  ${MASTER_SITE_GITHUB:=kr/}
 GITHUB_TAG=    v${PKGVERSION_NOREV}
@@ -14,8 +15,9 @@
 
 B_MANDIR=              ${PKGMANDIR}/man1
 B_DOCDIR=              share/doc/${PKGBASE}
+INSTALLATION_DIRS+=    ${B_MANDIR} ${B_DOCDIR}
+
 RCD_SCRIPTS+=          beanstalkd
-INSTALLATION_DIRS+=    ${B_MANDIR} ${B_DOCDIR} share/examples/rc.d
 
 PKG_GROUPS_VARS+=      BEANSTALKD_GROUP
 PKG_USERS_VARS=                BEANSTALKD_USER
@@ -25,7 +27,6 @@
 BEANSTALKD_GROUP?=     beanstalkd
 BEANSTALKD_HOME?=      ${VARBASE}/chroot/beanstalkd
 PKG_HOME.beanstalkd?=  ${BEANSTALKD_HOME}
-PLIST_SUBST+=          BEANSTALK_HOME=${BEANSTALKD_HOME}
 PKG_GROUPS=            ${BEANSTALKD_GROUP}
 PKG_GECOS.beanstalkd=  beanstalk daemon
 PKG_USERS=             ${BEANSTALKD_USER}:${BEANSTALKD_GROUP}
diff -r ddd8fd664574 -r 14a1ee55130b net/beanstalkd/files/beanstalkd.sh
--- a/net/beanstalkd/files/beanstalkd.sh        Mon Aug 30 21:52:41 2021 +0000
+++ b/net/beanstalkd/files/beanstalkd.sh        Mon Aug 30 22:29:18 2021 +0000
@@ -1,42 +1,45 @@
 #!/bin/sh
 #
-# $NetBSD: beanstalkd.sh,v 1.1 2021/03/18 22:54:52 khorben Exp $
+# $NetBSD: beanstalkd.sh,v 1.2 2021/08/30 22:29:18 khorben Exp $
 #
 # beanstalkd - simple, fast work queue daemon
 #
 # PROVIDE: beanstalkd
 # REQUIRE: DAEMON NETWORKING SERVERS
+# KEYWORD: shutdown
 #
 # You will need to set some variables in @PKG_SYSCONFDIR@/rc.conf to start beanstalkd:
 #
 # beanstalkd=YES
 
-. /etc/rc.subr
+if [ -f @SYSCONFBASE@/rc.subr ]; then
+       . @SYSCONFBASE@/rc.subr
+       load_rc_config_var beanstalkd_user beanstalkd_user
+       load_rc_config_var beanstalkd_host beanstalkd_host
+       load_rc_config_var beanstalkd_port beanstalkd_port
+fi
 
 name="beanstalkd"
 rcvar=${name}
-beanstalkd_user="@BEANSTALK_USER@"
-beanstalkd_host="127.0.0.1"
-beanstalkd_port="11300"
+beanstalkd_user="${beanstalkd_user:-@BEANSTALK_USER@}"
+beanstalkd_host="${beanstalkd_host:-127.0.0.1}"
+beanstalkd_port="${beanstalkd_port:-11300}"
+pidfile="@VARBASE@/run/${name}.pid"
 start_cmd="beanstalkd_start"
-restart_cmd="beanstalkd_stop ; beanstalkd_start"
-stop_cmd="beanstalkd_stop"
 command="@PREFIX@/bin/${name}"
 command_args="-u ${beanstalkd_user} -l ${beanstalkd_host} -p ${beanstalkd_port}"
 
 beanstalkd_start()
 {
-       ${command} ${command_args} &
+       echo "Starting ${name}."
+       ${command} ${beanstalkd_flags} ${command_args} &
+       echo $! > ${pidfile}
 }
 
-beanstalkd_stop()
-{
-        pkill -u @BEANSTALK_USER@ 2>/dev/null
-}
-
-if [ -f /etc/rc.subr ]; then
+if [ -f @SYSCONFBASE@/rc.subr ]; then
        load_rc_config $name
        run_rc_command "$1"
 else
-       eval ${start_cmd}
+       echo -n "${name}"
+       ${start_cmd}
 fi



Home | Main Index | Thread Index | Old Index