{
    "content": [
        {
            "type": "text",
            "text": "# init-d-script(5) (man)\n\n**Summary:** init-d-script — interpreter for short and simple init.d scripts\n\n## See Also\n\n- inittab(8)\n- service(8)\n- update-rc.d(8)\n\n## Section Outline\n\n- **NAME** (2 lines)\n- **DESCRIPTION** (113 lines)\n- **SEE ALSO** (2 lines)\n- **AUTHORS** (2 lines)\n- **Debian                          August 5, 2019                          Debian** (1 lines)\n\n## Full Content\n\n### NAME\n\ninit-d-script — interpreter for short and simple init.d scripts\n\n### DESCRIPTION\n\nGeneric init.d script framework to reduce the redundant code in /etc/init.d/.  The goal is to\ncreate an init.d script that is Debian and LSB compliant.  When the Debian policy conflicts\nwith the LSB, the Debian policy takes precedence.\n\nThis is a simple example on how init-d-script can be used to start and stop a daemon with PID\nfile support:\n\n#!/bin/sh /lib/init/init-d-script\n### BEGIN INIT INFO\n# Provides:          atd\n# Required-Start:    $syslog $time $remotefs\n# Required-Stop:     $syslog $time $remotefs\n# Default-Start:     2 3 4 5\n# Default-Stop:      0 1 6\n# Short-Description: run at jobs\n# Description:       Debian init script to start the daemon\n#                    running at jobs.\n### END INIT INFO\nDAEMON=/usr/sbin/atd\n\nThe following variables affect behaviour of an init script:\n\nDAEMON         Path to daemon being started.  If the init script is not supposed to start any\nkind of daemon, it should be set to “none” and the functions\ndostartoverride(), dostopoverride() and dostatusoverride() should be de‐\nfined instead.\n\nDAEMONARGS    Additional arguments, passed to daemon during start.\n\nDESC           Full name or short description of the daemon, printed on screen.  If unset, this\nvariable defaults to the “NAME” value.\n\nNAME           Additional environment variables are sourced from /etc/default/${NAME}.  If un‐\nset, this variable defaults to the basename of the “DAEMON” value.\n\nCOMMANDNAME   If this variable is set, it is used as argument to the --name option of\nstart-stop-daemon(8).  It may be useful if the value of the “NAME” variable is\nlonger than the command name length supported by the running kernel.  If the\nvalue is verbatim “none”, the command name will not be used to match the pro‐\ncesses.  If unset, this variable defaults to the “NAME” value.\n\nPIDFILE        Path to file where the process identifier of the started daemon will be stored\nduring start.  If the value is verbatim “none”, the process identifier will not\nbe stored in any file.  If this variable is not set, it gets a sensible default\nvalue, so it is rarely necessary to set this variable explicitly.\n\nRELOADSIGNAL  Signal number or name (without the SIG prefix) that will be sent to the process\non reload.  If the daemon performs reload action upon receiving a SIGHUP signal,\nthis variable should be set to “1” or “HUP”.\n\nThe variables RELOADARGS, STARTARGS and STOPARGS are additional arguments, passed to\nstart-stop-daemon(8) during reload, start and stop actions, to override the default options.\n\nAdditionally, it is possible to change the behaviour of the resulting shell script by overrid‐\ning some of the internal functions.  To do so, define function with an override suffix.  So,\nfor example, to override the dostatus() function, one should define a dostatusoverride()\nfunction.  The exception to this rule is the doreload() function, whose override should be de‐\nfined as-is, without the above-mentioned suffix.\n\nHere is a control flow chart that explains what functions are called and when:\n\n/etc/init.d/script start\ndostart\ndostartprepare # no-op\ndostartcmd     # start-stop-daemon is called here\ndostartcleanup # no-op\n\n/etc/init.d/script stop\ndostop\ndostopprepare # no-op\ndostopcmd     # start-stop-daemon is called here\ndostopcleanup # no-op\n\n/etc/init.d/script status\ndostatus\n\n/etc/init.d/script reload\ndoreload\ndousage\nexit 3\n\n/etc/init.d/script force-reload\ndoforcereload\ndoreload   # if overridden\ndorestart\ndorestartprepare\ndostopcmd\ndostartcmd\ndorestartcleanup\n\n/etc/init.d/script restart\ndoforcerestart\n/etc/init.d/script try-restart\nif dostatus; then\ndorestart\ndorestartprepare\ndostopcmd  # start-stop-daemon is called here\ndostartcmd # start-stop-daemon is called here\ndorestartcleanup\n\n/etc/init.d/script <arg>\ndounknown <arg>\nexit 3\n\n/etc/init.d/script\ndousage\n\nAs can be seen, by default, the script does not support the reload action; it should be imple‐\nmented by the script writer by defining a doreload() function.\n\nIf doreload() is not defined but doreloadcmd() is, the latter will be called on reload, af‐\nter doreloadprepare() and before doreloadcleanup().\n\n### SEE ALSO\n\ninittab(8), service(8), update-rc.d(8).\n\n### AUTHORS\n\nPetter Reinholdtsen <pere@debian.org>\n\n### Debian                          August 5, 2019                          Debian\n\n"
        }
    ],
    "structuredContent": {
        "command": "init-d-script",
        "section": "5",
        "mode": "man",
        "summary": "init-d-script — interpreter for short and simple init.d scripts",
        "synopsis": null,
        "flags": [],
        "examples": [],
        "see_also": [
            {
                "name": "inittab",
                "section": "8",
                "url": "https://www.chedong.com/phpMan.php/man/inittab/8/json"
            },
            {
                "name": "service",
                "section": "8",
                "url": "https://www.chedong.com/phpMan.php/man/service/8/json"
            },
            {
                "name": "update-rc.d",
                "section": "8",
                "url": "https://www.chedong.com/phpMan.php/man/update-rc.d/8/json"
            }
        ],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 113,
                "subsections": []
            },
            {
                "name": "SEE ALSO",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "AUTHORS",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "Debian                          August 5, 2019                          Debian",
                "lines": 1,
                "subsections": []
            }
        ]
    }
}