To make your Startscript LSB conform, there are only a few things to do. Your Script need the following informations:
- Provide at-least ‘start, stop, restart, force-reload, and status’
- Return Proper exit code
- Document run-time dependencies
You can put these informations in a header like this one:
### BEGIN INIT INFO
# Provides: my_daemon
# Required-Start: postgresql networking
# Required-Stop: postgresql networking
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: This is a test daemon
# Description: This is a test daemon
# Name: your_name
# Build-Date: date
### END INIT INFO
For ruby-startscripts here is an example:
#!/usr/bin/env ruby
#
### BEGIN INIT INFO
#
# Startup script for gmetric from Sebastian Gleicher
# description: gmetric is the Ganglia Custom Metric Utility
# rubyboot_gmetric_daemon.rb is a start-script for gmetric-daemon
# Version Date 30.11.2012
#
# Provides: rubyboot_gmetric_daemon.rb
# Required-Start: $network $syslog
# Required-Stop: $network $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the rubyboot_gmetric_daemon
# Description: starts the rubyboot_gmetric_daemon to control the gmetric
# utility
#
# chkconfig: 2345 80 20
#
#!/usr/local/bin/gmetric_gpu.rb_controller
#
### END INIT INFO
APP_NAME = 'rubyboot_gmetric_daemon.rb'
APP_DIR = '/etc/init.d'
ARGV.each do|a|
puts "Argument: #{a}"
end
require 'daemons'
options = {
:dir_mode => :system,
:monitor => true
}
if ['start'].include? ARGV.first
puts "Starting gmetric-daemon"
Daemons.run('/var/lib/gmetric/gmetric_gpu.rb',options)
end
if ['stop'].include? ARGV.first
puts "Stopping gmetric-daemon"
Daemons.run('/var/lib/gmetric/gmetric_gpu.rb',options)
end
if ['restart'].include? ARGV.first
puts "Restarting gmetric-daemon"
Daemons.run('/var/lib/gmetric/gmetric_gpu.rb',options)
end
unless %w{start stop restart status}.include? ARGV.first
puts "Usage: #{APP_NAME} {start|stop|restart}"
end
exit
--
SebastianGleicher - 06 Sep 2012