Re: Running something on start up and shutdown
Thanks, that's what I needed. After consulting the policy manual, I decided the right thing was for the script to execute on entry into level S and exit for levels 0 and 6. The incantation for the script MSGateway is update-rc.d MSGateway start 90 S . stop 15 0 6 . reflecting my judgement I wanted the system basically up before the script ran on start up (priority 90, i.e., late) and I wanted the shutdown to happen relatively early (priority 15). I provide that account for the benefit of those who follow, and in hope that someone will let me know if it was a mistake! By the way, I'm not sure what the success thing was in the stop case below; I got errors when I tested it and removed it from my script. On Thu, Jun 13, 2002 at 09:28:18PM -0500, Ron Johnson wrote: 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 -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]
Re: Running something on start up and shutdown
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. your script could read: #!/bin/sh # /etc/init.d/myscript # references /etc/init.d/mystartupscript #/etc/init.d/myhaltscript case $1 in start|restart) su user -c '/etc/init.d/mystartupscript' ;; stop) su user -c '/etc/init.d/myhaltscript' ;; *) echo Usage: myscript start|stop|restart ;; esac # The End. just put it in init.d and use update-rc.d to make it run automatically greetz, Joris -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]
Re: Running something on start up and shutdown
In article [EMAIL PROTECTED], Ross Boylan [EMAIL PROTECTED] wrote: By the way, I'm not sure what the success thing was in the stop case below; I got errors when I tested it and removed it from my script. That's because the example was actually a redhat example. A standard init.d template can be found in /etc/init.d/skeleton You can use the --chuid option to start-stop-daemon to start something under a different uid - read the manpage. Mike. -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]
Re: Running something on start up and shutdown
On Fri, 2002-06-14 at 14:13, Miquel van Smoorenburg wrote: In article [EMAIL PROTECTED], Ross Boylan [EMAIL PROTECTED] wrote: By the way, I'm not sure what the success thing was in the stop case below; I got errors when I tested it and removed it from my script. That's because the example was actually a redhat example. Well, Mandrake, but that's just a quibble... I took that script from my Mandrake box when I changed to Debian, and was released from the bonds of RPM Hell... A standard init.d template can be found in /etc/init.d/skeleton You can use the --chuid option to start-stop-daemon to start something under a different uid - read the manpage. Thanks for the tip. -- +-+ | Ron Johnson, Jr.Home: [EMAIL PROTECTED] | | 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 [EMAIL PROTECTED] with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]
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: [EMAIL PROTECTED] | | 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 [EMAIL PROTECTED] with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]