the title pretty much sums it up.

how do I add a startup.sh and shutdown.sh of my server app to the startup and shutdown sequence of the Debian OS?

link|improve this question

feedback

3 Answers

up vote 9 down vote accepted

On Debian, service & application boot and shutdown scripts should be placed into /etc/init.d/.

Debian provides an example script /etc/init.d/skeleton that you can modify to your taste for your particular application.

Once it's in place, call:

# update-rc.d YOURAPP defaults

To have Debian add the /etc/rc?.d/ symlinks for you.

If you prefer a menu or graphical interface, take a look at the sysv-rc-conf or ksysv package.

link|improve this answer
feedback

You can call your script from /etc/rc.local, prior to the line that says exit 0

As for shutting down your app, I would suggest putting a script in /etc/rc0.d. You need to name it with an uppercase K, and then a 2 digit number which specifies the order these scripts are run, and then a name. It will be called with a parameter "stop", but you can ignore this for a simple stop script.

link|improve this answer
Why would you stuff around with rc.local when you've already got to fiddle with /etc/rcX.d anyway? – womble May 22 '09 at 1:30
rc.local is the proper place for simple startup stuff - don't need to deal with start/stop parameters, etc. But it doesn't have the ability to shut-down a process. The rc0.d stuff is a bit of a hack. – Brent May 22 '09 at 4:44
feedback

For startup have a look at this.

For shutdown, create a link / copy your script into one of the /etc/rcX.d folders where X is the runlevel that you want it to execute at. 0 is the shutdown runlevel for Debian I believe.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.