7

I'm new to this SysOp stuff, so I'm wondering if it's possible to use other interpreted languages to write init.d scripts?

The upfront diff for me is /bin vs. /usr/bin

#!/bin/sh

versus

#!/usr/bin/perl
#!/usr/bin/php
#!/usr/bin/python
#!/usr/bin/ruby

Are there any other points I'm missing?

Lockhead
  • 95
  • 3

1 Answers1

9

Yes. There are issues of availability, speed, reliability, maintainability, etc, but init scripts can be written in whatever you want.

As is implied in your question, the /usr filesystem must be mounted before you can use the interpreters residing on it.

There are Perl modules for just this task. One example is Daemon::Control, there are many more for Perl as well as the other languages.

Bribles
  • 1,004
  • 6
  • 11
  • 2
    I can't overstate the importance of 'availability' in this context. We write our init scripts in perl, and we've run into all manner of interesting race conditions at init time: sure, the interpreter's available, but what about perl's site_lib? What about third-party libraries it depends on (expat, zlib, that sort of thing)? The dependency tree becomes non-trivial very quickly. If you're going to go down this road, my advice is to be very cautious and use only core-bundled features of the interpreter. – Jeff Albert Feb 07 '13 at 18:25
  • Thx bribles and @jeff-albert the point for me was if it's possible, I'm currently writing some socket server stuff and thought about why not writing the init script for that server in the same language. And yes dependency hell is everywhere... – Lockhead Feb 07 '13 at 18:35