diff options
author | khorben <khorben@pkgsrc.org> | 2021-08-30 22:29:18 +0000 |
---|---|---|
committer | khorben <khorben@pkgsrc.org> | 2021-08-30 22:29:18 +0000 |
commit | dba9fa800b5145a5941be076f1c4ec3d70a28f20 (patch) | |
tree | 1ba21df3c8bbc75574b04d5edbc8e3e6caa5dc56 | |
parent | bb10a36fefbe07a89967d18cab265331d1899f47 (diff) | |
download | pkgsrc-dba9fa800b5145a5941be076f1c4ec3d70a28f20.tar.gz |
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.
-rw-r--r-- | net/beanstalkd/Makefile | 7 | ||||
-rw-r--r-- | net/beanstalkd/files/beanstalkd.sh | 33 |
2 files changed, 22 insertions, 18 deletions
diff --git a/net/beanstalkd/Makefile b/net/beanstalkd/Makefile index bf14cb3cbf1..247fe21f3e6 100644 --- a/net/beanstalkd/Makefile +++ b/net/beanstalkd/Makefile @@ -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 @@ USE_TOOLS+= gmake 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 @@ FILES_SUBST+= BEANSTALK_USER=${BEANSTALKD_USER} 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 --git a/net/beanstalkd/files/beanstalkd.sh b/net/beanstalkd/files/beanstalkd.sh index 76df298727c..c8dd179aeb0 100644 --- a/net/beanstalkd/files/beanstalkd.sh +++ b/net/beanstalkd/files/beanstalkd.sh @@ -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} & -} - -beanstalkd_stop() -{ - pkill -u @BEANSTALK_USER@ 2>/dev/null + echo "Starting ${name}." + ${command} ${beanstalkd_flags} ${command_args} & + echo $! > ${pidfile} } -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 |