1

Is it possible to write a System V init script (the scripts usually stored in /etc/init.d and run with service) in Perl, and have the shell recognize the #!/usr/bin/perl? Would there be any downside to doing this?

DJG
  • 6,413
  • 4
  • 30
  • 51

1 Answers1

3

The scripts themselves can be written in any language, but support tools may need to parse the script for metadata required to decide when the initscript will start/stop. This restricts the choices to those which can make this metadata available in the form that the tools accept.

Additionally, there may be external files written in shell script which the initscript will require in order to operate properly/efficiently/effectively. Unless these files are very simple, any parser used to read them may grow very complex.

Ignacio Vazquez-Abrams
  • 776,304
  • 153
  • 1,341
  • 1,358
  • how does script parsing for metadata look like? – mpapec Sep 01 '13 at 11:37
  • That depends on the OS. For Linux, read the LSB for what the metadata should look like. – Ignacio Vazquez-Abrams Sep 01 '13 at 11:52
  • Least significant bit? I'm confused how such metadata could dictate sysv scripting. – mpapec Sep 01 '13 at 12:02
  • @mpapec: Linux Standard Base. Some distros have comments with the runlevels the script should be started/stopped on. 10-15 years ago, SuSE and RedHat differed, now they both probably follow the LSB guidelines. See: http://refspecs.linuxfoundation.org/LSB_3.1.0/LSB-Core-generic/LSB-Core-generic/tocsysinit.html – ninjalj Sep 01 '13 at 12:14