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

Re: Running something on start up and shutdown



On Thu, 2002-06-13 at 21:13, Ross Boylan wrote:
> What's the best way to run a script once on startup and again (well, a
> related script) on shutdown?  I want to run the scripts as a user
> rather than root, which I believe is the standard init.d method.

Since you (presumably) know about init.d & rc?.d, it's simple:
put a file in /etc/init.d just like always, but here's what it
will look like:

#!/bin/sh
# dnetc - starts and stops dnetc, the distributed.net key cruncher

# Source function library.
####. /etc/rc.d/init.d/functions

[ -x ~dnet/dnetc ] || exit 0

case "$1" in
  start)
	echo 'Starting distributed.net cracker'
    su -c ~dnet/dnet.start.sh dnet
	;;
  stop)
	echo -n 'Stopping distributed.net cracker'
	su -c ~dnet/dnet.shut.sh dnet
	success
	;;
  *)
	echo "Usage: $0 {start|stop}"
	exit 1
esac

exit 0


-- 
+---------------------------------------------------------+
| Ron Johnson, Jr.        Home: ron.l.johnson@cox.net     |
| Jefferson, LA  USA      http://ronandheather.dhs.org:81 |
|                                                         |
| "I have created a government of whirled peas..."        |
|   Maharishi Mahesh Yogi, 12-May-2002,                   |
!   CNN, Larry King Live                                  |
+---------------------------------------------------------+


-- 
To UNSUBSCRIBE, email to debian-user-request@lists.debian.org 
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org



Reply to: