Subject: pkg/18740: Startup rc.d script for misc/dnetc
To: None <gnats-bugs@gnats.netbsd.org>
From: Julio Merino <jmmv@menta.net>
List: netbsd-bugs
Date: 10/20/2002 17:15:59
>Number: 18740
>Category: pkg
>Synopsis: Startup rc.d script for misc/dnetc
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: pkg-manager
>State: open
>Class: change-request
>Submitter-Id: net
>Arrival-Date: Sun Oct 20 08:12:00 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator: Julio Merino
>Release: NetBSD 1.6I
>Organization:
HispaBSD
>Environment:
System: NetBSD darkstar.local 1.6I NetBSD 1.6I (DARKSTAR) #19: Sun Oct 20 13:08:45 CEST 2002 jmmv@darkstar.local:/var/build/kernel/DARKSTAR i386
Architecture: i386
Machine: i386
>Description:
The package misc/dnetc can be improved by including a startup script.
This script should execute dnetc's daemon when the system is booting
and leave it processing units in the background, as an unpriviledged
user.
By default, this file will use /var/db/dnetc as the work area, running
under nobody:nobody. This may be changed, though.
The first time the script is run it starts dnetc's configuration, so
that the user can select his user id. Configuration can also be
launched through the special config keyword of the script at any
time.
>How-To-Repeat:
>Fix:
Apply this patch:
Index: Makefile
===================================================================
RCS file: /cvsroot/pkgsrc/misc/dnetc/Makefile,v
retrieving revision 1.2
diff -u -u -r1.2 Makefile
--- Makefile 2002/06/18 16:20:21 1.2
+++ Makefile 2002/10/20 15:06:59
@@ -2,6 +2,7 @@
DISTNAME= ${DISTNAME_${OPSYS}_${MACHINE_ARCH}}
PKGNAME= dnetc-2.8015.469
+PKGREVISION= 1
CATEGORIES= misc
MASTER_SITES= http://http.distributed.net/pub/dcti/current-client/
@@ -14,6 +15,8 @@
SunOS-*-sparc
NO_BUILD= YES
+RCD_SCRIPTS= dnetc
+
DISTNAME_Darwin_powerpc= dnetc-darwin-ppc
DISTNAME_NetBSD_m68k= dnetc-netbsd-68k
DISTNAME_NetBSD_alpha= dnetc-netbsd-alpha
@@ -32,4 +35,5 @@
${INSTALL_MAN} ${WRKSRC}/dnetc.1 ${PREFIX}/man/man1/
${INSTALL_PROGRAM} ${WRKSRC}/dnetc ${PREFIX}/bin/
+.include "../../mk/bsd.pkg.install.mk"
.include "../../mk/bsd.pkg.mk"
And now add this file to the files directory as `dnetc.sh':
#!/bin/sh
#
# $NetBSD$
#
# PROVIDE: dnetc
# REQUIRE: LOGIN
# KEYWORD: shutdown
. /etc/rc.subr
dnetc_user="nobody"
dnetc_group="nobody"
dnetc_homedir="/var/db/dnetc"
name="dnetc"
rcvar=$name
extra_commands="config"
# XXX: We cannot use the full pathname to call dnetc's binary directly.
# Doing so means it will not work properly.
PATH=@PREFIX@/bin:/bin:/sbin:/usr/bin:/usr/sbin
command="${name}"
dnetc_config() {
if [ ! -d ${dnetc_homedir} ]; then
mkdir ${dnetc_homedir}
chmod 755 ${dnetc_homedir}
chown ${dnetc_user}:${dnetc_group} ${dnetc_homedir}
fi
su -fm ${dnetc_user} -c "cd ${dnetc_homedir} && exec ${command} -config"
return 0
}
dnetc_start() {
if [ ! -f ${dnetc_homedir}/dnetc.ini ]; then
run_rc_command config
fi
echo "Starting ${name}."
su -fm ${dnetc_user} -c "cd ${dnetc_homedir} && exec ${command} &" \
2>/dev/null 1>/dev/null
}
config_cmd=dnetc_config
start_cmd=dnetc_start
load_rc_config $name
run_rc_command "$1"
Thank you!
>Release-Note:
>Audit-Trail:
>Unformatted: