Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question

4 Answers 4

up vote 13 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.

share|improve this answer

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.

share|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

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.

share|improve this answer

The easiest is to modify existing scripts, works in my system, used for sounds :)

  • startup, modify /etc/init.d/rc.local, add your sh at the end of the file, before : (it will execute it right before login "screen")
  • shutdown, modify /etc/init.d/halt, add your sh at the beginning of the file, just after initial comments (it will be executed before actual shutdown command, that is called by this script file
  • reboot, same as shutdown, but in /etc/init.d/reboot
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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