| 1 | Run-parts Scripts |
| 2 | ----------------- |
| 3 | |
| 4 | **Syntax:** `runparts [progress] [sysv] <DIR>` |
| 5 | |
| 6 | Call [run-parts(8)][] on `DIR` to run start scripts. All executable |
| 7 | files in the directory are called, in alphabetic order. The scripts in |
| 8 | this directory are executed at the very end of runlevel `S`. |
| 9 | |
| 10 | A common use-case for runparts scripts is to create and enable/disable |
| 11 | services, which Finit will then apply when changing runlevel from S to |
| 12 | whatever the next runlevel is set to be (default 2). E.g., generate a |
| 13 | `/etc/chrony.conf` and call `initctl enable chronyd`. |
| 14 | |
| 15 | **Options:** |
| 16 | |
| 17 | - `progress`: display the progress of each script being executed |
| 18 | - `sysv`: run only SysV style scripts, i.e., `SNNfoo`, or `KNNbar`, |
| 19 | where `NN` is a number (0-99). |
| 20 | |
| 21 | If global debug mode is enabled, the `runparts` program is also called |
| 22 | with the debug flag. |
| 23 | |
| 24 | **Limitations:** |
| 25 | |
| 26 | Scripts called from `runparts`, or hook scripts (see below), are limited |
| 27 | in their interaction with Finit. Like the standalone `run` stanza and |
| 28 | the `/etc/rc.local` shell script, Finit waits for their completion |
| 29 | before continuing. None of them can issue commands to start, stop, or |
| 30 | restart other services. Also, ensure all your services and programs |
| 31 | either terminate or start in the background or you will block Finit. |
| 32 | |
| 33 | > [!NOTE] |
| 34 | > `runparts` scripts are only read and executed in runlevel S. See |
| 35 | > [hook scripts](../plugins.md#hooks) for other ways to run scripts at |
| 36 | > certain points during the complete lifetime of the system. |
| 37 | |
| 38 | **Recommendations:** |
| 39 | |
| 40 | It can be beneficial to use `01-name`, `02-othername`, etc., to ensure |
| 41 | the scripts are started in that order, e.g., if there is a dependency |
| 42 | order between scripts. Symlinks to existing daemons can talso be used, |
| 43 | but make sure they daemonize (background) themselves properly, otherwise |
| 44 | Finit will lock up. |
| 45 | |
| 46 | If `S[0-9]foo` and `K[0-9]bar` style naming is used, the executable will |
| 47 | be called with an extra argument, `start` and `stop`, respectively. |
| 48 | E.g., `S01foo` will be called as `S01foo start`. Of course, `S01foo` |
| 49 | and `K01foo` may be a symlink to to `another/directory/foo`. |
| 50 | |
| 51 | [run-parts(8)]: http://manpages.debian.org/cgi-bin/man.cgi?query=run-parts |