Remove net-tools requirement from README
[archnosh.git] / README.md
blobb14d31e05626af440e6130d7ef6940c9efecbf38
1 # Archnosh is nosh for Archlinux
3 This repository provides the build files necessary to integrate the [nosh](https://jdebp.eu/Softwares/nosh/) system and service manager with Archlinux package management.
5 The packaging here closely follows the [Debian packaging](https://jdebp.eu/Softwares/nosh/debian-binary-packages.html) provided by the author of nosh.
8 ## How do I use it?
10 With caution! Installing some of the nosh packages provided here can profoundly change the way your system bootstraps and runs services.
12 Furthermore, the packages have so far been tested locally on virtual machines with minimum installs of early 2018 Archlinux releases and on a personal laptop, where they *do* work for the most part but tailoring to your system will be necessary.
14 *Caveat emptor.*
17 ### The packages
19 This is a [split-package](https://www.archlinux.org/pacman/PKGBUILD.5.html#_package_splitting) PKGBUILD which will generate packages covering the toolset aswell as a service bundle collection which together can provide a complete working system.
21 Use the latest available released archive, i.e. the latest tagged git commit.
23 This README applies to the latest release.
25 Note that preset files will be handled as [config files](https://www.archlinux.org/pacman/pacman.8.html#_handling_config_files_a_id_hcf_a).
27 Service bundles, however, are a form of configuration via the filesystem and are less amenable to pacman's config file mechanism. Saving the run files under the `service` directory would reflect this configuration only partially. Currently therefore, in order to preserve customization through package upgrades, you should patch the systemd-like service files from which the bundles are generated.
30 #### Dependencies
32 The make dependencies are the following and require [AUR](https://wiki.archlinux.org/index.php/Aur) access to be set up:
34 * [pax](https://aur.archlinux.org/packages/pax/) (AUR)
35 * [redo-jdebp](https://aur.archlinux.org/packages/redo-jdebp/) (AUR)
36 * [xmlto](https://www.archlinux.org/packages/extra/x86_64/xmlto/) (Extra)
37 * [docbook-xml](https://www.archlinux.org/packages/extra/any/docbook-xml/) (Extra)
38 * [docbook-xsl](https://www.archlinux.org/packages/extra/any/docbook-xsl/) (Extra)
40 For [package building](https://wiki.archlinux.org/index.php/Arch_Build_System) in general, ensure the [base-devel](https://www.archlinux.org/groups/x86_64/base-devel/) package is installed.
43 #### Build and install the packages
45 Put the files in a directory and run:
47     $ makepkg
49 You can then install the generated packages with:
51     # pacman -U <package-name>
53 N.B.: due to a change in dbus-daemon behaviour and since nosh-1.37, `nosh-desktop-bus-shims` needs to override the `dbus-daemon-launch-helper` binary from the `core/dbus` Archlinux package with its own. While the Debian package uses the `dpkg-divert` mechanism, no similar method appears to exist on Arch (suggestions welcome).
55 The Archnosh package currently overwrites `/usr/lib/dbus-1.0/dbus-daemon-launch-helper`. This has two consequences:
57 * one must use the `--overwrite=usr/lib/dbus-1.0/dbus-daemon-launch-helper` option when installing with pacman to avoid a file collision error
58 * `nosh-desktop-bus-shims` now competes with `core/dbus` and must be reinstalled when the latter is updated.
60 In fact several nosh packages have files that may conflict with existing Archlinux packages. In some cases the packages are set to conflict in the `PKGBUILD` if nosh provides a complete replacement. In others, where nosh offers partial replacements such as for `core/dbus` above, the packages will not conflict and the [--overwrite option](https://www.archlinux.org/pacman/pacman.8.html#_upgrade_options_apply_to_em_s_em_and_em_u_em_a_id_uo_a) may be used to install them.
62 For example:
64     # pacman -U nosh-core-shims-1.40-1-x86_64.pkg.tar.xz
65     (...)
66     error: failed to commit transaction (conflicting files)
67     nosh-core-shims: /usr/bin/chroot exists in filesystem (owned by coreutils)
68     nosh-core-shims: /usr/bin/false exists in filesystem (owned by coreutils)
69     nosh-core-shims: /usr/bin/printenv exists in filesystem (owned by coreutils)
70     nosh-core-shims: /usr/bin/true exists in filesystem (owned by coreutils)
71     nosh-core-shims: /usr/share/man/man1/chroot.1.gz exists in filesystem (owned by coreutils)
72     nosh-core-shims: /usr/share/man/man1/false.1.gz exists in filesystem (owned by coreutils)
73     nosh-core-shims: /usr/share/man/man1/printenv.1.gz exists in filesystem (owned by coreutils)
74     nosh-core-shims: /usr/share/man/man1/true.1.gz exists in filesystem (owned by coreutils)
75     Errors occurred, no packages were upgraded.
77     # pacman -U nosh-core-shims-1.40-1-x86_64.pkg.tar.xz --overwrite="*"
79 Of course, each install using `--overwrite` competes with its corresponding package and upgrades will have to be tracked somehow, to make sure the correct files are in use.
82 ### Running nosh
84 Read the [timorous admin's installation how-to](https://jdebp.eu/Softwares/nosh/timorous-admin-installation-how-to.html).
86 The following describes the two expected common setups.
88 Both assume that you are running the default [systemd](https://wiki.archlinux.org/index.php/Systemd)-managed install.
91 #### nosh service manager only: nosh-run-via-systemd
93 It is possible to run nosh as a service manager alongside systemd.
95 The following packages are necessary:
97 * nosh-common
98 * nosh-exec
99 * nosh-service-management
100 * nosh-terminal-management
101 * nosh-bundles
102 * nosh-run-via-systemd
103 * nosh-run-debian-server-base or nosh-run-debian-desktop-base
105 Due to Archlinux's default preset *disable* policy (`/usr/lib/systemd/system-preset/99-default.preset`), you need to enable the following unit:
107     # systemctl enable service-manager.socket
109 Then you should enable one or both of:
111 * system-control-normal.service
112 * service-manager-svscan.path
114 `system-control-normal.service` uses nosh [targets](https://jdebp.eu/Softwares/nosh/guide/anatomy-of-system-target.html) to bring up enabled services. Simply run `system-control enable <service>` and `systemctl disable <service>` for its equivalent in order to switch management of the service over to nosh.
116 `service-manager-svscan.path` will scan and bring up any service bundle you place in the `/service` directory (which you will have to create), effectively enabling it. This is the more typical daemontools [approach](https://cr.yp.to/daemontools/faq/create.html#why).
118 It's probably simpler to stick to just one of these methods.
120 Creating preset files for these units will also ensure their enabled/disabled status in case of package upgrades.
122 Also make sure to check the presets provided by the chosen `nosh-run-debian-X-base` package, they will activate *some* services by default.
125 #### nosh system and service manager: nosh-run-system-manager
127 For a fully nosh-managed system, i.e. nosh running as the init process and service manager, install the following packages:
129 * nosh-common
130 * nosh-exec
131 * nosh-execline-shims
132 * nosh-freebsd-shims
133 * nosh-service-management
134 * nosh-terminal-management
135 * nosh-bundles
136 * nosh-run-system-manager
137 * nosh-run-udev or nosh-run-systemd-udev
138 * nosh-run-kernel-vt
139 * nosh-run-debian-server-base or nosh-run-debian-desktop-base
140 * nosh-run-local-syslog
141 * nosh-run-klogd
143 Note that `nosh-run-system-manager` conflicts with `systemd-sysvcompat` which should be removed.
145 Installing these packages will raise a lot of the following errors:
147     reset: ERROR: connect: /run/service-manager/control: No such file or directory
149 This is due to the fact that nosh isn't actually properly running yet but is not an issue. The system will work properly after a reboot (`system-control reboot`).
152 ##### systemd-udev
154 The installation above assumes udev is the device manager, which is provided by the [systemd](https://www.archlinux.org/packages/core/x86_64/systemd/) package on Archlinux.
156 The easiest method is to simply use the binaries and configuration files provided by this package to run udev. The `nosh-run-systemd-udev` package will do just that and everything should work transparently. This means all udev configuration rules already set up should work as-is.
159 ##### eudev
161 Alternatively you may wish to use the [eudev](https://wiki.gentoo.org/wiki/Eudev) implementation rather than keeping the systemd package for udev functionality.
163 We will detail the installation of [eudev](https://aur.archlinux.org/packages/eudev/), [libeudev](https://aur.archlinux.org/packages/libeudev/), [eudev-systemd](https://aur.archlinux.org/packages/eudev-systemd/) and [libeudev-systemd](https://aur.archlinux.org/packages/libeudev-systemd/) (available from the AUR) which should provide a drop-in replacement for systemd/udev.
165 1. Install libeudev
167     This conflicts with the libsystemd package, you should remove it but it will almost certainly be a dependency for other packages on your system so run:
169         # pacman -d -d -S libeudev
171     The `-d` (or `--nodeps`) repeated option skips dependency checking. You will be providing replacements for these dependencies.
173     It might also fail to install due to the following pre-existing files: `/usr/include/libudev.h` and `/usr/lib/pkgconfig/libudev.pc`. Remove these manually.
175 2. Install libeudev-systemd
177     This will provide the `libsystemd.so` libraries.
179 3. Install eudev
181     This conflicts with the systemd package and, again, will doubtless bring up many dependency warnings so run:
182     
183         # pacman -d -d -S eudev
185 4. Install eudev-systemd
187     This will provide some shim systemd binaries and libraries.
189 The `nosh-run-udev` package will run the `udevd` binary, provided by eudev here.
191 From there you will have a working udev and some systemd shims which should allow installing most packages without too much trouble.
193 Run-packages for other device managers are provided: vdev, busybox-mdev and suckless-mdev. You will probably need to account for Archlinux's rather heavy systemd/udev integration in order to use them.
196 ##### base presets
198 The `nosh-run-debian-X-base` packages have not currently been renamed but one of them must be used.
200 They provide essential presets for booting your system. The "desktop-base" extends the "server-base" presets.
202 Make sure to check, modify or add preset files where necessary in `/usr/share/system-control/presets`.
204 The `90-*-boot-essentials.preset` files, in particular, contain services for [mounting filesystems](https://jdebp.eu/Softwares/nosh/guide/fstab.html), for loading necessary kernel modules, service targets to achieve etc.
207 ##### per-user service management
209 For user-controlled services, a [per-user manager](https://jdebp.eu/Softwares/nosh/guide/per-user-manager.html) can be enabled for user *my_user* with:
211     # system-control enable user@my_user
213 This will start [per-user service management](https://jdebp.eu/Softwares/nosh/guide/per-user-system-services.html) for *my_user* on system boot.
215 Default user service bundles are generated by users running `redo all` in their `$HOME/.config/service-bundles/convert/` directory.
217 Additional user service bundles can be placed under `$HOME/.config/service-bundles/services/` and controlled with:
219     $ system-control --user <command>
222 ##### networking
224 Service bundles are available for various network managers, such as Wicd and NetworkManager.
226 Native network configuration is also [available](https://jdebp.eu/Softwares/nosh/guide/networking.html).
228 It can be achieved, via the [rc.conf amalgamation](https://jdebp.eu/Softwares/nosh/guide/rcconf-amalgamation.html) mechanism, by writing a [Debian-style](https://wiki.debian.org/NetworkConfiguration) `/etc/network/interfaces` file or directly in [FreeBSD-style](https://www.freebsd.org/doc/handbook/config-network-setup.html) within `/etc/rc.conf`.
230 A `dhcpcd@` service (the [default enabled tool](https://wiki.archlinux.org/index.php/Installation_guide#Connect_to_the_Internet) for wired devices on Archlinux) is generated for each interface and is preset enabled by `90-linux-static-networking.preset`.
232 It should be enabled automatically (on interfaces configured with dhcp of course). The discovery script will detect [dhclient](https://www.isc.org/downloads/dhcp/), [udhcpc](https://udhcp.busybox.net/) and [dhcpcd](https://roy.marples.name/projects/dhcpcd). You can manually set your client in `/etc/rc.conf` or `/etc/rc.conf.local` with the `dhclient_program` variable.
234 Don't forget to run `redo all` after applying configuration changes. Check `/etc/system-control/convert/static-networking` to make sure the desired services for your interface are set to `on`.
237 ##### non-root Xorg and device access
239 Since we are not using systemd's `logind`, starting X as an unpriviledged user requires adding that user to the "input" and "video" groups.
241 See [https://wiki.gentoo.org/wiki/Non_root_Xorg](https://wiki.gentoo.org/wiki/Non_root_Xorg) for further details.
243 In the same vein, other device access may no longer work for unpriviledged users. You will probably have to add users to the "audio" group to use a soundcard for instance.
245 [elogind](https://github.com/elogind/elogind) might conceivably be used to achieve systemd behaviour here.
248 ##### shims
250 Various "shim" packages exist to provide the following:
252 1. Commands from other service or system managers that will invoke the corresponding nosh management actions, e.g. nosh-debian-shims, nosh-systemd-shims, nosh-upstart-shims, etc.
254 2. Utilities which may be provided by other packages, e.g. nosh-execline-shims, nosh-ucspi-tcp-shims, nosh-kbd-shims, etc.
257 ##### virtual terminals
259 Rather than kernel virtual terminals, [user-space virtual terminals](https://jdebp.eu/Softwares/nosh/guide/user-virtual-terminals.html) may be used by installing `nosh-run-user-vt`.
261 The `nosh-execline-shims` package is necessary if you do not have [execline](https://skarnet.org/software/execline/) available.
263 Also ensure that you have the proper [resources](https://jdebp.eu/Softwares/nosh/guide/terminal-resources.html) available to use the virtual terminals.
266 ##### troubleshooting and exceptional boot modes
268 A [troubleshooting](https://jdebp.eu/Softwares/nosh/guide/troubleshooting.html) page is available for potential issues aswell as a [gazetteer](https://jdebp.eu/Softwares/nosh/guide/gazetteer.html) to find the location of relevant files.
270 In certain cases your system may need to be booted in an [exceptional mode](https://jdebp.eu/FGA/emergency-and-rescue-mode-bootstrap.html).
272 * A *rescue mode* is available for nosh by appending "s" to the kernel boot parameters.
274 * An *emergency mode* is available by appending "b" to the kernel boot parameters.
277 ## Some nosh guidelines
279 The online [nosh guide](https://jdebp.eu/Softwares/nosh/guide/), also available in the `nosh-guide` package, and command [manpages](https://jdebp.eu/Softwares/nosh/guide/commands.html) provide comprehensive documentation.
281 The nosh toolset follows general [daemontools design](https://jdebp.eu/FGA/daemontools-family.html) which includes:
283 * using the filesystem as database and API: the system can be inspected and modified using standard filesystem commands
284 * logging as an ordinary --"first-class citizen"-- service
285 * chain-loading of simple utilities to build a controlled final running state
286 * composability: utilities from other toolsets in this family can be used in conjunction with nosh
288 To these features nosh [adds](https://jdebp.eu/Softwares/nosh/guide/new-interfaces.html):
290 * explicit separation of *service* and *system* management
291 * terminal management
292 * service ordering and interdependency through "service bundles" which allows for system "targets" similar to systemd
293 * restart scripts
294 * etc.
296 For a general presentation you may read the following:
298 [https://jdebp.eu/Softwares/nosh/guide/introduction.html](https://jdebp.eu/Softwares/nosh/guide/introduction.html)
301 ### Service bundles
303 A standard bundle will look something like this:
305     /var/sv $ tree kamailio
306     kamailio
307     ├── after
308     │   ├── basic -> /etc/service-bundles/targets/basic
309     │   └── log -> ../log
310     ├── before
311     │   └── shutdown -> /etc/service-bundles/targets/shutdown
312     ├── conflicts
313     ├── log -> ../cyclog@kamailio
314     ├── required-by
315     ├── service
316     │   ├── env
317     │   ├── restart
318     │   ├── run
319     │   ├── start
320     │   └── stop
321     ├── stopped-by
322     │   └── shutdown -> /etc/service-bundles/targets/shutdown
323     ├── supervise
324     │   ├── control
325     │   ├── lock
326     │   ├── ok
327     │   └── status
328     ├── wanted-by
329     │   └── server -> /etc/service-bundles/targets/server
330     └── wants
331         └── basic -> /etc/service-bundles/targets/basic
333 The `before` and `after` directories allow for linking to other service bundles to set *ordering constraints*.
335 The `conflicts`, `required-by`, `stopped-by`, `wanted-by` and `wants` directories allow for linking to other service bundles to set *dependency constraints*.
337 The `log` directory points to a logging service.
339 The `service` directory contains the scripts used to run the service. `service/env` can be used to store configuration information.
341 The `supervise` directory contains the control/status API files.
344 ### logging
346 Logging is a service on par with any other. In general one logging service is associated with each daemon to capture and manage its output (log rotation, size capping etc.) although fan-in from multiple services to one logging service is also possible.
348 The daemontools [assumption](https://jdebp.eu/FGA/unix-daemon-design-mistakes-to-avoid.html) is that daemons log to their standard error, *not* to syslog. Specialised logging tools can then be used to manage this output.
350 More generally, daemons are expected not to implement functions such as dropping privileges, socket management, resource limiting, etc. which could be provided by external tools, typically the daemontools family toolsets and other service managers (see the same argument for systemd's ["new-style"](https://www.freedesktop.org/software/systemd/man/daemon.html) daemons).
352 In practice, nosh [connects](https://jdebp.eu/Softwares/nosh/guide/log-service-plumbing.html) a service's standard output and error to the service pointed to by the "log" directory of the service bundle. Below are some excerpts of the `lsof` command to illustrate:
354     COMMAND   PID     USER   FD      TYPE             DEVICE SIZE/OFF   NODE NAME
356     # the sshd service, file descriptors 1 and 2 refer to pipe 17119
357     tcp-socke 976     root  cwd       DIR              254,0     4096 198091 /var/sv/sshd/service
358     tcp-socke 976     root  txt       REG              254,0   212968  62095 /usr/bin/tcp-socket-accept
359     tcp-socke 976     root    0r     FIFO               0,10      0t0  17188 pipe
360     tcp-socke 976     root    1w     FIFO               0,10      0t0  17119 pipe
361     tcp-socke 976     root    2w     FIFO               0,10      0t0  17119 pipe
363     # the cyclog@sshd service, file descriptor 0 refers to pipe 17119: reading sshd's stdout and stderr
364     cyclog    963 sshd-log  txt       REG              254,0   212968  63713 /usr/bin/cyclog
365     cyclog    963 sshd-log    0r     FIFO               0,10      0t0  17119 pipe
366     cyclog    963 sshd-log    1w     FIFO               0,10      0t0   8409 pipe
367     cyclog    963 sshd-log    2w     FIFO               0,10      0t0   8409 pipe
368     cyclog    963 sshd-log    6w      REG              254,0        0 202749 /var/log/sv/sshd/current
370     # note that cyclog@sshd's own stdout and stderr point to pipe 8409 which is actually the system-wide logger's input
371     cyclog    163     root  txt       REG              254,0   130984  63711 /usr/bin/system-manager
372     cyclog    163     root    0r     FIFO               0,10      0t0   8409 pipe
373     cyclog    163     root    1u      CHR                5,1      0t0   6547 /dev/console (deleted)
374     cyclog    163     root    2u      CHR                5,1      0t0   6547 /dev/console (deleted)
375     cyclog    163     root    5w      REG               0,18    81718   8433 /run/system-manager/log/current
377     # ... just as init's own stdout and stderr also point to the system-wide cyclog
378     init        1     root  txt       REG              254,0   130984  63711 /usr/bin/system-manager
379     init        1     root    0r      CHR                1,3      0t0   6465 /dev/null
380     init        1     root    1w     FIFO               0,10      0t0   8409 pipe
381     init        1     root    2w     FIFO               0,10      0t0   8409 pipe
383 The "log" directory name is a bit misleading insofar as one could chain anything to the service and create an arbitrarily long pipe chain. That being said, service `run` files already use [chain-loading mechanisms](https://jdebp.eu/Softwares/nosh/guide/chain-loading-cheatsheet.html) so it generally really is a logging service that is ultimately piped to.
386 ### system-control
388 [system-control](https://jdebp.eu/Softwares/nosh/guide/system-control.html) is the system workhorse command from a user perspective.
390 It provides high-level system-wide and per-user service management (start/stop, enable/disable etc.) aswell as system management (reboot, poweroff etc.) and various other specialised commands for e.g. converting systemd-style unit files to service bundles.
393 ### Converting systemd unit files
395 `system-control convert-systemd-units <unit-file>` supports conversion for [various types](https://jdebp.eu/Softwares/nosh/guide/converting-systemd-units.html) of systemd unit files to service bundles.
397 It also understands extended syntax to express service bundle-specific functionality in a systemd-like unit file, which can be used for easy distribution for example.
399 In other words, one can benefit from existing systemd unit files through automatic conversion in most cases.
402 ## Automation
404 Basic support for service management is available with the [Ansible nosh module](http://docs.ansible.com/ansible/latest/modules/nosh_module.html#nosh-module).
407 ## Repositories
409 This repository is publicly available at the following locations:
411 1. [https://framagit.org/taca/archnosh](https://framagit.org/taca/archnosh)
412 2. [https://repo.or.cz/archnosh.git](https://repo.or.cz/archnosh.git)
413 3. [https://github.com/tacatac/archnosh](https://github.com/tacatac/archnosh)
416 ## License
418 These packaging configuration files are distributed under the public domain [Unlicense](https://unlicense.org/), see the UNLICENSE file provided.
420 The nosh software, however, is distributed under BSD/BSD-compatible licensing.