Init Script Installer

I’ve got a few scripts which need to run as system daemons. For a while
it worked to just manually start them, but it soon became annoying, so I
wrote a little script to create and install the init scripts for me.

Here’s what it does… it takes a template init script (similar to
/etc/init.d/skeleton) and updates it according to passed in arguments,
and then installs the script into /etc/init.d/

That’s it… now, i just run /etc/init.d/myservice start|restart|stop

any/all feedback would be great! Thanks,

Zach

p.s. - this will only work on *nix-like systems which use systemv style
init scripts

Checking for feedback this morning on this thread I see that my post
doesn’t make a whole lot sense. Perhaps a rephrase will help
it out, as mentionend previously I wrote an init script installer.
Currently you run it like:
ruby install_init_script.rb myscriptname
/path/to/where/script/should/be/run

This will create an /etc/init.d script which which utilizes the
start-stop-daemon (i am on a debian system). It will handle
forking your program for you and it will run it in the background as a
system daemon.

Right now that is all it does. I would like to have it wrap the script
itself in code that generates the pid file for the user and
handles removing it etc… I am thinking of doing something like:

init_script_install( scriptname, path2scriptdir ) do |script,
rootdir|
ensure_script_exists rootdir + ‘/’ + script
create_and_install :initscript, :script=>script,
:rootdir=>rootdir, :to => ‘/etc/init.d/’
create_and_install :scriptwrapper, :script=>script
end

Where the first ‘create_and_install :initscript’ creates the init
script, and the second part creates a wrapper for it which
handles the creation and removal of the pid file. For the wrapper I
think I need to either rename the original script, and put my
wrapper in it’s place, then have my wrapper require the renamed script,
or I need to modify the contents of the script itself.

Anyone have any ideas or thoughts on this? I’m not looking for code,
just input and opinions. I would like to get a decent base so
I can expand this to handle other types of system init scripts ( I
believe RH doesn’t use start-stop-daemon like debian does,
etc… ) before I release on rubyforge. Thanks,

Zach

On Mar 13, 2006, at 7:51 AM, zdennis wrote:

system daemon.
o => ‘/etc/init.d/’
Anyone have any ideas or thoughts on this? I’m not looking for
code, just input and opinions. I would like to get a decent base so
I can expand this to handle other types of system init scripts ( I
believe RH doesn’t use start-stop-daemon like debian does, etc… )
before I release on rubyforge. Thanks,

Zach

Zach-

I could use a script like this. i think its a good idea. Will you be

sharing the code? I can help test it for you if you want.

Cheers-
-Ezra

I’d also be happy to test this out.

Ezra Z. wrote:

Zach-

I could use a script like this. i think its a good idea. Will you be 

sharing the code?

Absolutely. I just didn’t want to post anything yet until I got some
base capabilities put in.

I can help test it for you if you want.

That would be great! After work I’ll get my code tested a little more
and I’ll email you privately the code if that works for you.

Thanks Ezra,

Zach