linux init script help
-
yakko
- Posts: 258
- Joined: 2003-01-27 06:04
linux init script help
I'm trying to use the debian skeleton script to make a init script for DCH++ now that daemon mode works. I can't kill the process with the script because it looks like DCH++ starts up then spawns other processes and kills the first one. How can I get the process id of the parent DCH++ process so I can kill that to kill the hub?
-
yakko
- Posts: 258
- Joined: 2003-01-27 06:04
I figured out I could do a killall, and since my hub's currently running on this pc as well I renamed the executable and this seems to work for now. I'd like to do it a little more gracefully though. With this "/etc/init.d/dchpp start" and "/etc/init.d/dchpp stop" both work.
daemon (script to start DCH++)
/etc/init.d/dchpp
daemon (script to start DCH++)
Code: Select all
#! /bin/sh
/usr/local/bin/dchpp/dchpp31 eth0 -d/etc/init.d/dchpp
Code: Select all
#! /bin/sh
#
# skeleton example file to build /etc/init.d/ scripts.
# This file should be used to construct scripts for /etc/init.d.
#
# Written by Miquel van Smoorenburg <[email protected]>.
# Modified for Debian GNU/Linux
# by Ian Murdock <[email protected]>.
#
# Version: @(#)skeleton 1.9.1 08-Apr-2002 [email protected]
#
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin/dchpp
DAEMON=/usr/local/bin/dchpp/daemon
NAME=dchpp
DESC="DCH++ Direct Connect Hub Daemon"
test -x $DAEMON || exit 0
set -e
case "$1" in
start)
echo -n "Starting $DESC: $NAME"
start-stop-daemon --start --quiet --exec $DAEMON
#start-stop-daemon --start --quiet --make-pidfile --pidfile /var/run/$NAME.pid \
# --exec $DAEMON
echo "."
;;
stop)
echo -n "Stopping $DESC: $NAME "
killall dchpp31
#start-stop-daemon --stop --quiet --pidfile /var/run/$NAME.pid \
# --exec $DAEMON
echo "."
;;
*)
N=/etc/init.d/$NAME
# echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2
echo "Usage: $N {start|stop}" >&2
exit 1
;;
esac
exit 0
-
Sedulus
- Forum Moderator
- Posts: 687
- Joined: 2003-01-04 14:32
Code: Select all
-b|--background
Typically used with programs that don't detach on their own. This option will force start-
stop-daemon to fork before starting the process, and force it into the background. WARNING:
start-stop-daemon cannot check the exit status if the process fails to execute for any reason.
This is a last resort, and is only meant for programs that either make no sense forking on
their own, or where it's not feasible to add the code for it to do this itself.Code: Select all
-m|--make-pidfile
Used when starting a program that does not create its own pid file. This option will make
start-stop-daemon create the file referenced with --pidfile and place the pid into it just
before executing the process. Note, it will not be removed when stopping the program. NOTE:
This feature may not work in all cases. Most notably when the program being executed forks
from its main process. Because of this it is usually only useful when combined with the
--background option.perhaps arne could have it add a pidfile as /var/run/dchpp/$NAME.pid, where $NAME is the basename (i.e. /etc/dchpp/surfnet/ -> surfnet) of the config dir specified by -c
http://dc.selwerd.nl/hublist.xml.bz2
http://www.b.ali.btinternet.co.uk/DCPlusPlus/index.html (TheParanoidOne's DC++ Guide)
http://www.dslreports.com/faq/dc (BSOD2600's Direct Connect FAQ)
http://www.b.ali.btinternet.co.uk/DCPlusPlus/index.html (TheParanoidOne's DC++ Guide)
http://www.dslreports.com/faq/dc (BSOD2600's Direct Connect FAQ)
-
yakko
- Posts: 258
- Joined: 2003-01-27 06:04
-
Sedulus
- Forum Moderator
- Posts: 687
- Joined: 2003-01-04 14:32
well yes,
you could combine -b and --make-pid and NOT use -d on dchpp
but like it says, it's a last resort.
you could combine -b and --make-pid and NOT use -d on dchpp
but like it says, it's a last resort.
http://dc.selwerd.nl/hublist.xml.bz2
http://www.b.ali.btinternet.co.uk/DCPlusPlus/index.html (TheParanoidOne's DC++ Guide)
http://www.dslreports.com/faq/dc (BSOD2600's Direct Connect FAQ)
http://www.b.ali.btinternet.co.uk/DCPlusPlus/index.html (TheParanoidOne's DC++ Guide)
http://www.dslreports.com/faq/dc (BSOD2600's Direct Connect FAQ)
-
arnetheduck
- The Creator Himself
- Posts: 296
- Joined: 2003-01-02 22:15
-
yakko
- Posts: 258
- Joined: 2003-01-27 06:04
Here's scripts that use pids and work with DCH++ .32-3
/usr/local/bin/dchpp/dchppdaemon
/etc/init.d/dchpp
/usr/local/bin/dchpp/dchppdaemon
Code: Select all
#! /bin/sh
/usr/local/bin/dchpp/dchpp eth0 -d -p /var/run/dchpp.pid
/etc/init.d/dchpp
Code: Select all
#! /bin/sh
#
# dchpp Init script for starting the DCH++ hub daemon.
# copy this file to /etc/init.d.
#
# Change the daemon script path to the correct path for dch++
# Make sure the daemon script also contains the correct path.
#
#
# Version: @(#)dchpp 0.32-3 20-Jan-2004
#
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin/dchpp
DAEMON=/usr/local/bin/dchpp/dchppdaemon
NAME=dchpp
DESC="DCH++ Direct Connect Hub Daemon"
test -x $DAEMON || exit 0
set -e
case "$1" in
start)
echo -n "Starting $DESC: $NAME"
start-stop-daemon --start --quiet --pidfile /var/run/$NAME.pid \
--exec $DAEMON
echo "."
;;
stop)
echo -n "Stopping $DESC: $NAME "
start-stop-daemon --stop --quiet --pidfile /var/run/$NAME.pid \
--stop $DAEMON
echo "."
;;
*)
N=/etc/init.d/$NAME
echo "Usage: $N {start|stop}" >&2
exit 1
;;
esac
exit 0
-
Sedulus
- Forum Moderator
- Posts: 687
- Joined: 2003-01-04 14:32
http://dchpp.digitalbrains.com/extra/dchpp.init
assumes you have the following configuration:
assumes you have the following configuration:
Code: Select all
/etc/dchpp/
daemons (a file containing "my1sthub" and "my2ndhub", separated by linefeeds)
my1sthub/
dchpp.xml
(all other settings)
my2ndhub/
dhcpp.xml
(all other settings)http://dc.selwerd.nl/hublist.xml.bz2
http://www.b.ali.btinternet.co.uk/DCPlusPlus/index.html (TheParanoidOne's DC++ Guide)
http://www.dslreports.com/faq/dc (BSOD2600's Direct Connect FAQ)
http://www.b.ali.btinternet.co.uk/DCPlusPlus/index.html (TheParanoidOne's DC++ Guide)
http://www.dslreports.com/faq/dc (BSOD2600's Direct Connect FAQ)
Who is online
Users browsing this forum: Google [Bot] and 0 guests