InitScript - files /etc/rc.d/init.d/*

InitScript is a parser for the initscripts in /etc/rc.d/init.d.

Because this parser read multiple files, the initscripts are stored as a list within the parser and need to be iterated through in order to find specific initscripts.


>>> for initscript in shared[InitScript]: # Parser contains list of all initscripts
...     print "Name:", initscript.file_name
Name: netconsole
Name: rhnsd
exception insights.parsers.initscript.EmptyFileException[source]

Bases: insights.core.exceptions.ParseException

class insights.parsers.initscript.InitScript(context)[source]

Bases: insights.core.Parser

Parse initscript files. Each item is a dictionary with following fields:


initscript name


initscript path without leading ‘/’


initscript content, line by line


Because some files may not be real initscripts, to determine whether a file in etc/rc.d/init.d/ is an initscript, the parser checks for # chkconfig: <values> or # Provides: <names> strings in the script. If that matches, then it assumes it is an initscript.

Otherwise, it tries to find out if it is by searching for

  • shebang (e.g. #!/bin/bash) on first line
  • start/stop/status tokens in non-commented out lines

If 3 or more items are found (half the items searched for + 1), called confidence in the code (e.g. shebang + start + stop), then we assume it is an initscript.

Otherwise the parser raises a ParseException.

exception insights.parsers.initscript.NotInitscriptException[source]

Bases: insights.core.exceptions.ParseException