pkgsrc-Changes-HG archive

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

[pkgsrc/trunk]: pkgsrc/chat/bitlbee bitlbee: Always create the ${pidfile} dir...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/ce74a2b211c9
branches:  trunk
changeset: 380873:ce74a2b211c9
user:      leot <leot%pkgsrc.org@localhost>
date:      Wed May 23 18:44:52 2018 +0000

description:
bitlbee: Always create the ${pidfile} directory and improve rc.d script

- At least on NetBSD every files on /var/run are removed at every
  boot by mountcritlocal rc.d script. Add a bitlbee_precmd() function
  to always check that a directory for the ${pidfile} exists and
  create it if needed.
- Check if /etc/rc.subr exists before source-ing it.
- Introduce BITLBEE_USER and BITLBEE_GROUP variables and reuse them to avoid
  hardcoding `bitlbee' and `nobody' (NFCI)

Discussed with and suggestions from <tonio>, thanks!

diffstat:

 chat/bitlbee/Makefile         |  16 ++++++++++------
 chat/bitlbee/files/bitlbee.sh |  14 +++++++++++++-
 2 files changed, 23 insertions(+), 7 deletions(-)

diffs (67 lines):

diff -r fff3e9044aa2 -r ce74a2b211c9 chat/bitlbee/Makefile
--- a/chat/bitlbee/Makefile     Wed May 23 17:48:07 2018 +0000
+++ b/chat/bitlbee/Makefile     Wed May 23 18:44:52 2018 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.75 2018/05/18 17:54:05 leot Exp $
+# $NetBSD: Makefile,v 1.76 2018/05/23 18:44:52 leot Exp $
 
 DISTNAME=              bitlbee-3.5.1
 PKGREVISION=           1
@@ -33,18 +33,22 @@
 CONF_FILES+=           ${EGDIR}/bitlbee.conf ${PKG_SYSCONFDIR}/bitlbee.conf
 OWN_DIRS+=             ${VARBASE}/run/bitlbee
 
-BUILD_DEFS+=           VARBASE
+BUILD_DEFS+=           VARBASE BITLBEE_USER BITLBEE_GROUP
+FILES_SUBST+=          BITLBEE_USER=${BITLBEE_USER} BITLBEE_GROUP=${BITLBEE_GROUP}
 
 EGDIR=                 ${PREFIX}/share/examples/bitlbee
 DATADIR=               ${PREFIX}/share/bitlbee
 DOCDIR=                        ${PREFIX}/share/doc/bitlbee
 STATEDIR=              ${VARBASE}/db/bitlbee
 
-OWN_DIRS_PERMS=                ${STATEDIR} bitlbee nobody 700
-OWN_DIRS_PERMS+=       ${VARBASE}/run/bitlbee bitlbee nobody 700
+BITLBEE_USER?=         bitlbee
+BITLBEE_GROUP?=                nobody
 
-PKG_GROUPS=            nobody
-PKG_USERS=             bitlbee:nobody
+OWN_DIRS_PERMS=                ${STATEDIR} ${BITLBEE_USER} ${BITLBEE_GROUP} 700
+OWN_DIRS_PERMS+=       ${VARBASE}/run/bitlbee ${BITLBEE_USER} ${BITLBEE_GROUP} 700
+
+PKG_GROUPS=            ${BITLBEE_GROUP}
+PKG_USERS=             ${BITLBEE_USER}:${BITLBEE_GROUP}
 PKG_HOME.bitlbee=      ${VARBASE}/db/bitlbee
 
 INSTALLATION_DIRS=     ${PKGMANDIR}/man5 ${PKGMANDIR}/man8 sbin
diff -r fff3e9044aa2 -r ce74a2b211c9 chat/bitlbee/files/bitlbee.sh
--- a/chat/bitlbee/files/bitlbee.sh     Wed May 23 17:48:07 2018 +0000
+++ b/chat/bitlbee/files/bitlbee.sh     Wed May 23 18:44:52 2018 +0000
@@ -3,13 +3,25 @@
 # PROVIDE: bitlbee
 # REQUIRE: DAEMON
 
-. /etc/rc.subr
+if [ -f /etc/rc.subr ]; then
+       . /etc/rc.subr
+fi
 
 name="bitlbee"
 rcvar=$name
 command="@PREFIX@/sbin/bitlbee"
 pidfile="@VARBASE@/run/${name}/pid"
 command_args="-D"      # run as a daemon
+start_precmd="bitlbee_precmd"
+
+bitlbee_precmd()
+{
+       if [ ! -d "@VARBASE@/run/${name}" ]; then
+               @MKDIR@ "@VARBASE@/run/${name}"
+               @CHMOD@ 0700 "@VARBASE@/run/${name}"
+               @CHOWN@ @BITLBEE_USER@:@BITLBEE_GROUP@ "@VARBASE@/run/${name}"
+       fi
+}
 
 if [ -f /etc/rc.subr ]; then
        load_rc_config $name



Home | Main Index | Thread Index | Old Index