Subject: Creating an /etc/rc.d service script.
To: None <netbsd-users@netbsd.org>
From: None <RFischer@PanAmSat.com>
List: netbsd-users
Date: 08/17/2001 14:27:16
(I hope this isn't a rehash of some previous discussion on this list.
If so, please point me to the general time frame that it occurred and
I'll look it up.)
On my NetBSD 1.5 system I've added a script to my /etc/rc.d directory to
start up
Netatalk-asun package installed via pkgsrc. The package installed a file
to start-up the service in /usr/pkg/etc/rc.d/netatalk.sh.
The installed script only starts up the daemons, but I'd like my rc.d script
to additionally handle "stop" and "restart" arguments too.
I've been unsuccessful at desciphering exactly how I should use the
/etc/rc.subr and run_rc_command combination. Will the "run_rc_command" do
what I want?
It appears that netatalk does not keep a /var/run/atalk.pid file.
Will my greps in the stop section (to search for the pid) foul up when 'ps'
finds
the grep task in addition to the process I'm looking for?
Is the recursive call to /etc/rc.d/atalk.sh under the restart OK?
TIA for any help.
- Roger
Heres what I have so far.
*-- snip --*
#!/bin/sh
# /etc/rc.d/atalk.sh
#
# PROVIDE: atalk
# REQUIRE: NETWORK
. /etc/rc.subr
name="atalk"
rcvar=$name
command="/usr/pkg/etc/rc.d/netatalk.sh"
load_rc_config $name
# if [ $1 = start ] ; then
# run_rc_command "$1"
/usr/pkg/etc/rc.d/netatalk.sh
# elif [ $1 = stop ] ; then
# kill -HUP `ps -e | grep atalkd | awk '{print $1}'`
# echo atalkd stopped
# kill -HUP `ps -e | grep afpd | awk '{print $1}'`
# echo afpd stopped
# kill -HUP `ps -e | grep papd | awk '{print $1}'`
# echo papd stopped
# elif [ $1 = restart ] ; then
# /etc/rc.d/atalk.sh stop
# /etc/rc.d/atalk.sh start
# else ;
# echo command unavailable
# fi
*-- snip --*