From Night_H4nter, 1 Week ago, written in Diff-output.
This paste will kick the bucket in 2 Weeks.
Embed
  1. diff --git a/init_rosetta.md b/init_rosetta.md
  2. index 298f314..a5699ba 100644
  3. --- a/init_rosetta.md
  4. +++ b/init_rosetta.md
  5. @@ -1,16 +1,78 @@
  6. +# Init Rosetta
  7. +**Regardless of what init system and what operating system you use, please make
  8. +sure to read the [notes](#notes) below.**
  9.  
  10. -
  11. -| what to do/init system       | systemd                            | openRC                                                                       | runit | S6 |
  12. +| what to do/init system       | systemd                            | openRC                                                                       | runit | s6 |
  13.  |------------------------------|------------------------------------|------------------------------------------------------------------------------|-------|----|
  14.  | list service files           | `systemctl list-unit-files`        | `rc-status`                                                                  |       | `ls [SERVICE_REPO]` |
  15.  | list running services status | `systemctl list-units`             | `rc-update show`                                                             | sv status | `s6-rc -a list` |
  16. -| list failed services         | `systemctl --failed`               | `rc-status --crashed`                                                        |       | N/A |
  17. -| list available services      | `systemctl --all`                  | `rc-update -v show` or `ls /etc/init.d/`                                     | `ls /etc/sv/` (list all enabled services: `ls /etc/run/service`)| `s6-rc -d list` |
  18. +| list failed services         | `systemctl --failed`               | `rc-status --crashed`                                                        |       | N/A; see [notes](#general) |
  19. +| list available services      | `systemctl --all`                  | `rc-update -v show` or `ls /etc/init.d/`                                     | `ls /etc/sv/` (list all enabled services: `ls /etc/run/service`) | `s6-rc -d list` |
  20.  | start a service              | `systemctl start [SERVICE_NAME]`   | `rc-service [SERVICE_NAME] start` or `/etc/init.d/[SERVICE_NAME] start`      | `sv up [SERVICE_NAME]` or `sv u [SERVICE_NAME]` | `s6-rc -u change [SERVICE_NAME]` |
  21.  | stop a service               | `systemctl stop [SERVICE_NAME]`    | `rc-service [SERVICE_NAME] stop` or `/etc/init.d/[SERVICE_NAME] stop`        | `sv down [SERVICE_NAME]` or `sv d [SERVICE_NAME]` | `s6-rc -d change [SERVICE_NAME]` |
  22. -| restart a service            | `systemctl restart [SERVICE_NAME]` | `rc-service [SERVICE_NAME] restart` or `/etc/init.d/[SERVICE_NAME] restart`  | `sv restart [SERVICE_NAME]` or `sv t [SERVICE_NAME]` | `s6-rc -u change [SERVICE_NAME] && s6-rc -u change [SERVICE_NAME]` |
  23. -| get the status of a service  | `systemctl status [SERVICE_NAME]`  | `rc-service [SERVICE_NAME] status` or `/etc/init.d/[SERVICE_NAME] status`    | `sv status [SERVICE_NAME]` or `sv s [SERVICE_NAME]` | `s6-svstat [LIVE_SERVICE_DIR]` |
  24. -| enable a service             | `systemctl enable [SERVICE_NAME]`  | `rc-update add [SERVICE_NAME]`                                               | `ln -s /etc/sv/[SERVICE_NAME] /var/service/` |  |
  25. -| disable a service            | `systemctl disable [SERVICE_NAME]` | `rc-update del [SERVICE_NAME]`                                               | `rm /var/service/[SERVICE_NAME]` |  |
  26. +| restart a service            | `systemctl restart [SERVICE_NAME]` | `rc-service [SERVICE_NAME] restart` or `/etc/init.d/[SERVICE_NAME] restart`  | `sv restart [SERVICE_NAME]` or `sv t [SERVICE_NAME]` | `s6-svc -r [SCANDIR]/[SERVICE_NAME]` *(for long running services only)*|
  27. +| get the status of a service  | `systemctl status [SERVICE_NAME]`  | `rc-service [SERVICE_NAME] status` or `/etc/init.d/[SERVICE_NAME] status`    | `sv status [SERVICE_NAME]` or `sv s [SERVICE_NAME]` | `s6-rc -a list \| grep -qFx [SERVICE_NAME]`; exits 0, if `[SERVICE_NAME]` is up, exits 1 otherwise |
  28. +| enable a service             | `systemctl enable [SERVICE_NAME]`  | `rc-update add [SERVICE_NAME]`                                               | `ln -s /etc/sv/[SERVICE_NAME] /var/service/` | `export [VAR]=$(s6-rc-db -c [DATABASE] contents [BUNDLE]) && s6-rc-bundle -f add [BUNDLE] $[VAR] [SERVICE_NAME] && unset [VAR]`; see [notes](#for-artix-users-2) for Artix  |
  29. +| disable a service            | `systemctl disable [SERVICE_NAME]` | `rc-update del [SERVICE_NAME]`                                               | `rm /var/service/[SERVICE_NAME]` | `export [VAR]=$(s6-rc-db -c [DATABASE] contents [BUNDLE]) && s6-rc-bundle -f add [BUNDLE] $(echo $[VAR] \| grep -v [SERVICE_NAME]) && unset [VAR]`; see [notes](#for-artix-users-2) for Artix  |
  30. +
  31. +
  32. +# Notes
  33. +
  34. +#### runit
  35. +
  36. +##### For Artix users
  37. +
  38. +* available services are in `/etc/runit/sv/` directory
  39. +* enabled services are in `/run/runit/service/` directory
  40. +
  41. +
  42. +#### s6
  43. +
  44. +##### General
  45. +
  46. +* most of the commands listed are actually the commands from `s6-rc`, which
  47. +works on top of `s6`; you should generally avoid touching `s6` itself, unless
  48. +it's suggested here, or you really know what you're doing
  49. +* `s6-rc` does not implement "failed" state; only "up" and "down" states are
  50. +supported
  51. +* when disabling a service, keep in mind you should also disable all the
  52. +services that depend on it, otherwise the service manager will restart the
  53. +disabled service as a dependency of another service
  54. +* all the commands suggested for manually enabling/disabling a service do not
  55. +make any sanity checks, so make sure you've done all the necessary backups
  56. +before running them
  57. +   * do not use the variable name that is already in use by something else
  58. +   * consider dumping the value of `[VAR]` somewhere before unsetting it
  59. +   to be able to recompile the database in case of any errors
  60. +
  61. +- `[SERVICE_REPO]` is the absolute path to your service repository
  62. +for `s6-svscan`
  63. +    * refer to your system documentation, if you don't know this path
  64. +- `[SCANDIR]` is the absolute path to your scan directory for `s6-svscan`
  65. +    * run `pstree -a | head -n1`; the last argument of command in the output
  66. +    should be the path you  need
  67. +- `[VAR]` is an arbitrary variable to store previous contents of the bundle
  68. +- `[DATABASE]` is the absolute path to the compiled database
  69. +    * refer to your system documentation, if you don't know this path
  70. +- `[BUNDLE]` is the name of bundle, most likely the top level one
  71. +    * refer to your system documentation, if you don't know the bundle name
  72. +    * issuing `s6-rc-db -d all-dependencies [SERVICE_NAME]` might help, as it
  73. +    lists all the services that depend on `[SERVICE_NAME]`, the top level
  74. +    bundle included, you can try making something up from there
  75. +
  76. +
  77. +##### For Artix users
  78. +
  79. +* all commands listed require `sudo` privileges by default
  80. +* to enable/disable a service, use the helper script `s6-rc-bundle-update`:
  81. +```sh
  82. +s6-rc-bundle-update add default [SERVICE_NAME]              #enable
  83. +s6-rc-bundle-update delete default [SERVICE_NAME]           #disable
  84. +```
  85. +
  86. +- `[SERVICE_REPO]` is `/etc/s6/sv/` directory
  87. +- `[SCANDIR]` is `/run/service/` directory
  88. +- `[VAR]` is an arbitrary variable to store previous contents of the bundle
  89. +- `[DATABASE]` is `/run/s6-rc/compiled/` directory
  90. +- `[BUNDLE]` is then name of bundle, most likely `default`
  91.  
  92. -> note, if you're an Artix user, available services are in `/etc/runit/sv` directory and the enabled services are in `/run/runit/service` directory
  93.