Latest revision |
Your text |
Line 1: |
Line 1: |
| {{welcome}} | | {{welcome}} |
− | {{Navbar GhostBSD Boot Process}} | + | {{maintenance}} |
− | {{Navbar OpenRC}} | + | {{Navbar System}} |
| | | |
| ==Introduction== | | ==Introduction== |
− | | + | OpenRC is a dependency-based ''init system'' that works with the system-provided init program, normally ''/sbin/init''. Currently, it does not have an init program of its own. It does not function as a replacement for the /sbin/init file. |
− | '''OpenRC''' is a dependency-based ''init system'' that works with the system-provided init program, normally ''/sbin/init''. Currently, it does not have an init program of its own. It does not function as a replacement for the /sbin/init file. OpenRC is located on /sbin/openrc.
| + | |
| | | |
| There are 105 [https://github.com/OpenRC/openrc/graphs/contributors contributors on GitHub]. | | There are 105 [https://github.com/OpenRC/openrc/graphs/contributors contributors on GitHub]. |
| | | |
| GhostBSD/FreeBSD provides for booting from both the older MBR standard and the newer GUID Partition Table (GPT). | | GhostBSD/FreeBSD provides for booting from both the older MBR standard and the newer GUID Partition Table (GPT). |
− | Once the kernel boot process is finished, the kernel passes control to the user process [https://www.freebsd.org/cgi/man.cgi?query=init&sektion=8&manpath=freebsd-release-ports init(8)], which is located at ''/sbin/init''. The '''[[/boot/defaults/loader.conf]]''' states as GhostBSD defaults: ''rc_system="openrc".'' | + | Once the kernel boot process is finished, the kernel passes control to the user process [https://www.freebsd.org/cgi/man.cgi?query=init&sektion=8&manpath=freebsd-release-ports init(8)], which is located at ''/sbin/init''. The ''/boot/defaults/loader.conf'' states as GhostBSD defaults: ''rc_system="openrc".'' |
| | | |
| The loader is the final stage of the three-stage bootstrap process. It is located on the file system, usually as ''/boot/loader.'' | | The loader is the final stage of the three-stage bootstrap process. It is located on the file system, usually as ''/boot/loader.'' |
| | | |
− | The loader will read ''/boot/loader.rc,'' which by default reads in '''[[/boot/defaults/loader.conf]]''' which sets reasonable defaults for variables and reads '''[[/boot/loader.conf]]''' for local changes to those variables. loader.rc then acts on these variables, loading whichever modules and kernel are selected. | + | The loader will read ''/boot/loader.rc,'' which by default reads in ''/boot/defaults/loader.conf'' which sets reasonable defaults for variables and reads ''/boot/loader.conf'' for local changes to those variables. loader.rc then acts on these variables, loading whichever modules and kernel are selected. |
− | | + | |
− | A very useful command to edit rc files is '''[[Sysrc|sysrc]]'''.
| + | |
| | | |
| ==Installation== | | ==Installation== |
Line 51: |
Line 48: |
| | | |
| Source: https://github.com/OpenRC/openrc/blob/master/README.md | | Source: https://github.com/OpenRC/openrc/blob/master/README.md |
− |
| |
− | ===Notes===
| |
− |
| |
− | From [https://github.com/OpenRC/openrc/blob/master/README.md the developers:]<br/>
| |
− |
| |
− | We don't support building a static OpenRC with PAM.
| |
− |
| |
− | You may need to use PROGLDFLAGS=-Wl,-Bstatic on glibc instead of just -static.
| |
− |
| |
− | If you are building OpenRC for a Gentoo Prefix installation, add MKPREFIX=yes.
| |
− |
| |
− | PKG_PREFIX should be set to where packages install to by default.
| |
− |
| |
− | LOCAL_PREFIX should be set to where user maintained packages are. Only set LOCAL_PREFIX if different from PKG_PREFIX.
| |
− |
| |
− | PREFIX should be set when OpenRC is not installed to /.
| |
− |
| |
− | If any of the following files exist then we do not overwrite them<br/>
| |
− |
| |
− | * '''/etc/[[Devd.conf|devd.conf]]'''
| |
− | * '''/etc/[[Rc|rc]]'''
| |
− | * '''/etc/rc.shutdown'''
| |
− | * '''/etc/[[Conf.d|conf.d/*]]'''
| |
− |
| |
− | '''[[Rc|rc]]''' and '''rc.shutdown''' are the hooks from the BSD init into '''[[OpenRC]].'''
| |
− |
| |
− | '''[[Devd.conf|devd.con]]f''' is modified from FreeBSD to call '''/etc/[[Rc.devd|rc.devd]]''' which is a generic hook into '''[[OpenRC]].'''
| |
− |
| |
− | inittab is the same, but for SysVInit as used by most Linux distributions. This can be found in the support folder.
| |
− |
| |
− | Obviously, if you're installing this onto a system that does not use '''[[OpenRC]]''' by default then you may wish to backup the above listed files, remove them and then install so that the OS hooks into '''[[OpenRC]]'''.
| |
− |
| |
− | ==OpenRC Developers Guide==
| |
− |
| |
− |
| |
− |
| |
− | This document is aimed at developers or packagers who write OpenRC service scripts, either for their own projects, or for the packages they maintain. It contains advice, suggestions, tips, tricks, hints, and counsel; cautions, warnings, heads-ups, admonitions, proscriptions, enjoinders, and reprimands.
| |
− |
| |
− | It is intended to prevent common mistakes that are found "in the wild" by pointing out those mistakes and suggesting alternatives. Each good/bad thing that you should/not do has a section devoted to it. We don't consider anything exotic, and assume that you will use start-stop-daemon to manage a fairly typical long-running UNIX process.
| |
− |
| |
− | For more information see: [https://github.com/OpenRC/openrc/blob/master/service-script-guide.md OpenRC Service Script Writing Guide]
| |
− |
| |
− | ==Scripts to run OpenRC==
| |
− |
| |
− | Scripts to run OpenRC are located on '''/etc/[[init.d]]/''' and '''/usr/[[local/etc/init.d]]'''.
| |
| | | |
| ==OpenRC Users Guide== | | ==OpenRC Users Guide== |
Line 139: |
Line 91: |
| ===Runlevels=== | | ===Runlevels=== |
| | | |
− | '''OpenRC''' has a concept of runlevels, similar to what sysvinit historically offered. A runlevel is basically a collection of services that needs to be started. Instead of random numbers they are named, and users can create their own if needed. This allows, for example, to have a default runlevel with "everything" enabled, and a "powersaving" runlevel where some services are disabled.
| + | OpenRC has a concept of runlevels, similar to what sysvinit historically offered. A runlevel is basically a collection of services that needs to be started. Instead of random numbers they are named, and users can create their own if needed. This allows, for example, to have a default runlevel with "everything" enabled, and a "powersaving" runlevel where some services are disabled. |
| | | |
− | The '''[[rc-status]]''' helper will print all currently active runlevels and the state of services in them. | + | The rc-status helper will print all currently active runlevels and the state of services in them: |
| | | |
− | All runlevels are represented as folders in ''/etc/runlevels/'' with symlinks to the actual service scripts.<br/>
| + | <nowiki># rc-status</nowiki> |
− | All services must reside in the '''/etc/[[Init.d|init.d]]''' or '''/usr/[[Local/etc/init.d|local/etc/init.d]]''' directories. They must also conform to the '''OpenRC''' runscript standard.
| + | * Caching service dependencies ... [ ok ] |
| + | * Runlevel: default |
| + | * modules [ started ] |
| + | * lvm [ started ] |
| | | |
− | Calling '''OpenRC''' with an argument (openrc default) will switch to that runlevel; this will start and stop services as needed.
| + | All runlevels are represented as folders in ''/etc/runlevels/'' with symlinks to the actual service scripts. |
| | | |
− | Managing runlevels is usually done through the '''[[rc-update]]''' helper, but could of course be done by hand if desired. e.g. ''rc-update add foo default'' - add foo to the default runlevel '''Note:''' This will not auto-start foo! You'd still have to trigger rc or run the service script by hand. | + | Calling OpenRC with an argument (openrc default) will switch to that runlevel; this will start and stop services as needed. |
| + | |
| + | Managing runlevels is usually done through the ''rc-update helper'', but could of course be done by hand if desired. e.g. ''rc-update add nginx default'' - add nginx to the default runlevel '''Note:''' This will not auto-start nginx! You'd still have to trigger rc or run the service script by hand. |
| | | |
| FIXME: Document stacked runlevels | | FIXME: Document stacked runlevels |
Line 154: |
Line 111: |
| The default startup uses the runlevels ''sysinit'', ''boot'', and ''default'', in that order. Shutdown uses the shutdown runlevel. | | The default startup uses the runlevels ''sysinit'', ''boot'', and ''default'', in that order. Shutdown uses the shutdown runlevel. |
| | | |
− | ===The Magic of [[Conf.d|conf.d]]=== | + | ===The Magic of conf.d=== |
| | | |
− | Most service scripts need default values. It would be fragile to explicitly source some arbitrary files. By convention ''openrc-run'' will source the matching file in '''/etc/[[Conf.d|conf.d]]/''' for any script in '''/etc/[[Init.d|init.d]]/''' | + | Most service scripts need default values. It would be fragile to explicitly source some arbitrary files. By convention ''openrc-run'' will source the matching file in ''/etc/conf.d/'' for any script in ''/etc/init.d/'' |
| | | |
| This allows you to set random startup-related things easily. | | This allows you to set random startup-related things easily. |
Line 177: |
Line 134: |
| It helps with starting daemons, backgrounding, creating PID files and many other convenience functions related to managing daemons. | | It helps with starting daemons, backgrounding, creating PID files and many other convenience functions related to managing daemons. |
| | | |
− | ===/etc/[[Rc.conf|rc.conf]]=== | + | ===/etc/rc.conf=== |
| | | |
− | This file manages the default configuration for [[OpenRC]], and it has examples of per-service-script variables. | + | This file manages the default configuration for OpenRC, and it has examples of per-service-script variables. |
| | | |
| Among these are ''rc_parallel'' (for parallelized startup), ''rc_log'' (logs all boot messages to a file), and a few others. | | Among these are ''rc_parallel'' (for parallelized startup), ''rc_log'' (logs all boot messages to a file), and a few others. |
Line 187: |
Line 144: |
| Setting ''ulimit'' and nice values per service can be done through the ''rc_ulimit'' variable. | | Setting ''ulimit'' and nice values per service can be done through the ''rc_ulimit'' variable. |
| | | |
− | Under Linux, OpenRC can use cgroups for process management as well. Once the kernel is configured appropriately, the ''rc_cgroup_mode'' setting in '''/etc/[[Rc.conf|rc.conf]]''' should be used to control whether ''cgroups'' version one, two, or both are used. The default is to use both if they are available. | + | Under Linux, OpenRC can use cgroups for process management as well. Once the kernel is configured appropriately, the ''rc_cgroup_mode'' setting in ''/etc/rc.conf'' should be used to control whether ''cgroups'' version one, two, or both are used. The default is to use both if they are available. |
| | | |
− | By changing certain settings in the service's ''conf.d'' file limits can be enforced per service. These settings are documented in detail in the default '''/etc/[[Rc.conf|rc.conf]]''' under LINUX CGROUPS RESOURCE MANAGEMENT. | + | By changing certain settings in the service's ''conf.d'' file limits can be enforced per service. These settings are documented in detail in the default ''/etc/rc.conf'' under LINUX CGROUPS RESOURCE MANAGEMENT. |
| | | |
| ===Dealing with Orphaned Processes=== | | ===Dealing with Orphaned Processes=== |
Line 212: |
Line 169: |
| | | |
| | | |
− | ===Additional Directories, Programs and Files related to OpenRC===
| |
− |
| |
− | In this directory we collect files are not described above yet.
| |
− |
| |
− | {|class="wikitable" style="width:96.5%;background:#FFFFFF; border:2px solid #008000;text-align:left;padding: 10px"
| |
− | |-
| |
− | ! scope="col" style="width: 100px;"|'''Directory/Files'''
| |
− | ! scope="col" style="width: 350px;"|'''Description'''
| |
− | |-
| |
− | |/boot/loader.rc||Includes additional commands; Load boot menu; Start the boot menu
| |
− | |-
| |
− | |/boot/loader.rc.local||set 0
| |
− | |-
| |
− | |/etc/devd-openrc||Contains the following files: asus.conf, devmatch-openrc.conf, hyperv.conf, uath.conf, ulpt.conf, and zfs.conf
| |
− | |-
| |
− | |/etc/openrc.shutdown||[https://manpages.debian.org/testing/openrc/openrc-shutdown.8.en.html openrc-shutdown] is the utility that communicates with [https://manpages.debian.org/testing/openrc/openrc-init.8.en.html openrc-init(8)] to bring down the system or instruct openrc-init to re-execute itself.
| |
− | |-
| |
− | |/etc/rc.dynamicdiskless||[https://reviews.freebsd.org/D18578 OpenRC for FreeBSD]
| |
− | |-
| |
− | |/etc/rc.firewall||The [https://www.freebsd.org/cgi/man.cgi?query=rc.firewall&sektion=8 rc.firewall] script is used to configure rules for the kernel based firewall service.
| |
− | |-
| |
− | |/etc/rc.initdiskless||The post-boot initialization of an embedded FreeBSD system is controlled by [https://www.freebsd.org/doc/en_US.ISO8859-1/articles/solid-state/ro-fs.html /etc/rc.initdiskless].
| |
− | |-
| |
− | |/etc/rc.resume|| If drivers can be properly loaded and unloaded, automate this by putting the appropriate commands in /etc/rc.suspend and [https://www.freebsd.org/doc/handbook/acpi-overview.html /etc/rc.resume].
| |
− | |-
| |
− | |/etc/rc.sendmail||The [https://www.freebsd.org/cgi/man.cgi?query=rc.sendmail&sektion=8&n=1 rc.sendmail] script is used by /etc/rc at boot time to start [https://www.freebsd.org/cgi/man.cgi?query=sendmail&sektion=8&apropos=0&manpath=FreeBSD+12.1-RELEASE+and+Ports sendmail(8)]. It is meant to be sendmail(8) specific and not a generic script for all MTAs. It is only called by /etc/rc if the rc.conf(5) mta_start_script variable is set to /etc/rc.sendmail.
| |
| | | |
− | |-
| |
− | |/etc/rc.shutdown||See [https://www.freebsd.org/cgi/man.cgi?query=rc.shutdown&apropos=0&sektion=8&manpath=FreeBSD+12.1-RELEASE+and+Ports&arch=default&format=html#Operation Operation of rc.shutdown]
| |
− | |-
| |
− | |/etc/rc.subr||[https://www.freebsd.org/cgi/man.cgi?query=rc.subr&sektion=8&apropos=0&manpath=FreeBSD+12.1-RELEASE+and+Ports functions used by system shell scripts]
| |
− | |-
| |
− | |/etc/rc.suspend||If drivers can be properly loaded and unloaded, automate this by putting the appropriate commands in [https://www.freebsd.org/doc/handbook/acpi-overview.html /etc/rc.suspend] and /etc/rc.resume.
| |
− | |-
| |
− | |/sbin/openrc-run||[https://manpages.debian.org/testing/openrc/openrc-run.8.en.html openrc-run] is basically an interpreter for shell scripts which provides an easy interface to the often complex system commands and daemons. When a service runs a command it first loads its multiplexed configuration file, then its master configuration file, then /etc/rc.conf and finally the script itself. At this point openrc-run then runs the command given.
| |
− | |}
| |
| | | |
| ==For more Information See== | | ==For more Information See== |