Init Script Installer

Z

zdennis

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
 
Z

zdennis

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
 
E

Ezra Zygmuntowicz

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, :t
o => '/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


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
 
Z

zdennis

Ezra said:
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
 
W

William Ramirez

------=_Part_9967_33423855.1142275785551
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

I'd also be happy to test this out.

------=_Part_9967_33423855.1142275785551--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,202
Messages
2,571,057
Members
47,667
Latest member
DaniloB294

Latest Threads

Top