├── .cirrus.yml ├── .clangd ├── .github └── workflows │ ├── ci-alpine-linux.yml │ ├── ci-ubuntu.yml │ └── coverity.yml ├── .gitignore ├── .travis.yml ├── AUTHORS ├── BUSYBOX.md ├── CODE_OF_CONDUCT.md ├── FEATURE-REMOVAL-SCHEDULE.md ├── HISTORY.md ├── LICENSE ├── NEWNET.md ├── NEWS.md ├── README.md ├── STYLE-GUIDE.md ├── TODO ├── agetty-guide.md ├── bash-completion ├── meson.build ├── openrc ├── rc-service ├── rc-status └── rc-update ├── ci ├── cirrus.sh └── travis.sh ├── conf.d ├── adjkerntz ├── agetty ├── bootmisc ├── cgroups ├── consolefont ├── devfs ├── dmesg ├── fsck ├── hostname ├── hwclock ├── ipfw ├── keymaps ├── killprocs ├── localmount ├── meson.build ├── modules ├── moused ├── mtab ├── net-online ├── netmount ├── network ├── powerd ├── rarpd ├── savecore ├── seedrng ├── staticroute ├── swap ├── swclock ├── syscons └── urandom ├── etc ├── devd.conf ├── meson.build ├── rc.conf ├── rc.devd ├── rc.in └── rc.shutdown.in ├── init-guide.md ├── init.d ├── adjkerntz.in ├── agetty.in ├── binfmt.in ├── bootmisc.in ├── cgroups.in ├── consolefont.in ├── devd.in ├── devdb.in ├── devfs.in ├── dmesg.in ├── dumpon.in ├── encswap.in ├── fsck.in ├── hostid.in ├── hostname.in ├── hwclock.in ├── ipfw.in ├── keymaps.in ├── killprocs.in ├── local.in ├── localmount.in ├── loopback.in ├── meson.build ├── mixer.in ├── modules.in ├── mount-ro.in ├── moused.in ├── mtab.in ├── net-online.in ├── netmount.in ├── network.in ├── newsyslog.in ├── nscd.in ├── numlock.in ├── osclock.in ├── pf.in ├── powerd.in ├── procfs.in ├── rarpd.in ├── rc-enabled.in ├── root.in ├── rpcbind.in ├── runsvdir.in ├── s6-svscan.in ├── save-keymaps.in ├── save-termencoding.in ├── savecache.in ├── savecore.in ├── seedrng.in ├── staticroute.in ├── swap-blk.in ├── swap.in ├── swclock.in ├── syscons.in ├── sysctl.in ├── sysfs.in ├── syslogd.in ├── termencoding.in ├── ttys.in ├── urandom.in ├── user.in └── wscons.in ├── local.d ├── README └── meson.build ├── man ├── einfo.3 ├── meson.build ├── meson_man_links.sh ├── openrc-init.8 ├── openrc-run.8 ├── openrc-shutdown.8 ├── openrc.8 ├── rc-service.8 ├── rc-sstat.8 ├── rc-status.8 ├── rc-update.8 ├── rc_config.3 ├── rc_deptree.3 ├── rc_find_pids.3 ├── rc_plugin_hook.3 ├── rc_runlevel.3 ├── rc_service.3 ├── rc_stringlist.3 ├── start-stop-daemon.8 └── supervise-daemon.8 ├── meson.build ├── meson_options.txt ├── runit-guide.md ├── s6-guide.md ├── service-script-guide.md ├── sh ├── binfmt.sh.in ├── cgroup-release-agent.sh.in ├── functions.sh.in ├── gendepends.sh.in ├── init-early.sh.Linux.in ├── init.sh.BSD.in ├── init.sh.GNU-kFreeBSD.in ├── init.sh.GNU.in ├── init.sh.Linux.in ├── meson.build ├── openrc-run.sh.in ├── rc-cgroup.sh ├── rc-functions.sh ├── rc-mount.sh ├── runit.sh ├── s6.sh ├── start-stop-daemon.sh ├── supervise-daemon.sh └── user-init.sh.in ├── src ├── checkpath │ ├── checkpath.c │ └── meson.build ├── einfo │ ├── einfo.c │ └── meson.build ├── fstabinfo │ ├── fstabinfo.c │ └── meson.build ├── halt │ ├── halt.in │ └── meson.build ├── is_newer_than │ ├── is_newer_than.c │ └── meson.build ├── is_older_than │ ├── is_older_than.c │ └── meson.build ├── kill_all │ ├── kill_all.c │ └── meson.build ├── libeinfo │ ├── einfo.h │ ├── einfo.map │ ├── libeinfo.c │ └── meson.build ├── librc │ ├── librc-daemon.c │ ├── librc-depend.c │ ├── librc-misc.c │ ├── librc-stringlist.c │ ├── librc.c │ ├── librc.h │ ├── meson.build │ ├── rc.h.in │ └── rc.map ├── mark_service │ ├── mark_service.c │ └── meson.build ├── meson.build ├── mountinfo │ ├── meson.build │ └── mountinfo.c ├── on_ac_power │ ├── meson.build │ └── on_ac_power ├── openrc-init │ ├── meson.build │ └── openrc-init.c ├── openrc-pam │ ├── meson.build │ └── openrc-pam.c ├── openrc-run │ ├── meson.build │ └── openrc-run.c ├── openrc-shutdown │ ├── broadcast.c │ ├── broadcast.h │ ├── meson.build │ ├── openrc-shutdown.c │ ├── sysvinit.c │ └── sysvinit.h ├── openrc │ ├── meson.build │ ├── rc-logger.c │ ├── rc-logger.h │ └── rc.c ├── poweroff │ ├── meson.build │ └── poweroff.in ├── rc-abort │ ├── meson.build │ └── rc-abort.c ├── rc-depend │ ├── meson.build │ └── rc-depend.c ├── rc-service │ ├── meson.build │ └── rc-service.c ├── rc-sstat │ ├── meson.build │ └── rc-sstat ├── rc-status │ ├── meson.build │ └── rc-status.c ├── rc-update │ ├── meson.build │ └── rc-update.c ├── reboot │ ├── meson.build │ └── reboot.in ├── seedrng │ ├── meson.build │ └── seedrng.c ├── service │ ├── meson.build │ └── service.c ├── shared │ ├── _usage.c │ ├── _usage.h │ ├── helpers.h │ ├── meson.build │ ├── misc.c │ ├── misc.h │ ├── pipes.c │ ├── pipes.h │ ├── plugin.c │ ├── plugin.h │ ├── queue.h │ ├── schedules.c │ ├── schedules.h │ ├── selinux.c │ ├── selinux.h │ ├── version.h.in │ ├── version.in │ ├── wtmp.c │ └── wtmp.h ├── shell_var │ ├── meson.build │ └── shell_var.c ├── shutdown │ ├── meson.build │ └── shutdown.in ├── start-stop-daemon │ ├── meson.build │ ├── start-stop-daemon.c │ └── start-stop-daemon.pam ├── supervise-daemon │ ├── meson.build │ ├── supervise-daemon.c │ └── supervise-daemon.pam ├── swclock │ ├── meson.build │ └── swclock.c ├── user_init │ ├── meson.build │ └── user_init.c └── value │ ├── meson.build │ └── value.c ├── supervise-daemon-guide.md ├── support ├── deptree2dot │ ├── README.md │ ├── deptree2dot │ └── meson.build ├── init.d.examples │ ├── README.md │ ├── avahi-dnsconfd.in │ ├── avahid.in │ ├── dbus.in │ ├── dhcpcd.in │ ├── dnsmasq.in │ ├── hald.in │ ├── meson.build │ ├── named.in │ ├── ntpd.in │ ├── openvpn.in │ ├── polkitd.in │ ├── sshd.in │ └── wpa_supplicant.in ├── meson.build ├── openvpn │ ├── README.md │ ├── down.sh │ ├── meson.build │ └── up.sh ├── sysvinit │ ├── README.md │ ├── halt.sh │ ├── inittab │ └── meson.build └── user.d.examples │ ├── README.md │ ├── dbus.in │ ├── dunst.in │ ├── meson.build │ ├── pipewire-pulse.in │ ├── pipewire.in │ ├── ssh-agent.in │ └── wireplumber.in ├── sysctl.d ├── README └── meson.build ├── test ├── check-obsolete-functions.sh ├── check-spacing-style.sh ├── check-trailing-newlines.sh ├── check-trailing-whitespace.sh ├── check-xfunc-usage.sh ├── meson.build ├── setup_env.sh └── units │ ├── check-is-older-than.sh │ ├── check-sh-yesno.sh │ └── meson.build ├── tools ├── meson_final.sh └── meson_runlevels.sh ├── user-guide.md └── zsh-completion ├── _openrc ├── _rc-service ├── _rc-status ├── _rc-update └── meson.build /.cirrus.yml: -------------------------------------------------------------------------------- 1 | # Cirrus CI integration 2 | # https://cirrus-ci.org 3 | 4 | test_task: 5 | freebsd_instance: 6 | matrix: 7 | image: freebsd-13-2-release-amd64 8 | image: freebsd-13-3-release-amd64 9 | env: 10 | OS: FreeBSD 11 | procfs_script: > 12 | [ -f /proc/curproc ] || mount -t procfs proc /proc 13 | pkg_install_script: pkg install -y bash gawk gsed meson 14 | gsed_hack_script: rm /usr/bin/sed && ln -s /usr/local/bin/gsed /usr/bin/sed 15 | test_script: bash ci/cirrus.sh 16 | -------------------------------------------------------------------------------- /.clangd: -------------------------------------------------------------------------------- 1 | CompileFlags: 2 | CompilationDatabase: builddir/ 3 | -------------------------------------------------------------------------------- /.github/workflows/ci-alpine-linux.yml: -------------------------------------------------------------------------------- 1 | name: ci_alpine_linux 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | 7 | alpine: 8 | name: Alpine Linux 9 | runs-on: ubuntu-latest 10 | container: alpine:latest 11 | strategy: 12 | fail-fast: false 13 | matrix: 14 | compiler: 15 | - gcc 16 | env: 17 | CC: ${{ matrix.compiler }} 18 | steps: 19 | - run: >- 20 | apk --no-cache add \ 21 | build-base \ 22 | meson \ 23 | pkgconf \ 24 | linux-pam \ 25 | linux-pam-dev \ 26 | libcap \ 27 | libcap-dev 28 | - uses: actions/checkout@v2 29 | - run: meson setup builddir/ 30 | - run: meson compile -C builddir 31 | - run: meson test --verbose -C builddir 32 | -------------------------------------------------------------------------------- /.github/workflows/ci-ubuntu.yml: -------------------------------------------------------------------------------- 1 | name: ci_ubuntu 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | 7 | ubuntu: 8 | name: Ubuntu 9 | runs-on: ubuntu-latest 10 | strategy: 11 | fail-fast: false 12 | matrix: 13 | compiler: 14 | - gcc 15 | - clang 16 | env: 17 | CC: ${{ matrix.compiler }} 18 | steps: 19 | - uses: actions/checkout@v2 20 | - run: sudo apt-get update -q 21 | - run: sudo apt-get install -q -y build-essential libpam-dev meson libcap-dev ${CC} 22 | - run: meson setup builddir/ 23 | - run: ninja -C builddir 24 | - run: ninja test --verbose -C builddir 25 | -------------------------------------------------------------------------------- /.github/workflows/coverity.yml: -------------------------------------------------------------------------------- 1 | # GitHub actions workflow. 2 | # https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions 3 | 4 | # https://scan.coverity.com/projects/openrc-openrc 5 | name: Coverity Scan 6 | 7 | on: 8 | push: 9 | branches: [master] 10 | 11 | jobs: 12 | coverity: 13 | runs-on: ubuntu-latest 14 | steps: 15 | - uses: actions/checkout@v2 16 | - run: sudo apt-get update -q 17 | - run: sudo apt-get install -q -y build-essential libpam-dev meson libcap-dev 18 | - run: meson setup builddir/ 19 | env: 20 | CC: gcc 21 | - uses: vapier/coverity-scan-action@v1 22 | with: 23 | command: ninja -C builddir 24 | email: ${{ secrets.COVERITY_SCAN_EMAIL }} 25 | token: ${{ secrets.COVERITY_SCAN_TOKEN }} 26 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.gz 2 | 3 | *.diff 4 | *.patch 5 | *.orig 6 | *.rej 7 | 8 | core 9 | .gdb_history 10 | .gdbinit 11 | 12 | build 13 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | # Travis build integration. 2 | # https://docs.travis-ci.com/ 3 | 4 | language: c 5 | 6 | os: 7 | - linux 8 | 9 | compiler: 10 | - gcc 11 | - clang 12 | - musl-gcc 13 | 14 | addons: 15 | apt: 16 | packages: 17 | - musl-tools 18 | 19 | notifications: 20 | irc: 21 | channels: 22 | - "irc.libera.chat#openrc" 23 | on_success: always # options: [always|never|change] default: always 24 | on_failure: always # options: [always|never|change] default: always 25 | on_start: false # default: false 26 | 27 | before_install: 28 | - sudo apt-get update 29 | - sudo apt-get install -y shellcheck 30 | 31 | script: 32 | - ./ci/travis.sh 33 | -------------------------------------------------------------------------------- /BUSYBOX.md: -------------------------------------------------------------------------------- 1 | Using Busybox as your Default Shell with OpenRC 2 | =============================================== 3 | 4 | If you have/bin/sh linked to busybox, you need to be aware of several 5 | incompatibilities between busybox's applets and the standalone 6 | counterparts. Since it is possible to configure busybox to not include 7 | these applets or to prefer the standalone counterparts, OpenRC does not 8 | attempt to support the busybox applets. 9 | 10 | For now, it is recommended that you disable the following busybox 11 | configuration settings for best results with OpenRC. 12 | 13 | CONFIG_START_STOP_DAEMON -- The start-stop-daemon applet is not compatible with 14 | start-stop-daemon in OpenRC. 15 | 16 | CONFIG_MOUNT -- The mount applet does not support the -O [no]_netdev options to 17 | skip over or include network file systems when the -a option is present. 18 | 19 | CONFIG_UMOUNT -- The umount applet does not support the -O option along with -a. 20 | 21 | CONFIG_SWAPONOFF -- The swapon applet does not support the -e option 22 | or recognize the nofail option in fstab. 23 | 24 | CONFIG_SETFONT -- The setfont applet does not support the -u option from kbd. 25 | 26 | CONFIG_BB_SYSCTL -- The sysctl applet does not support the --system command 27 | line switch. 28 | 29 | There is work to get most of these supported by busybox, so this file 30 | will be updated as things change. 31 | -------------------------------------------------------------------------------- /FEATURE-REMOVAL-SCHEDULE.md: -------------------------------------------------------------------------------- 1 | Features Scheduled for Removal 2 | ============================== 3 | 4 | The following is a list of files and features that are going to be removed in 5 | the source tree. Every entry should contain what exactly is going away, why it 6 | is happening, and who is going to be doing the work. When the feature is 7 | removed, it should also be removed from this file. 8 | 9 | # Service pause action 10 | 11 | When: 1.0 12 | 13 | Why: The same affect can be obtained with the --nodeps option to stop. 14 | 15 | Who: 16 | 17 | # start-stop-daemon options --startas, --chuid , --oknodo 18 | 19 | When: 1.0 20 | 21 | Why: Obsolete or replaced by other options. 22 | 23 | * --startas => use --name or --exec 24 | * --chuid => use --user 25 | * --oknodo => ignore return code instead 26 | 27 | Who: 28 | 29 | # runscript and rc symbolic links 30 | 31 | When: 1.0 32 | 33 | Why: Deprecated in favor of openrc-run and openrc due to naming 34 | conflicts with other software. 35 | 36 | Who: 37 | 38 | # support for the opts variable in service scripts 39 | 40 | When: 1.0 41 | 42 | Why: Deprecated in favor of extra_commands, extra_started_commands 43 | and extra_stopped_commands. 44 | 45 | Who: 46 | 47 | # support for local_start and local_stop 48 | 49 | When: 1.0 50 | 51 | Why: Deprecated in favor of executable scripts in @SYSCONFDIR@/local.d 52 | 53 | Who: 54 | 55 | # the mtab service script 56 | 57 | When: force /etc/mtab to link to /proc/self/mounts in 1.0, remove 58 | service in 2.0 59 | 60 | Why: /etc/mtab should be a symbolic link to /proc/self/mounts on modern 61 | Linux systems 62 | 63 | Who: 64 | 65 | # C API Functions in rc.h 66 | 67 | If you have a c program that links to librc and uses functions from 68 | there, this section will list API functions which are deprecated and 69 | will be removed along with the reason they are being removed. 70 | 71 | ## rc_getline() 72 | 73 | When: 1.0 74 | 75 | Why: The getline() function was standardized in POSIX.1-2008, so it 76 | should be available on POSIX systems. 77 | 78 | Who: 79 | 80 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2007-2008, Roy Marples 2 | Copyright (c) 2007-2023, the OpenRC authors 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | 2. Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | 14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 18 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | POSSIBILITY OF SUCH DAMAGE. 25 | -------------------------------------------------------------------------------- /NEWNET.md: -------------------------------------------------------------------------------- 1 | OpenRC Network Ideals 2 | ===================== 3 | 4 | The new style networking for OpenRC is very simplistic - provide a basic means 5 | of configuring static interface address and routes whilst allowing the 6 | possibility to run any command at any point. 7 | 8 | In a nutshell, init.d/network is a wrapper around ifconfig(8) and 9 | init.d/staticroute is wrapper around route(8). 10 | 11 | In the Perfect World (TM) ifconfig should be able to configure everything 12 | about the interface easily * . The BSD family almost get this right and Linux 13 | epically fails. 14 | 15 | * Only static configuration, including link setup. 16 | For dynamic, static, IPv4LL, arping and per ssid IPv4 setup dhcpcd-5.x 17 | provides your needs. 18 | 19 | It fails because there are many tools to do the same job and often have 20 | vastly different syntax where they could be similar. In other words, there 21 | is no coherence. 22 | 23 | OpenRC-0.4.x and older (inc Gentoo baselayout-1) had a collection of scripts 24 | for each tool and allowed a script per interface. Over the years, this design 25 | has proven very hard to maintain as each user has their own idea of how 26 | things should work. Also, there were (and still are) race conditions. 27 | 28 | So where do we go from here? 29 | Well, it's possible to use the new network scripts using the tools 30 | currently available. It's just harder as you have to know them and their 31 | documentation can be lacking at times. 32 | The correct end goal is a BSD style ifconfig tool. 33 | I've started work on it, but the project has stalled somewhat. 34 | It's display only right now and the source is not yet publicly available. 35 | If you have the skills and share the vision then contact me privately and 36 | we'll take it from there. 37 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | openrc-navi 2 | ============= 3 | 4 | OpenRC is a dependency-based init system that works with the 5 | system-provided init program, normally `/sbin/init`. 6 | 7 | This fork provides extra functionality like user services. 8 | 9 | ## building and installing 10 | 11 | OpenRC uses the [meson](http://mesonbuild.com) build system, so use the 12 | usual methods for this build system to build and install. 13 | 14 | ## Notes 15 | 16 | We don't support building a static OpenRC with PAM. 17 | 18 | `PKG_PREFIX` should be set to where packages install to by default. 19 | 20 | `LOCAL_PREFIX` should be set to where user maintained packages are. 21 | Only set `LOCAL_PREFIX` if different from `PKG_PREFIX`. 22 | 23 | `ROOTPREFIX` should be set when the root path is different from '/'. 24 | 25 | `rc` and `rc.shutdown` are the hooks from the BSD init into OpenRC. 26 | 27 | `devd.conf` is modified from FreeBSD to call `/etc/rc.devd` which is a 28 | generic hook into OpenRC. 29 | 30 | `inittab` is the same, but for SysVInit as used by most Linux distributions. 31 | This can be found in the support folder. 32 | 33 | Obviously, if you're installing this onto a system that does not use 34 | OpenRC by default then you may wish to backup the above listed files, 35 | remove them and then install so that the OS hooks into OpenRC. 36 | 37 | ## Discussions 38 | 39 | We are testing [discussions](https://github.com/navi-desu/openrc/discussions), so 40 | feel free to open topics there. 41 | 42 | ## Reporting Bugs 43 | 44 | Please report bugs on our [bug tracker](http://github.com/navi-desu/openrc/issues). 45 | 46 | If you can contribute code , please feel free to do so by opening 47 | [pull requests](https://github.com/OpenRC/openrc/pulls). 48 | 49 | ## IRC Channel 50 | 51 | We have an official irc channel, #navi on the libera network. 52 | Please connect your irc client to irc.libera.chat and join #navi on 53 | that network. 54 | -------------------------------------------------------------------------------- /TODO: -------------------------------------------------------------------------------- 1 | - ensure all forks block, restore and unblock signals. needs review 2 | 3 | - add support somehow for optional translations 4 | 5 | - oldnet[bridging]: Review setting of bridge configuration on dynamic interface add 6 | 7 | - Document rc-depend binary. 8 | 9 | - _ifindex is not a reliable means of calculating metrics: 10 | _ifindex is used for calculating metrics for new devices but has a major 11 | problem: Since it's only the nth entry in /proc/net/dev 12 | And devices may be removed from that file, and reordered, you won't always 13 | get the same result. 14 | If you do: 15 | - add eth0 - _ifindex (eth0=0) 16 | - add vlan1 - _ifindex (eth0=0,vlan1=1) 17 | - add vlan2 - _ifindex (eth0=0,vlan1=1,vlan2=2) 18 | - rem vlan1 - _ifindex (eth0=0,vlan2=1) 19 | - add vlan3 - _ifindex (eth0=0,vlan2=1,vlan3=2) 20 | Now your routing table has entries for both vlan2 and vlan3 with a metric of 2. 21 | 22 | -------------------------------------------------------------------------------- /agetty-guide.md: -------------------------------------------------------------------------------- 1 | Setting up the agetty service in OpenRC 2 | =================================xxxxxx 3 | 4 | The agetty service is an OpenRC specific way to monitor and respawn a 5 | getty, using agetty, on Linux. To use this method, make sure you aren't 6 | spawning a getty manager for this port some other way (such as through 7 | sysvinit/inittab), then run the following commands as root. 8 | 9 | Note that [port] refers to the port you are spawning the getty on, for 10 | example, tty1 or ttyS0. The full path to it, for example, /dev/tty1 11 | should not be used. 12 | 13 | ``` 14 | # cd /etc/init.d 15 | # ln -s agetty agetty.[port] 16 | # cd /etc/conf.d 17 | # cp agetty agetty.[port] 18 | #rc-update add agetty.[port] [runlevel] 19 | ``` 20 | -------------------------------------------------------------------------------- /bash-completion/meson.build: -------------------------------------------------------------------------------- 1 | if get_option('bash-completions') 2 | bash_completions = [ 3 | 'openrc', 4 | 'rc-service', 5 | 'rc-status', 6 | 'rc-update', 7 | ] 8 | 9 | install_data(bash_completions, 10 | install_dir : get_option('datadir') / 'bash-completion/completions') 11 | endif 12 | -------------------------------------------------------------------------------- /bash-completion/openrc: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2017 The OpenRC Authors. 2 | # See the Authors file at the top-level directory of this distribution and 3 | # https://github.com/OpenRC/openrc/blob/HEAD/AUTHORS 4 | # 5 | # This file is part of OpenRC. It is subject to the license terms in 6 | # the LICENSE file found in the top-level directory of this 7 | # distribution and at https://github.com/OpenRC/openrc/blob/HEAD/LICENSE 8 | # This file may not be copied, modified, propagated, or distributed 9 | # except according to the terms contained in the LICENSE file. 10 | 11 | # 12 | # openrc completion command 13 | # 14 | _openrc() 15 | { 16 | local cur 17 | COMPREPLY=() 18 | cur="${COMP_WORDS[COMP_CWORD]}" 19 | if [[ ${#COMP_WORDS[*]} -le 2 ]]; then 20 | COMPREPLY=($(compgen -W "$(rc-status --list)" -- $cur)) 21 | fi 22 | return 0 23 | } && 24 | complete -F _openrc openrc 25 | -------------------------------------------------------------------------------- /bash-completion/rc-status: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2017 The OpenRC Authors. 2 | # See the Authors file at the top-level directory of this distribution and 3 | # https://github.com/OpenRC/openrc/blob/HEAD/AUTHORS 4 | # 5 | # This file is part of OpenRC. It is subject to the license terms in 6 | # the LICENSE file found in the top-level directory of this 7 | # distribution and at https://github.com/OpenRC/openrc/blob/HEAD/LICENSE 8 | # This file may not be copied, modified, propagated, or distributed 9 | # except according to the terms contained in the LICENSE file. 10 | 11 | # 12 | # rc-status completion command 13 | # 14 | _rcstatus() 15 | { 16 | local cur 17 | cur="${COMP_WORDS[COMP_CWORD]}" 18 | if [[ $COMP_CWORD -eq 1 ]]; then 19 | if [[ "${cur}" == --* ]]; then 20 | COMPREPLY=($(compgen -W '--all --list --unused' -- ${cur})) 21 | elif [[ "${cur}" == -* ]]; then 22 | COMPREPLY=($(compgen -W '-a -l -u' -- ${cur})) 23 | else 24 | COMPREPLY=($(compgen -W "$(rc-status --list)" -- ${cur})) 25 | fi 26 | else 27 | unset COMPREPLY 28 | fi 29 | return 0 30 | } && 31 | complete -F _rcstatus rc-status 32 | -------------------------------------------------------------------------------- /bash-completion/rc-update: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2017 The OpenRC Authors. 2 | # See the Authors file at the top-level directory of this distribution and 3 | # https://github.com/OpenRC/openrc/blob/HEAD/AUTHORS 4 | # 5 | # This file is part of OpenRC. It is subject to the license terms in 6 | # the LICENSE file found in the top-level directory of this 7 | # distribution and at https://github.com/OpenRC/openrc/blob/HEAD/LICENSE 8 | # This file may not be copied, modified, propagated, or distributed 9 | # except according to the terms contained in the LICENSE file. 10 | 11 | # 12 | # rc-update completion command 13 | # 14 | _rc_update() 15 | { 16 | local cur show 17 | COMPREPLY=() 18 | cur="${COMP_WORDS[COMP_CWORD]}" 19 | if [[ $COMP_CWORD -eq 1 ]]; then 20 | if [[ "${cur}" == -* ]]; then 21 | COMPREPLY=($(compgen -W '-a -d -s' -- ${cur})) 22 | else 23 | COMPREPLY=($(compgen -W 'add del show' ${cur})) 24 | fi 25 | else 26 | if [[ "${COMP_WORDS[1]}" == "show" ]] || [[ "${COMP_WORDS[1]}" == "-s" ]]; then 27 | show="TRUE" 28 | fi 29 | if ([[ $COMP_CWORD -eq 3 ]] && [[ -z "$show" ]]) || \ 30 | ([[ $COMP_CWORD -eq 2 ]] && [[ -n "$show" ]]); then 31 | COMPREPLY=($(compgen -W "$(rc-status --list)" -- $cur)) 32 | elif [[ $COMP_CWORD -eq 2 ]]; then 33 | COMPREPLY=($(compgen -W "$(rc-service --list)" $cur)) 34 | elif [[ ${#COMP_WORDS[*]} -gt 2 ]] ; then 35 | COMPREPLY=($(compgen -W "$(rc-status --list)" -- $cur)) 36 | else 37 | unset COMPREPLY 38 | fi 39 | fi 40 | return 0 41 | } && 42 | complete -F _rc_update rc-update 43 | -------------------------------------------------------------------------------- /ci/cirrus.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Copyright (c) 2007-2018 The OpenRC Authors. 3 | # See the Authors file at the top-level directory of this distribution and 4 | # https://github.com/OpenRC/openrc/blob/HEAD/AUTHORS 5 | # 6 | # This file is part of OpenRC. It is subject to the license terms in 7 | # the LICENSE file found in the top-level directory of this 8 | # distribution and at https://github.com/OpenRC/openrc/blob/HEAD/LICENSE 9 | # This file may not be copied, modified, propagated, or distributed 10 | # except according to the terms contained in the LICENSE file. 11 | 12 | set -e 13 | set -u 14 | set -x 15 | 16 | # These are steps to run on Cirrus CI under a jailed FreeBSD system. 17 | # See $TOP/.cirrus.yml for more info about the Cirrus CI setup. 18 | 19 | meson build 20 | meson compile -C build 21 | meson test --verbose -C build 22 | -------------------------------------------------------------------------------- /ci/travis.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Copyright (c) 2007-2018 The OpenRC Authors. 3 | # See the Authors file at the top-level directory of this distribution and 4 | # https://github.com/OpenRC/openrc/blob/HEAD/AUTHORS 5 | # 6 | # This file is part of OpenRC. It is subject to the license terms in 7 | # the LICENSE file found in the top-level directory of this 8 | # distribution and at https://github.com/OpenRC/openrc/blob/HEAD/LICENSE 9 | # This file may not be copied, modified, propagated, or distributed 10 | # except according to the terms contained in the LICENSE file. 11 | 12 | set -e 13 | set -u 14 | set -x 15 | 16 | # These are steps to run on TravisCI under a containerized Ubuntu system. 17 | # See $TOP/.travis.yml for more info about the TravisCI setup. 18 | 19 | # Run shellcheck, but don't fail (yet): 20 | shellcheck --version 21 | for shellscript in $(git ls-files); do 22 | case $shellscript in 23 | init.d/*.in) ;; 24 | sh/*.in) ;; 25 | sh/*.sh) ;; 26 | support/init.d.examples/*.in) ;; 27 | support/openvpn/*.sh) ;; 28 | support/sysvinit/halt.sh) ;; 29 | test/*.sh) ;; 30 | *) continue ;; 31 | esac 32 | echo "Checking ${shellscript} with shellcheck:" 33 | shellcheck -s sh "${shellscript}" || true 34 | done 35 | 36 | cpus=$(getconf _NPROCESSORS_CONF || echo 1) 37 | # make on TravisCI doesn't support -O yet 38 | make -j"${cpus}" 39 | 40 | make test 41 | -------------------------------------------------------------------------------- /conf.d/adjkerntz: -------------------------------------------------------------------------------- 1 | # Set CLOCK to "UTC" if your system clock is set to UTC (also known as 2 | # Greenwich Mean Time). If your clock is set to the local time, then 3 | # set CLOCK to "local". Note that if you dual boot with Windows, then 4 | # you should set it to "local". 5 | clock="UTC" 6 | 7 | # If you want to set the Hardware Clock to the current System Time 8 | # during shutdown, then say "YES" here. 9 | # You normally don't need to do this if you run a ntp daemon. 10 | clock_systohc="NO" 11 | -------------------------------------------------------------------------------- /conf.d/agetty: -------------------------------------------------------------------------------- 1 | # make agetty quiet 2 | #quiet="yes" 3 | 4 | # Set the baud rate of the terminal line 5 | #baud="" 6 | 7 | # set the terminal type 8 | #term_type="linux" 9 | 10 | # extra options to pass to agetty for this port 11 | #agetty_options="" 12 | -------------------------------------------------------------------------------- /conf.d/bootmisc: -------------------------------------------------------------------------------- 1 | # List of /tmp directories we should clean up 2 | clean_tmp_dirs="/tmp" 3 | 4 | # Should we wipe the tmp paths completely or just selectively remove known 5 | # locks / files / etc... ? 6 | wipe_tmp="YES" 7 | 8 | # Write the initial dmesg log into /var/log/dmesg after boot 9 | # This may be useful if you need the kernel boot log afterwards 10 | log_dmesg="YES" 11 | 12 | # Save the previous dmesg log to dmesg.old 13 | # This may be useful if you need to compare the current boot to the 14 | # previous one. 15 | #previous_dmesg=no 16 | -------------------------------------------------------------------------------- /conf.d/cgroups: -------------------------------------------------------------------------------- 1 | # override cgroup mount options 2 | #cgroup_opts=nodev,noexec,nosuid 3 | -------------------------------------------------------------------------------- /conf.d/consolefont: -------------------------------------------------------------------------------- 1 | # The consolefont service is not activated by default. If you need to 2 | # use it, you should run "rc-update add consolefont boot" as root. 3 | # 4 | # consolefont specifies the default font that you'd like Linux to use on the 5 | # console. You can find a good selection of fonts in /usr/share/consolefonts; 6 | # you shouldn't specify the trailing ".psf.gz", just the font name below. 7 | # To use the default console font, comment out the CONSOLEFONT setting below. 8 | consolefont="default8x16" 9 | 10 | # consoletranslation is the charset map file to use. Leave commented to use 11 | # the default one. Have a look in /usr/share/consoletrans for a selection of 12 | # map files you can use. 13 | #consoletranslation="8859-1_to_uni" 14 | 15 | # unicodemap is the unicode map file to use. Leave commented to use the 16 | # default one. Have a look in /usr/share/unimaps for a selection of map files 17 | # you can use. 18 | #unicodemap="iso01" 19 | -------------------------------------------------------------------------------- /conf.d/devfs: -------------------------------------------------------------------------------- 1 | # OpenRC will attempt each of the following in succession to mount /dev. 2 | # 3 | # 1. If there is an entry for /dev in fstab, it will be used. 4 | # 2. If devtmpfs is defined in the kernel, it will be used. 5 | # 3. If tmpfs is defined in the kernel, it will be used. 6 | # 7 | # Set this to yes if you do not want OpenRC to attempt to mount /dev. 8 | # skip_mount_dev="NO" 9 | -------------------------------------------------------------------------------- /conf.d/dmesg: -------------------------------------------------------------------------------- 1 | # Sets the level at which logging of messages is done to the 2 | # console. See dmesg(1) for more info. 3 | dmesg_level="1" 4 | -------------------------------------------------------------------------------- /conf.d/fsck: -------------------------------------------------------------------------------- 1 | # Pass any arguments to fsck. 2 | # By default we preen. 3 | # Linux systems also force -C0 and -T. 4 | # If fsck_args is not specified then Linux systems also use -A 5 | # (and -R if / is rw) 6 | #fsck_args="-p" 7 | 8 | # We can also specify the passno in /etc/fstab to check 9 | # If you multiplex fsck (ie ln -s fsck /etc/init.d/fsck.late) then you can 10 | # do an fsck outside of the normal scope, say for /home. 11 | # Here are some examples:- 12 | #fsck_passno="=1 =2" 13 | #fsck_passno=">1" 14 | #fsck_passno="<2" 15 | 16 | # If passno is not enough granularity, you can also specify mountpoints to 17 | # check. This should NOT be used for the default non-multiplexed fsck, or your 18 | # system might not be checked. Additionally, it is mutually exclusive with 19 | # the fsck_passno setting. 20 | #fsck_mnt="" 21 | #fsck_mnt="/home" 22 | 23 | # Most modern fs's don't require a full fsck on boot, but for those that do 24 | # it may be advisable to skip this when running on battery. 25 | # WARNING: Do not turn this off if you have any JFS partitions. 26 | fsck_on_battery="YES" 27 | 28 | # fsck_shutdown causes fsck to trigger during shutdown as well as startup. 29 | # The end result of this is that if any periodic non-root filesystem checks are 30 | # scheduled, under normal circumstances the actual check will happen during 31 | # shutdown rather than at next boot. 32 | # This is useful when periodic filesystem checks are causing undesirable 33 | # delays at startup, but such delays at shutdown are acceptable. 34 | fsck_shutdown="NO" 35 | 36 | # fsck_abort_on_errors can be set to no to cause fsck to not abort on 37 | # errors. 38 | # This is useful when periodic filesystem checks are causing undesirable 39 | # aborts. 40 | fsck_abort_on_errors="YES" 41 | -------------------------------------------------------------------------------- /conf.d/hostname: -------------------------------------------------------------------------------- 1 | # Hostname fallback if /etc/hostname does not exist 2 | hostname="localhost" 3 | -------------------------------------------------------------------------------- /conf.d/hwclock: -------------------------------------------------------------------------------- 1 | # Set CLOCK to "UTC" if your Hardware Clock is set to UTC (also known as 2 | # Greenwich Mean Time). If that clock is set to the local time, then 3 | # set CLOCK to "local". Note that if you dual boot with Windows, then 4 | # you should set it to "local". 5 | clock="UTC" 6 | 7 | # If you want the hwclock script to set the system time (software clock) 8 | # to match the current hardware clock during bootup, leave this 9 | # commented out. 10 | # However, you can set this to "NO" if you are running a modern kernel 11 | # and using NTP to synchronize your system clock. 12 | #clock_hctosys="YES" 13 | 14 | # If you do not want to set the hardware clock to the current system 15 | # time (software clock) during shutdown, set this to no. 16 | #clock_systohc="YES" 17 | 18 | # If you wish to pass any other arguments to hwclock during bootup, 19 | # you may do so here. Alpha users may wish to use --arc or --srm here. 20 | clock_args="" 21 | -------------------------------------------------------------------------------- /conf.d/ipfw: -------------------------------------------------------------------------------- 1 | # ipfw provides a stateful firewall. 2 | # This means we allow everything out, and if we have a connection we allow it 3 | # back in. This is very flexible and quite secure. 4 | 5 | # For ease of use, we allow auth and ssh ports through as well. 6 | # To override the list of allowed ports 7 | #ipfw_ports_in="auth ssh" 8 | 9 | # You may want to enable logging of denied connections 10 | #ipfw_log_deny="YES" 11 | 12 | # This ports not logged 13 | #ipfw_ports_nolog="135-139,445 1026,1027 1433,1434" 14 | 15 | -------------------------------------------------------------------------------- /conf.d/keymaps: -------------------------------------------------------------------------------- 1 | # Use keymap to specify the default console keymap. There is a complete tree 2 | # of keymaps in /usr/share/keymaps to choose from. 3 | keymap="us" 4 | 5 | # Should we first load the 'windowkeys' console keymap? Most x86 users will 6 | # say "yes" here. Note that non-x86 users should leave it as "no". 7 | # Loading this keymap will enable VT switching (like ALT+Left/Right) 8 | # using the special windows keys on the linux console. 9 | windowkeys="NO" 10 | 11 | # The maps to load for extended keyboards. Most users will leave this as is. 12 | extended_keymaps="" 13 | #extended_keymaps="backspace keypad euro2" 14 | 15 | # Tell dumpkeys(1) to interpret character action codes to be 16 | # from the specified character set. 17 | # This only matters if you set unicode="yes" in /etc/rc.conf. 18 | # For a list of valid sets, run `dumpkeys --help` 19 | dumpkeys_charset="" 20 | 21 | # Some fonts map AltGr-E to the currency symbol instead of the Euro. 22 | # To fix this, set to "yes" 23 | fix_euro="NO" 24 | -------------------------------------------------------------------------------- /conf.d/killprocs: -------------------------------------------------------------------------------- 1 | # If you wish to pass any options to kill_all during shutdown, 2 | # you should do so here. 3 | # 4 | # The setting is called killall5_opts because the options here are meant 5 | # to be identical to those you could pass to killall5. 6 | killall5_opts="" 7 | 8 | # If you need to delay after each kill attempt during shutdown, set the amount 9 | # of time you need to delay here. This gets passed directly to sleep in 10 | # the shell. 11 | # kill_delay=0 12 | -------------------------------------------------------------------------------- /conf.d/localmount: -------------------------------------------------------------------------------- 1 | # Stop the unmounting of certain points. 2 | # This could be useful for some NFS related work. 3 | #no_umounts="/dir1:/var/dir2" 4 | # 5 | # Mark certain mount points as critical. 6 | # This contains a space separated list of mount points which should be 7 | # considered critical. If one of these mount points cannot be mounted, 8 | # localmount will fail. 9 | # By default, this is empty. 10 | #critical_mounts="/home /var" 11 | -------------------------------------------------------------------------------- /conf.d/meson.build: -------------------------------------------------------------------------------- 1 | conf_d_dir = get_option('sysconfdir') / 'conf.d' 2 | 3 | conf_common = [ 4 | 'bootmisc', 5 | 'fsck', 6 | 'hostname', 7 | 'localmount', 8 | 'netmount', 9 | 'swap', 10 | 'swclock', 11 | ] 12 | 13 | conf_net = [ 14 | 'network', 15 | 'staticroute', 16 | ] 17 | 18 | conf_FreeBSD = [ 19 | 'ipfw', 20 | 'modules', 21 | 'moused', 22 | 'powerd', 23 | 'rarpd', 24 | 'savecore', 25 | 'syscons', 26 | 'urandom', 27 | ] 28 | 29 | conf_Linux = [ 30 | 'agetty', 31 | 'consolefont', 32 | 'devfs', 33 | 'dmesg', 34 | 'hwclock', 35 | 'keymaps', 36 | 'killprocs', 37 | 'modules', 38 | 'mtab', 39 | 'net-online', 40 | 'seedrng', 41 | ] 42 | 43 | conf_NetBSD = [ 44 | 'moused', 45 | 'rarpd', 46 | 'savecore', 47 | 'urandom', 48 | ] 49 | 50 | conf_data = conf_common 51 | if get_option('newnet') 52 | conf_data = conf_data + conf_net 53 | endif 54 | if os == 'FreeBSD' 55 | conf_data = conf_data + conf_FreeBSD 56 | elif os == 'Linux' 57 | conf_data = conf_data + conf_Linux 58 | elif os == 'NetBSD' 59 | conf_data = conf_data + conf_NetBSD 60 | endif 61 | 62 | install_data(conf_data, install_dir : conf_d_dir) 63 | -------------------------------------------------------------------------------- /conf.d/modules: -------------------------------------------------------------------------------- 1 | # Linux users can define a list of modules for a specific kernel version, 2 | # a released kernel version, a main kernel version or all kernel versions. 3 | # The most specific versioned variable will take precedence. 4 | # FreeBSD users can only use the modules="foo bar" setting. 5 | #modules_2_6_23_gentoo_r5="ieee1394 ohci1394" 6 | #modules_2_6_23="tun ieee1394" 7 | #modules_2_6="tun" 8 | #modules_2="ipv6" 9 | #modules="ohci1394" 10 | 11 | # Linux users can give the modules some arguments if needed, per version 12 | # if necessary. 13 | # Again, the most specific versioned variable will take precedence. 14 | # This is not supported on FreeBSD. 15 | #module_ieee1394_args="debug" 16 | #module_ieee1394_args_2_6_23_gentoo_r5="debug2" 17 | #module_ieee1394_args_2_6_23="debug3" 18 | #module_ieee1394_args_2_6="debug4" 19 | #module_ieee1394_args_2="debug5" 20 | 21 | # You should consult your kernel documentation and configuration 22 | # for a list of modules and their options. 23 | -------------------------------------------------------------------------------- /conf.d/moused: -------------------------------------------------------------------------------- 1 | # See the moused man page for available settings. 2 | 3 | # Set to your mouse device psm[0-9] for PS/2 ports, ums[0-9] for USB ports 4 | # Leave blank to try to autodetect it 5 | #moused_device="/dev/psm0" 6 | 7 | # Any additional arguments required for a specific port 8 | #moused_args_psm0="" 9 | # or for all mice 10 | #moused_args="" 11 | 12 | # You can also multiplex the init script for each device like so 13 | # ln -s moused /etc/init.d/moused.ums0 14 | # This enables you to have a config file per mouse (forces moused_device 15 | # to ums0 in this case) and control each mouse. 16 | # devd can also start and stop these mice, which laptop users will find handy. 17 | -------------------------------------------------------------------------------- /conf.d/mtab: -------------------------------------------------------------------------------- 1 | # As far as we are aware, there are no modern linux tools or use cases 2 | # which require /etc/mtab to be a separate file from /proc/self/mounts, 3 | # so this setting should be commented out. 4 | # If it is set to yes, please comment it out and run this command: 5 | # # rc-service mtab restart 6 | # In the future, the mtab service will be removed since we are not aware 7 | # of any need to manipulate /etc/mtab as a separate file from 8 | # /proc/self/mounts. 9 | # If you have a technical reason we should keep this support, please 10 | # open an issue at https://github.com/openrc/openrc/issues and let us 11 | # know about your situation. 12 | # This setting controls whether /etc/mtab is a file or symbolic link. 13 | # mtab_is_file=no 14 | -------------------------------------------------------------------------------- /conf.d/net-online: -------------------------------------------------------------------------------- 1 | # The interfaces setting controls which interfaces the net-online 2 | # service considers in deciding whether the network is active. The 3 | # default is all interfaces that support ethernet. 4 | #interfaces="" 5 | 6 | # This setting controls whether a ping test is included in the test for 7 | # network connectivity after all interfaces are active. 8 | #include_ping_test=no 9 | 10 | # This setting is the host to attempt to ping if the above is yes. 11 | # The default is google.com. 12 | #ping_test_host=some.host.name 13 | 14 | # The timeout setting controls how long the net-online service waits 15 | # for the network to be configured. 16 | # The default is 120 seconds. 17 | # if this is set to 0, the wait is infinite. 18 | #timeout=120 19 | -------------------------------------------------------------------------------- /conf.d/netmount: -------------------------------------------------------------------------------- 1 | # You will need to set the dependencies in the netmount script to match 2 | # the network configuration tools you are using. This should be done in 3 | # this file by following the examples below, and not by changing the 4 | # service script itself. 5 | # 6 | # Each of these examples is meant to be used separately. So, for 7 | # example, do not set rc_need to something like "net.eth0 dhcpcd". 8 | # 9 | # If you are using newnet and configuring your interfaces with static 10 | # addresses with the network script, you should use this setting. 11 | # 12 | #rc_need="network" 13 | # 14 | # If you are using oldnet, you must list the specific net.* services you 15 | # need. 16 | # 17 | # This example assumes all of your netmounts can be reached on 18 | # eth0. 19 | # 20 | #rc_need="net.eth0" 21 | # 22 | # This example assumes some of your netmounts are on eth1 and some 23 | # are on eth2. 24 | # 25 | #rc_need="net.eth1 net.eth2" 26 | # 27 | # If you are using a dynamic network management tool like 28 | # NetworkManager, dhcpcd in standalone mode, wicd, badvpn-ncd, etc, to 29 | # manage the network interfaces with the routes to your netmounts, you 30 | # should list that tool. 31 | # 32 | #rc_need="NetworkManager" 33 | #rc_need="dhcpcd" 34 | #rc_need="wicd" 35 | # 36 | # The default setting is designed to be backward compatible with our 37 | # current setup, but you are highly discouraged from using this. In 38 | # other words, please change it to be more suited to your system. 39 | # 40 | rc_need="net" 41 | # 42 | # Mark certain mount points as critical. 43 | # This contains aspace separated list of mount points which should be 44 | # considered critical. If one of these mount points cannot be mounted, 45 | # netmount will fail. 46 | # By default, this is empty. 47 | #critical_mounts="/home /var" 48 | -------------------------------------------------------------------------------- /conf.d/powerd: -------------------------------------------------------------------------------- 1 | # Mode allowed: maximum, minimum, adaptive 2 | # Default unless specified is adaptive 3 | powerd_ac_mode="maximum" 4 | #powerd_battery_mode="minimum" 5 | 6 | # Additional arguments for powerd - see the man page for details 7 | powerd_args="" 8 | -------------------------------------------------------------------------------- /conf.d/rarpd: -------------------------------------------------------------------------------- 1 | # To start rarpd only for a given interface, set the 2 | # following variable. Otherwise we listen on all interfaces. 3 | #rarpd_interface="rl0" 4 | -------------------------------------------------------------------------------- /conf.d/savecore: -------------------------------------------------------------------------------- 1 | # Unless you're a kernel developer or driver writer then this won't 2 | # be of any interest to you at all. 3 | # The following options allow to configure the kernel's core dump 4 | # facilities. 5 | 6 | # The dump_device variable is used to specify which device will be 7 | # used by the kernel to write the dump down. This has to be a swap 8 | # partition, and has to be at least big enough to contain the whole 9 | # physical memory (see hw.physmem sysctl(8) variable). 10 | # When the variable is commented out, no core dump will be enabled for 11 | # the kernel. 12 | #dump_device=/dev/ad0s1b 13 | 14 | # The dump_dir variable is used to tell savecore(8) utility where 15 | # to save the kernel core dump once it's restored from the dump 16 | # device. If unset, /var/crash will be used, as the default of 17 | # FreeBSD. 18 | #dump_dir=/var/crash 19 | 20 | # The dump_compress variable decide whether to compress with 21 | # gzip(1) the dump or leave it of its original size (the size of the 22 | # physical memory present on the system). If set to yes, the -z option 23 | # will be passed to savecore(8) that will proceed on compressing the 24 | # dump. 25 | #dump_compress=NO 26 | -------------------------------------------------------------------------------- /conf.d/seedrng: -------------------------------------------------------------------------------- 1 | # The convention in this file is to show the default settings commented out. 2 | # 3 | # Sometimes you want to have urandom start before "localmount" (say for crypt 4 | # swap), so you will need to customize this behavior. If you have /var on a 5 | # separate partition, make sure paths under /var are adjusted to point to 6 | # locations on your root device. 7 | # 8 | # Set skip_credit to yes or true if you do not want seed files to actually 9 | # credit the random number generator. For example, you should set this if you 10 | # plan to replicate the file system image without removing the contents of 11 | # ${seed_dir}. 12 | # 13 | # seed_dir=/var/lib/seedrng 14 | # skip_credit=no 15 | -------------------------------------------------------------------------------- /conf.d/staticroute: -------------------------------------------------------------------------------- 1 | # Static routes are defined differently depending on your operating 2 | # system, so please be sure to use the correct syntax. 3 | # Do not use this file to define the default route. 4 | # In all settings, multiple routes should be separated using ; or new lines. 5 | 6 | # Define static routes on Linux using route. See route(8) for syntax. 7 | #staticroute="net 192.168.0.0 netmask 255.255.255.0 gw 10.73.1.1 8 | #net 192.168.1.0 netmask 255.255.255.0 gw 10.73.1.1" 9 | 10 | # Define static routes on Linux using iproute2. See ip(8) for syntax. 11 | #staticiproute="192.168.0.0/24 via 10.73.1.1; 192.168.1.0/24 via 10.73.1.1" 12 | 13 | # Define static routes on GNU/Hurd. See route(8) for syntax. 14 | # /etc/route.conf(5) takes precedence over this configuration. 15 | # FIXME: "net ..." not supported 16 | #staticroute="net 192.168.0.0 -netmask 255.255.255.0 --address 10.73.1.1 17 | #net 192.168.1.0 -netmask 255.255.255.0 --address 10.73.1.1" 18 | 19 | # Define static routes on GNU/KFreeBSD. See route(8) for syntax. 20 | #staticroute="net 192.168.0.0 10.73.1.1 netmask 255.255.255.0 21 | #net 192.168.1.0 10.73.1.1 netmask 255.255.255.0" 22 | 23 | # Define static routes on other BSD systems. See route(8) for syntax. 24 | # /etc/route.conf(5) takes precedence over this configuration. 25 | #staticroute="net 192.168.0.0 -netmask 255.255.255.0 10.73.1.1 26 | #net 192.168.1.0 -netmask 255.255.255.0 10.73.1.1" 27 | -------------------------------------------------------------------------------- /conf.d/swap: -------------------------------------------------------------------------------- 1 | # If you are only using local swap partitions, you should not change 2 | # this file. Otherwise, you need to uncomment the below rc_before line 3 | # followed by the appropriate rc_need line. 4 | #rc_before="!localmount" 5 | # 6 | # If you are using swap files stored on local file systems, uncomment 7 | # this line. 8 | #rc_need="localmount" 9 | # 10 | # If you are using swap files stored on network file systems or swap 11 | # partitions stored on network block devices such as iSCSI, uncomment 12 | # this line. 13 | #rc_need="netmount" 14 | -------------------------------------------------------------------------------- /conf.d/swclock: -------------------------------------------------------------------------------- 1 | # This is the location of the reference file swclock uses to set the 2 | # system date and time. 3 | # This is the default path. If you are using it, you do not need to 4 | # uncomment it. If you are using the default and have /var on its own 5 | # file system, you need to add the appropriate rc_after setting. 6 | # swclock_file=/var/lib/misc/openrc-shutdowntime 7 | -------------------------------------------------------------------------------- /conf.d/syscons: -------------------------------------------------------------------------------- 1 | # Example syscons config file. This is the place to set things like keymap, etc. 2 | 3 | # Set the video mode - you should check the vidcontrol man page for valid modes 4 | # NOTE:- This will blank the screen after this command is run 5 | # NOTE:- You can get more modes if you load the vesa kernel module, but this 6 | # may require the SC_PIXEL_MODE kernel option 7 | #allscreen_flags="VGA_80x30" 8 | 9 | # Set the keymap to "uk.iso". 10 | #keymap="uk.iso" 11 | 12 | # Set the keyboard rate to 250ms delay, and 34 repeat rate. 13 | #keyrate="250.34" 14 | 15 | # Change the behaviour of F-unction keys (see kbdcontrol(1)). 16 | #keychange="10 'ssh myhost'" 17 | 18 | # See vidcontrol(1) -t 19 | #blanktime="off" 20 | -------------------------------------------------------------------------------- /conf.d/urandom: -------------------------------------------------------------------------------- 1 | # Sometimes you want to have urandom start before "localmount" 2 | # (say for crypt swap), so you will need to customize this 3 | # behavior. If you have /var on a separate partition, then 4 | # make sure this path lives on your root device somewhere. 5 | urandom_seed="/var/lib/misc/random-seed" 6 | -------------------------------------------------------------------------------- /etc/meson.build: -------------------------------------------------------------------------------- 1 | etc_conf_data = configuration_data() 2 | if os == 'FreeBSD' 3 | etc_conf_data.set('TERM', 'cons25') 4 | elif os == 'Linux' 5 | etc_conf_data.set('TERM', 'wsvt25') 6 | endif 7 | 8 | etc_conf_common = [ 9 | 'rc.conf', 10 | ] 11 | 12 | etc_bin_FreeBSD = [ 13 | 'rc.devd', 14 | ] 15 | 16 | etc_conf_FreeBSD = [ 17 | 'devd.conf', 18 | ] 19 | 20 | etc_bin_NetBSD = [ 21 | 'rc.in', 22 | 'rc.shutdown.in', 23 | ] 24 | 25 | install_data(etc_conf_common, 26 | install_dir : get_option('sysconfdir')) 27 | 28 | if os == 'FreeBSD' 29 | install_data(etc_bin_FreeBSD, 30 | install_dir : get_option('sysconfdir'), 31 | install_mode: 'rwxr-xr-x') 32 | install_data(etc_conf_FreeBSD, 33 | install_dir : get_option('sysconfdir')) 34 | endif 35 | 36 | if os == 'FreeBSD' or os == 'NetBSD' 37 | foreach file : etc_bin_NetBSD 38 | configure_file(input : file, 39 | output : '@BASENAME@', 40 | configuration : etc_conf_data, 41 | install_dir: get_option('sysconfdir'), 42 | install_mode: 'rwxr-xr-x') 43 | endforeach 44 | endif 45 | -------------------------------------------------------------------------------- /etc/rc.devd: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Copyright (c) 2007-2015 The OpenRC Authors. 3 | # See the Authors file at the top-level directory of this distribution and 4 | # https://github.com/OpenRC/openrc/blob/HEAD/AUTHORS 5 | # 6 | # This file is part of OpenRC. It is subject to the license terms in 7 | # the LICENSE file found in the top-level directory of this 8 | # distribution and at https://github.com/OpenRC/openrc/blob/HEAD/LICENSE 9 | # This file may not be copied, modified, propagated, or distributed 10 | # except according to the terms contained in the LICENSE file. 11 | 12 | # Inform RC that we are in the background and hotplugged 13 | IN_BACKGROUND=yes 14 | IN_HOTPLUG=yes 15 | export IN_BACKGROUND IN_HOTPLUG 16 | 17 | getmedia() { 18 | ifconfig "$1" | while read line; do 19 | case "${line}" in 20 | media:" "*) echo "${line}"; return;; 21 | esac 22 | done 23 | } 24 | 25 | # Try and create an init script for network interfaces 26 | if [ ! -e /etc/init.d/"$1" -a ! -e /usr/local/init.d/"$1" ]; then 27 | base=${1%%.*} 28 | if [ "${base}" = "net" ]; then 29 | # We only create links for physical interfaces 30 | [ -n "$(getmedia ${1#*.})" ] || exit 1 31 | base="net.lo0" 32 | fi 33 | if [ -e /etc/init.d/"${base}" -a "${base}" != "$1" ]; then 34 | ln -s "${base}" /etc/init.d/"$1" 35 | fi 36 | fi 37 | 38 | # Run the init script 39 | exec /etc/init.d/"$1" "$2" 40 | -------------------------------------------------------------------------------- /etc/rc.in: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Copyright (c) 2007-2015 The OpenRC Authors. 3 | # See the Authors file at the top-level directory of this distribution and 4 | # https://github.com/OpenRC/openrc/blob/HEAD/AUTHORS 5 | # 6 | # This file is part of OpenRC. It is subject to the license terms in 7 | # the LICENSE file found in the top-level directory of this 8 | # distribution and at https://github.com/OpenRC/openrc/blob/HEAD/LICENSE 9 | # This file may not be copied, modified, propagated, or distributed 10 | # except according to the terms contained in the LICENSE file. 11 | 12 | # If $TERM is not set then assume default of @TERM@ 13 | # This gives us a nice colour boot :) 14 | [ -z "$TERM" -o "$TERM" = "dumb" ] && TERM="@TERM@" && export TERM 15 | 16 | # Handle interrupts 17 | trap : SIGINT 18 | trap "echo 'Boot interrupted'; exit 1" SIGQUIT 19 | 20 | /sbin/openrc sysinit || exit 1 21 | /sbin/openrc boot || exit 1 22 | /sbin/openrc default 23 | 24 | # We don't actually care if rc default worked or not, we should exit 0 25 | # to allow logins 26 | exit 0 27 | -------------------------------------------------------------------------------- /etc/rc.shutdown.in: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Copyright (c) 2007-2015 The OpenRC Authors. 3 | # See the Authors file at the top-level directory of this distribution and 4 | # https://github.com/OpenRC/openrc/blob/HEAD/AUTHORS 5 | # 6 | # This file is part of OpenRC. It is subject to the license terms in 7 | # the LICENSE file found in the top-level directory of this 8 | # distribution and at https://github.com/OpenRC/openrc/blob/HEAD/LICENSE 9 | # This file may not be copied, modified, propagated, or distributed 10 | # except according to the terms contained in the LICENSE file. 11 | 12 | # Handle interrupts 13 | trap : SIGINT SIGQUIT 14 | 15 | # Try and use stuff in /lib over anywhere else so we can shutdown 16 | # local mounts correctly. 17 | LD_LIBRARY_PATH="/lib${LD_LIBRARY_PATH:+:}${LD_LIBRARY_PATH}" ; export LD_LIBRARY_PATH 18 | 19 | # If $TERM is not set then assume default of @TERM@ 20 | # This gives us a nice colour boot :) 21 | [ -z "$TERM" -o "$TERM" = "dumb" ] && TERM="@TERM@" && export TERM 22 | 23 | action=${1:-shutdown} 24 | exec /sbin/openrc "${action}" 25 | -------------------------------------------------------------------------------- /init-guide.md: -------------------------------------------------------------------------------- 1 | # OpenRC init process guide 2 | 3 | OpenRC now includes an init process which can be used on Linux systems 4 | in place of sysvinit. 5 | 6 | ## migrating a live system to openrc-init 7 | 8 | Configuring a live system to use this init process is very 9 | straight-forward, but the steps must be completed in this order. 10 | 11 | * have your boot loader add "init=/sbin/openrc-init" to the kernel command line 12 | 13 | The details of how to do this will vary from distro to distro, so they are 14 | out of scope for this document. 15 | 16 | * Install gettys into the runlevels where you need them. 17 | 18 | If you are using the provided /etc/init.d/agetty script,, you should 19 | first create symlinks in /etc/init.d to it for the ports where you 20 | want gettys to run, e.g. the following will work if you want gettys on 21 | tty1-tty6. 22 | 23 | ``` 24 | # cd /etc/init.d 25 | # for x in tty1 tty2 tty3 tty4 tty5 tty6; do 26 | ln -snf agetty agetty.$x 27 | done 28 | ``` 29 | 30 | Once this is done, use ```rc-update``` as normal to install the agetty 31 | services in the appropriate runlevels. 32 | 33 | * Reboot your system. 34 | 35 | At this point you are running under openrc-init, and you should use 36 | openrc-shutdown to handle shutting down, powering off, rebooting etc. 37 | 38 | ## optional sysvinit compatibility 39 | 40 | If you build and install OpenRC with MKSYSVINIT=yes, you will build and install 41 | wrappers that make openrc-init compatible with sysvinit -- you will have 42 | commands like "halt" "shutdown" "reboot" and "poweroff". 43 | 44 | If you want this functionality on a live system, you should first 45 | migrate the system to openrc-init, remove sysvinit, then rebuild and 46 | install this package with MKSYSVINIT=yes. 47 | 48 | -------------------------------------------------------------------------------- /init.d/adjkerntz.in: -------------------------------------------------------------------------------- 1 | #!@SBINDIR@/openrc-run 2 | # Copyright (c) 2007-2015 The OpenRC Authors. 3 | # See the Authors file at the top-level directory of this distribution and 4 | # https://github.com/OpenRC/openrc/blob/HEAD/AUTHORS 5 | # 6 | # This file is part of OpenRC. It is subject to the license terms in 7 | # the LICENSE file found in the top-level directory of this 8 | # distribution and at https://github.com/OpenRC/openrc/blob/HEAD/LICENSE 9 | # This file may not be copied, modified, propagated, or distributed 10 | # except according to the terms contained in the LICENSE file. 11 | 12 | extra_commands="save" 13 | 14 | description="Sets the local clock to UTC or Local Time." 15 | description_save="Saves the current time in the BIOS." 16 | 17 | : ${clock:=${CLOCK:-UTC}} 18 | if [ "$clock" = "UTC" ]; then 19 | utc="UTC" 20 | else 21 | utc="Local Time" 22 | fi 23 | 24 | depend() 25 | { 26 | after swclock 27 | provide clock 28 | # BSD adjkerntz needs to be able to write to /etc 29 | if [ "$clock" = "UTC" -a -e /etc/wall_cmos_clock ] || 30 | [ "$clock" != "UTC" -a ! -e /etc/wall_cmos_clock ]; then 31 | need root 32 | fi 33 | keyword -jail -prefix 34 | } 35 | 36 | start() 37 | { 38 | ebegin "Starting the System Clock Adjuster [${utc}]" 39 | if [ "$clock" != "UTC" ]; then 40 | echo >/etc/wall_cmos_clock 41 | start-stop-daemon --start --exec /sbin/adjkerntz -- -i 42 | else 43 | rm -f /etc/wall_cmos_clock 44 | /sbin/adjkerntz -i 45 | fi 46 | eend $? 47 | } 48 | 49 | save() 50 | { 51 | ebegin "Setting hardware clock using the system clock [${utc}]" 52 | adjkerntz -a 53 | eend $? 54 | } 55 | 56 | stop() 57 | { 58 | # Don't tweak the hardware clock on LiveCD halt. 59 | if yesno "${clock_systohc:-$CLOCK_SYSTOHC}"; then 60 | [ -z "$CDBOOT" ] && save 61 | fi 62 | 63 | ebegin "Stopping the System Clock Adjuster" 64 | if start-stop-daemon --test --quiet --stop --exec /sbin/adjkerntz; then 65 | start-stop-daemon --stop --exec /sbin/adjkerntz 66 | eend $? 67 | else 68 | eend 0 69 | fi 70 | } 71 | -------------------------------------------------------------------------------- /init.d/agetty.in: -------------------------------------------------------------------------------- 1 | #!@SBINDIR@/openrc-run 2 | # Copyright (c) 2017 The OpenRC Authors. 3 | # See the Authors file at the top-level directory of this distribution and 4 | # https://github.com/OpenRC/openrc/blob/HEAD/AUTHORS 5 | # 6 | # This file is part of OpenRC. It is subject to the license terms in 7 | # the LICENSE file found in the top-level directory of this 8 | # distribution and at https://github.com/OpenRC/openrc/blob/HEAD/LICENSE 9 | # This file may not be copied, modified, propagated, or distributed 10 | # except according to the terms contained in the LICENSE file. 11 | 12 | description="start agetty on a terminal line" 13 | supervisor=supervise-daemon 14 | port="${RC_SVCNAME#*.}" 15 | respawn_period="${respawn_period:-60}" 16 | term_type="${term_type:-linux}" 17 | command=/sbin/agetty 18 | command_args_foreground="${agetty_options} ${port} ${baud} ${term_type}" 19 | pidfile="/run/${RC_SVCNAME}.pid" 20 | 21 | depend() { 22 | after local 23 | keyword -prefix 24 | provide getty 25 | } 26 | 27 | start_pre() { 28 | if [ "$port" = "$RC_SVCNAME" ]; then 29 | eerror "${RC_SVCNAME} cannot be started directly. You must create" 30 | eerror "symbolic links to it for the ports you want to start" 31 | eerror "agetty on and add those to the appropriate runlevels." 32 | return 1 33 | else 34 | export EINFO_QUIET="${quiet:-yes}" 35 | fi 36 | } 37 | 38 | stop_pre() 39 | { 40 | export EINFO_QUIET="${quiet:-yes}" 41 | } 42 | -------------------------------------------------------------------------------- /init.d/binfmt.in: -------------------------------------------------------------------------------- 1 | #!@SBINDIR@/openrc-run 2 | # Copyright (c) 2015 The OpenRC Authors. 3 | # See the Authors file at the top-level directory of this distribution and 4 | # https://github.com/OpenRC/openrc/blob/HEAD/AUTHORS 5 | # 6 | # This file is part of OpenRC. It is subject to the license terms in 7 | # the LICENSE file found in the top-level directory of this 8 | # distribution and at https://github.com/OpenRC/openrc/blob/HEAD/LICENSE 9 | # This file may not be copied, modified, propagated, or distributed 10 | # except according to the terms contained in the LICENSE file. 11 | 12 | description="Register misc binary format handlers" 13 | 14 | depend() 15 | { 16 | after clock procfs 17 | use modules devfs 18 | keyword -docker -podman -lxc -openvz -prefix -systemd-nspawn -vserver 19 | } 20 | 21 | start() 22 | { 23 | ebegin "Loading custom binary format handlers" 24 | "$RC_LIBEXECDIR"/sh/binfmt.sh 25 | eend $? 26 | return 0 27 | } 28 | -------------------------------------------------------------------------------- /init.d/consolefont.in: -------------------------------------------------------------------------------- 1 | #!@SBINDIR@/openrc-run 2 | # Copyright (c) 2007-2015 The OpenRC Authors. 3 | # See the Authors file at the top-level directory of this distribution and 4 | # https://github.com/OpenRC/openrc/blob/HEAD/AUTHORS 5 | # 6 | # This file is part of OpenRC. It is subject to the license terms in 7 | # the LICENSE file found in the top-level directory of this 8 | # distribution and at https://github.com/OpenRC/openrc/blob/HEAD/LICENSE 9 | # This file may not be copied, modified, propagated, or distributed 10 | # except according to the terms contained in the LICENSE file. 11 | 12 | description="Sets a font for the consoles." 13 | 14 | depend() 15 | { 16 | need termencoding 17 | after hotplug bootmisc modules 18 | keyword -docker -podman -lxc -openvz -prefix -systemd-nspawn -uml -vserver -xenu 19 | } 20 | 21 | start() 22 | { 23 | ttyn=${rc_tty_number:-${RC_TTY_NUMBER:-12}} 24 | consolefont=${consolefont:-${CONSOLEFONT}} 25 | unicodemap=${unicodemap:-${UNICODEMAP}} 26 | consoletranslation=${consoletranslation:-${CONSOLETRANSLATION}} 27 | 28 | if [ -z "$consolefont" ]; then 29 | ebegin "Using the default console font" 30 | eend 0 31 | return 0 32 | fi 33 | 34 | if [ "$ttyn" = 0 ]; then 35 | ebegin "Skipping font setup (rc_tty_number == 0)" 36 | eend 0 37 | return 0 38 | fi 39 | 40 | local x= param= sf_param= retval=0 ttydev=/dev/tty 41 | 42 | # Get additional parameters 43 | if [ -n "$consoletranslation" ]; then 44 | param="$param -m $consoletranslation" 45 | fi 46 | if [ -n "${unicodemap}" ]; then 47 | param="$param -u $unicodemap" 48 | fi 49 | 50 | # Set the console font 51 | ebegin "Setting console font [$consolefont]" 52 | [ -d /dev/vc ] && ttydev=/dev/vc/ 53 | x=1 54 | while [ $x -le $ttyn ]; do 55 | if ! setfont $consolefont $param -C $ttydev$x >/dev/null; then 56 | retval=1 57 | break 58 | fi 59 | : $(( x += 1 )) 60 | done 61 | eend $retval 62 | 63 | # Store the font so we can use it ASAP on boot 64 | if [ $retval -eq 0 ] && checkpath -W "$RC_LIBEXECDIR"; then 65 | mkdir -p "$RC_LIBEXECDIR"/console 66 | setfont -O "$RC_LIBEXECDIR"/console/font 67 | fi 68 | 69 | return $retval 70 | } 71 | -------------------------------------------------------------------------------- /init.d/devd.in: -------------------------------------------------------------------------------- 1 | #!@SBINDIR@/openrc-run 2 | # Copyright (c) 2007-2015 The OpenRC Authors. 3 | # See the Authors file at the top-level directory of this distribution and 4 | # https://github.com/OpenRC/openrc/blob/HEAD/AUTHORS 5 | # 6 | # This file is part of OpenRC. It is subject to the license terms in 7 | # the LICENSE file found in the top-level directory of this 8 | # distribution and at https://github.com/OpenRC/openrc/blob/HEAD/LICENSE 9 | # This file may not be copied, modified, propagated, or distributed 10 | # except according to the terms contained in the LICENSE file. 11 | 12 | command=/sbin/devd 13 | command_args=$devd_args 14 | name="Device State Change Daemon" 15 | 16 | depend() { 17 | need localmount 18 | after bootmisc 19 | before net.lo0 20 | keyword -jail -prefix 21 | } 22 | 23 | start_pre() { 24 | sysctl hw.bus.devctl_disable=0 >/dev/null 25 | } 26 | 27 | stop_post() { 28 | sysctl hw.bus.devctl_disable=1 >/dev/null 29 | } 30 | -------------------------------------------------------------------------------- /init.d/devdb.in: -------------------------------------------------------------------------------- 1 | #!@SBINDIR@/openrc-run 2 | # Copyright (c) 2008-2015 The OpenRC Authors. 3 | # See the Authors file at the top-level directory of this distribution and 4 | # https://github.com/OpenRC/openrc/blob/HEAD/AUTHORS 5 | # 6 | # This file is part of OpenRC. It is subject to the license terms in 7 | # the LICENSE file found in the top-level directory of this 8 | # distribution and at https://github.com/OpenRC/openrc/blob/HEAD/LICENSE 9 | # This file may not be copied, modified, propagated, or distributed 10 | # except according to the terms contained in the LICENSE file. 11 | 12 | description="Creates the dev database" 13 | 14 | depend() 15 | { 16 | after clock 17 | need localmount 18 | } 19 | 20 | start() 21 | { 22 | ebegin "Building the dev database" 23 | if [ /var/run/dev.db -nt /dev ]; then 24 | : 25 | else 26 | dev_mkdb 27 | fi 28 | eend $? 29 | } 30 | -------------------------------------------------------------------------------- /init.d/dmesg.in: -------------------------------------------------------------------------------- 1 | #!@SBINDIR@/openrc-run 2 | # Copyright (c) 2007-2015 The OpenRC Authors. 3 | # See the Authors file at the top-level directory of this distribution and 4 | # https://github.com/OpenRC/openrc/blob/HEAD/AUTHORS 5 | # 6 | # This file is part of OpenRC. It is subject to the license terms in 7 | # the LICENSE file found in the top-level directory of this 8 | # distribution and at https://github.com/OpenRC/openrc/blob/HEAD/LICENSE 9 | # This file may not be copied, modified, propagated, or distributed 10 | # except according to the terms contained in the LICENSE file. 11 | 12 | description="Set the dmesg level for a cleaner boot" 13 | 14 | depend() 15 | { 16 | before dev modules 17 | keyword -docker -podman -lxc -prefix -systemd-nspawn -vserver 18 | } 19 | 20 | start() 21 | { 22 | if [ -n "$dmesg_level" ]; then 23 | dmesg -n$dmesg_level 24 | fi 25 | } 26 | -------------------------------------------------------------------------------- /init.d/dumpon.in: -------------------------------------------------------------------------------- 1 | #!@SBINDIR@/openrc-run 2 | # Copyright (c) 2007-2015 The OpenRC Authors. 3 | # See the Authors file at the top-level directory of this distribution and 4 | # https://github.com/OpenRC/openrc/blob/HEAD/AUTHORS 5 | # 6 | # This file is part of OpenRC. It is subject to the license terms in 7 | # the LICENSE file found in the top-level directory of this 8 | # distribution and at https://github.com/OpenRC/openrc/blob/HEAD/LICENSE 9 | # This file may not be copied, modified, propagated, or distributed 10 | # except according to the terms contained in the LICENSE file. 11 | 12 | description="Configures a specific kernel dump device." 13 | 14 | depend() { 15 | after clock 16 | need swap 17 | keyword -jail -prefix 18 | } 19 | 20 | start() { 21 | # Setup any user requested dump device 22 | if [ -n "$dump_device" ]; then 23 | ebegin "Activating kernel core dump device ($dump_device)" 24 | dumpon ${dump_device} 25 | eend $? 26 | fi 27 | } 28 | 29 | stop() { 30 | ebegin "Deactivating kernel core dump device" 31 | dumpon off 32 | eend $? 33 | } 34 | -------------------------------------------------------------------------------- /init.d/encswap.in: -------------------------------------------------------------------------------- 1 | #!@SBINDIR@/openrc-run 2 | # Copyright 1992-2012 FreeBSD Project 3 | # Released under the 2-clause BSD license 4 | 5 | depend() { 6 | before swap 7 | } 8 | 9 | start() { 10 | while read device mountpoint type options rest ; do 11 | case ":${device}:${type}:${options}" in 12 | :#*) 13 | ;; 14 | *.bde:swap:sw) 15 | passphrase=$(dd if=/dev/random count=1 2>/dev/null | md5 -q) 16 | device="${device%.bde}" 17 | gbde init "${device}" -P "${passphrase}" || return 1 18 | gbde attach "${device}" -p "${passphrase}" || return 1 19 | ;; 20 | *.eli:swap:sw) 21 | device="${device%.eli}" 22 | geli onetime ${geli_swap_flags} "${device}" || return 1 23 | ;; 24 | esac 25 | done < /etc/fstab 26 | } 27 | 28 | stop() { 29 | while read device mountpoint type options rest ; do 30 | case ":${device}:${type}:${options}" in 31 | :#*) 32 | ;; 33 | *.bde:swap:sw) 34 | device="${device%.bde}" 35 | gbde detach "${device}" 36 | ;; 37 | *.eli:swap:sw) 38 | # Nothing here, because geli swap devices should be 39 | # created with the auto-detach-on-last-close option. 40 | ;; 41 | esac 42 | done < /etc/fstab 43 | } 44 | -------------------------------------------------------------------------------- /init.d/hostid.in: -------------------------------------------------------------------------------- 1 | #!@SBINDIR@/openrc-run 2 | # Copyright (c) 2007-2015 The OpenRC Authors. 3 | # See the Authors file at the top-level directory of this distribution and 4 | # https://github.com/OpenRC/openrc/blob/HEAD/AUTHORS 5 | # 6 | # This file is part of OpenRC. It is subject to the license terms in 7 | # the LICENSE file found in the top-level directory of this 8 | # distribution and at https://github.com/OpenRC/openrc/blob/HEAD/LICENSE 9 | # This file may not be copied, modified, propagated, or distributed 10 | # except according to the terms contained in the LICENSE file. 11 | 12 | extra_commands="reset" 13 | : ${hostid_file:=/etc/hostid} 14 | 15 | depend() 16 | { 17 | use root 18 | after clock 19 | before devd net 20 | keyword -jail -prefix 21 | } 22 | 23 | _set() 24 | { 25 | local id=0 26 | 27 | if [ -n "$1" ]; then 28 | id=$(echo "$1" | md5) 29 | id="0x${id%????????????????????????}" 30 | fi 31 | ebegin "Setting Host ID: $id" 32 | sysctl -w kern.hostid="$id" >/dev/null 33 | eend $? || return 1 34 | 35 | if sysctl -n kern.hostuuid >/dev/null 2>&1; then 36 | [ -n "$1" ] && id=$1 37 | ebegin "Setting Host UUID: $id" 38 | sysctl kern.hostuuid="$id" >/dev/null 39 | eend $? || return 1 40 | fi 41 | 42 | } 43 | 44 | # First we check to see if there is a system UUID 45 | # If so then we use that and erase the hostid file, 46 | # otherwise we generate a random UUID. 47 | reset() 48 | { 49 | local uuid= x="[0-9a-f]" y="$x$x$x$x" 50 | 51 | if command -v kenv >/dev/null 2>&1; then 52 | uuid=$(kenv smbios.system.uuid 2>/dev/null) 53 | fi 54 | case "$uuid" in 55 | $y$y-$y-$y-$y-$y$y$y);; 56 | *) uuid=;; 57 | esac 58 | 59 | if [ -n "$uuid" ]; then 60 | rm -f "$hostid_file" 61 | else 62 | uuid=$(uuidgen) 63 | if [ -z "$uuid" ]; then 64 | eerror "Unable to generate a UUID" 65 | return 1 66 | fi 67 | if ! echo "$uuid" >"$hostid_file"; then 68 | eerror "Failed to store UUID in \`$hostid_file'" 69 | return 1 70 | fi 71 | fi 72 | 73 | _set "$uuid" 74 | } 75 | 76 | start() 77 | { 78 | if [ -r "$hostid_file" ]; then 79 | _set $(cat "$hostid_file") 80 | else 81 | reset 82 | fi 83 | } 84 | 85 | stop() 86 | { 87 | _set 88 | } 89 | -------------------------------------------------------------------------------- /init.d/hostname.in: -------------------------------------------------------------------------------- 1 | #!@SBINDIR@/openrc-run 2 | # Copyright (c) 2007-2015 The OpenRC Authors. 3 | # See the Authors file at the top-level directory of this distribution and 4 | # https://github.com/OpenRC/openrc/blob/HEAD/AUTHORS 5 | # 6 | # This file is part of OpenRC. It is subject to the license terms in 7 | # the LICENSE file found in the top-level directory of this 8 | # distribution and at https://github.com/OpenRC/openrc/blob/HEAD/LICENSE 9 | # This file may not be copied, modified, propagated, or distributed 10 | # except according to the terms contained in the LICENSE file. 11 | 12 | description="Sets the hostname of the machine." 13 | 14 | depend() 15 | { 16 | after clock 17 | keyword -docker -podman -lxc -prefix -systemd-nspawn 18 | } 19 | 20 | start() 21 | { 22 | local h source 23 | if read -r h _ 2> /dev/null < @SYSCONFDIR@/hostname; then 24 | source="@SYSCONFDIR@/hostname" 25 | elif [ -n "${hostname}" ]; then 26 | h=${hostname} 27 | source="@SYSCONFDIR@/conf.d/${RC_SVCNAME}" 28 | fi 29 | if [ -z "$h" ]; then 30 | einfo "Using default system hostname" 31 | return 0 32 | fi 33 | ebegin "Setting hostname to $h from $source" 34 | hostname "$h" 35 | eend $? "Failed to set the hostname" 36 | } 37 | -------------------------------------------------------------------------------- /init.d/killprocs.in: -------------------------------------------------------------------------------- 1 | #!@SBINDIR@/openrc-run 2 | # Copyright (c) 2007-2015 The OpenRC Authors. 3 | # See the Authors file at the top-level directory of this distribution and 4 | # https://github.com/OpenRC/openrc/blob/HEAD/AUTHORS 5 | # 6 | # This file is part of OpenRC. It is subject to the license terms in 7 | # the LICENSE file found in the top-level directory of this 8 | # distribution and at https://github.com/OpenRC/openrc/blob/HEAD/LICENSE 9 | # This file may not be copied, modified, propagated, or distributed 10 | # except according to the terms contained in the LICENSE file. 11 | 12 | description="Kill all processes so we can unmount disks cleanly." 13 | 14 | depend() 15 | { 16 | keyword -prefix 17 | } 18 | 19 | start() 20 | { 21 | ebegin "Terminating remaining processes" 22 | kill_all 15 ${killall5_opts} 23 | sleep ${kill_delay:-0} 24 | eend 0 25 | ebegin "Killing remaining processes" 26 | sleep ${kill_delay:-0} 27 | kill_all 9 ${killall5_opts} 28 | eend 0 29 | } 30 | -------------------------------------------------------------------------------- /init.d/loopback.in: -------------------------------------------------------------------------------- 1 | #!@SBINDIR@/openrc-run 2 | # Copyright (c) 2013-2015 The OpenRC Authors. 3 | # See the Authors file at the top-level directory of this distribution and 4 | # https://github.com/OpenRC/openrc/blob/HEAD/AUTHORS 5 | # 6 | # This file is part of OpenRC. It is subject to the license terms in 7 | # the LICENSE file found in the top-level directory of this 8 | # distribution and at https://github.com/OpenRC/openrc/blob/HEAD/LICENSE 9 | # This file may not be copied, modified, propagated, or distributed 10 | # except according to the terms contained in the LICENSE file. 11 | 12 | description="Configures the loopback interface." 13 | 14 | depend() 15 | { 16 | after clock 17 | keyword -jail -prefix -systemd-nspawn -vserver 18 | } 19 | 20 | start() 21 | { 22 | if [ "$RC_UNAME" = Linux ]; then 23 | ebegin "Bringing up network interface lo" 24 | if command -v ip > /dev/null 2>&1; then 25 | ip addr add 127.0.0.1/8 dev lo brd + 26 | ip link set lo up 27 | else 28 | ifconfig lo 127.0.0.1 netmask 255.0.0.0 29 | fi 30 | else 31 | ebegin "Bringing up network interface lo0" 32 | ifconfig lo0 127.0.0.1 netmask 255.0.0.0 33 | fi 34 | eend $? 35 | } 36 | -------------------------------------------------------------------------------- /init.d/mixer.in: -------------------------------------------------------------------------------- 1 | #!@SBINDIR@/openrc-run 2 | # Copyright (c) 2007-2015 The OpenRC Authors. 3 | # See the Authors file at the top-level directory of this distribution and 4 | # https://github.com/OpenRC/openrc/blob/HEAD/AUTHORS 5 | # 6 | # This file is part of OpenRC. It is subject to the license terms in 7 | # the LICENSE file found in the top-level directory of this 8 | # distribution and at https://github.com/OpenRC/openrc/blob/HEAD/LICENSE 9 | # This file may not be copied, modified, propagated, or distributed 10 | # except according to the terms contained in the LICENSE file. 11 | 12 | extra_commands="restore" 13 | 14 | depend() 15 | { 16 | need localmount 17 | keyword -jail -prefix 18 | } 19 | 20 | restore() 21 | { 22 | local mixer= retval=0 23 | ebegin "Restoring mixer settings" 24 | eindent 25 | for mixer in /dev/mixer*; do 26 | if [ -r "/var/db/${mixer#/dev/}-state" ]; then 27 | vebegin "$mixer" 28 | mixer -f "$mixer" \ 29 | $(cat "/var/db/${mixer#/dev/}-state") >/dev/null 30 | veend $? 31 | : $(( retval += $? )) 32 | fi 33 | done 34 | } 35 | 36 | start() 37 | { 38 | restore 39 | } 40 | 41 | stop() 42 | { 43 | local mixer= retval=0 44 | ebegin "Saving mixer settings" 45 | eindent 46 | for mixer in /dev/mixer*; do 47 | vebegin "$mixer" 48 | mixer -f "$mixer" -s >/var/db/"${mixer#/dev/}"-state 49 | veend $? 50 | : $(( retval += $? )) 51 | done 52 | eoutdent 53 | eend $retval 54 | } 55 | -------------------------------------------------------------------------------- /init.d/mount-ro.in: -------------------------------------------------------------------------------- 1 | #!@SBINDIR@/openrc-run 2 | # Copyright (c) 2007-2015 The OpenRC Authors. 3 | # See the Authors file at the top-level directory of this distribution and 4 | # https://github.com/OpenRC/openrc/blob/HEAD/AUTHORS 5 | # 6 | # This file is part of OpenRC. It is subject to the license terms in 7 | # the LICENSE file found in the top-level directory of this 8 | # distribution and at https://github.com/OpenRC/openrc/blob/HEAD/LICENSE 9 | # This file may not be copied, modified, propagated, or distributed 10 | # except according to the terms contained in the LICENSE file. 11 | 12 | description="Re-mount filesystems read-only for a clean reboot." 13 | 14 | depend() 15 | { 16 | after killprocs savecache 17 | keyword -docker -podman -lxc -openvz -prefix -systemd-nspawn -vserver 18 | } 19 | 20 | start() 21 | { 22 | local ret=0 23 | 24 | # Flush all pending disk writes now 25 | sync 26 | 27 | ebegin "Remounting remaining filesystems read-only" 28 | # We need the do_unmount function 29 | . "$RC_LIBEXECDIR"/sh/rc-mount.sh 30 | eindent 31 | 32 | # Bug 381783 33 | local rc_svcdir=$(echo $RC_SVCDIR | sed 's:/lib\(32\|64\)\?/:/lib(32|64)?/:g') 34 | 35 | local m="/dev|/dev/.*|/proc|/proc.*|/sys|/sys/.*|/run|${rc_svcdir}" x= fs= 36 | m="$m|/bin|/sbin|/lib(32|64)?|/libexec" 37 | if [ -e "$rc_svcdir"/usr_premounted ]; then 38 | m="$m|/usr" 39 | fi 40 | # RC_NO_UMOUNTS is an env var that can be set by plugins 41 | local IFS="$IFS:" 42 | for x in $no_umounts $RC_NO_UMOUNTS; do 43 | m="$m|$x" 44 | done 45 | m="^($m)$" 46 | fs= 47 | for x in $net_fs_list $extra_net_fs_list; do 48 | fs="$fs${fs:+|}$x" 49 | done 50 | [ -n "$fs" ] && fs="^($fs)$" 51 | do_unmount "umount -r" \ 52 | --skip-point-regex "$m" \ 53 | "${fs:+--skip-fstype-regex}" $fs --nonetdev 54 | ret=$? 55 | 56 | eoutdent 57 | 58 | eend $ret 59 | } 60 | -------------------------------------------------------------------------------- /init.d/moused.in: -------------------------------------------------------------------------------- 1 | #!@SBINDIR@/openrc-run 2 | # Copyright (c) 2007-2015 The OpenRC Authors. 3 | # See the Authors file at the top-level directory of this distribution and 4 | # https://github.com/OpenRC/openrc/blob/HEAD/AUTHORS 5 | # 6 | # This file is part of OpenRC. It is subject to the license terms in 7 | # the LICENSE file found in the top-level directory of this 8 | # distribution and at https://github.com/OpenRC/openrc/blob/HEAD/LICENSE 9 | # This file may not be copied, modified, propagated, or distributed 10 | # except according to the terms contained in the LICENSE file. 11 | 12 | mouse=${RC_SVCNAME##*.} 13 | if [ -n "$mouse" -a "$mouse" != "moused" ]; then 14 | moused_device=/dev/"$mouse" 15 | pidfile=/var/run/moused-"$mouse".pid 16 | else 17 | pidfile=/var/run/moused.pid 18 | fi 19 | name="Console Mouse Daemon" 20 | [ -n "$moused_device" ] && name="$name ($moused_device)" 21 | 22 | depend() 23 | { 24 | need localmount 25 | after bootmisc 26 | keyword -jail -prefix 27 | } 28 | 29 | start() 30 | { 31 | ebegin "Starting $name" 32 | 33 | if [ -z "$moused_device" ]; then 34 | local dev= 35 | for dev in /dev/psm[0-9]* /dev/ums[0-9]*; do 36 | [ -c "$dev" ] || continue 37 | [ -e /var/run/moused-"${dev##*/}".pid ] && continue 38 | moused_device=$dev 39 | eindent 40 | einfo "Using mouse on $moused_device" 41 | eoutdent 42 | break 43 | done 44 | fi 45 | 46 | if [ -z "$moused_device" ]; then 47 | eend 1 "No mouse device found" 48 | return 1 49 | fi 50 | 51 | local args= 52 | eval args=\$moused_args_${moused_device##*/} 53 | [ -z "$args" ] && args=$moused_args 54 | 55 | start-stop-daemon --start --exec /usr/sbin/moused \ 56 | --pidfile "$pidfile" \ 57 | -- $args -p "$moused_device" -I "$pidfile" 58 | local retval=$? 59 | 60 | if [ $retval = 0 ]; then 61 | local ttyv= 62 | for ttyv in /dev/ttyv*; do 63 | vidcontrol < "$ttyv" -m on 64 | : $(( retval += $? )) 65 | done 66 | fi 67 | 68 | eend $retval "Failed to start moused" 69 | } 70 | -------------------------------------------------------------------------------- /init.d/mtab.in: -------------------------------------------------------------------------------- 1 | #!@SBINDIR@/openrc-run 2 | # Copyright (c) 2007-2015 The OpenRC Authors. 3 | # See the Authors file at the top-level directory of this distribution and 4 | # https://github.com/OpenRC/openrc/blob/HEAD/AUTHORS 5 | # 6 | # This file is part of OpenRC. It is subject to the license terms in 7 | # the LICENSE file found in the top-level directory of this 8 | # distribution and at https://github.com/OpenRC/openrc/blob/HEAD/LICENSE 9 | # This file may not be copied, modified, propagated, or distributed 10 | # except according to the terms contained in the LICENSE file. 11 | 12 | description="Update /etc/mtab to match what the kernel knows about" 13 | 14 | depend() 15 | { 16 | after clock 17 | before localmount 18 | need root 19 | keyword -prefix -systemd-nspawn 20 | } 21 | 22 | start() 23 | { 24 | local rc=0 25 | ebegin "Updating /etc/mtab" 26 | if ! checkpath -W /etc; then 27 | rc=1 28 | elif ! yesno ${mtab_is_file:-no}; then 29 | [ ! -L /etc/mtab ] && [ -f /etc/mtab ] && 30 | ewarn "Removing /etc/mtab file" 31 | einfo "Creating mtab symbolic link" 32 | ln -snf /proc/self/mounts /etc/mtab 33 | else 34 | ewarn "The ${RC_SVCNAME} service will be removed in the future." 35 | ewarn "Please change the mtab_is_file setting to no and run" 36 | ewarn "# rc-service mtab restart" 37 | ewarn "to create the mtab symbolic link." 38 | [ -L /etc/mtab ] && ewarn "Removing /etc/mtab symbolic link" 39 | rm -f /etc/mtab 40 | einfo "Creating mtab file" 41 | # With / as tmpfs we cannot umount -at tmpfs in localmount as that 42 | # makes / readonly and dismounts all tmpfs even if in use which is 43 | # not good. Luckily, umount uses /etc/mtab instead of /proc/mounts 44 | # which allows this hack to work. 45 | grep -v "^[! ]* / tmpfs " /proc/mounts > /etc/mtab 46 | 47 | # Remove stale backups 48 | rm -f /etc/mtab~ /etc/mtab~~ 49 | fi 50 | eend $rc "/etc is not writable; unable to create /etc/mtab" 51 | return 0 52 | } 53 | -------------------------------------------------------------------------------- /init.d/newsyslog.in: -------------------------------------------------------------------------------- 1 | #!@SBINDIR@/openrc-run 2 | # Copyright (c) 2007-2015 The OpenRC Authors. 3 | # See the Authors file at the top-level directory of this distribution and 4 | # https://github.com/OpenRC/openrc/blob/HEAD/AUTHORS 5 | # 6 | # This file is part of OpenRC. It is subject to the license terms in 7 | # the LICENSE file found in the top-level directory of this 8 | # distribution and at https://github.com/OpenRC/openrc/blob/HEAD/LICENSE 9 | # This file may not be copied, modified, propagated, or distributed 10 | # except according to the terms contained in the LICENSE file. 11 | 12 | required_files="/etc/newsyslog.conf" 13 | 14 | depend() 15 | { 16 | after clock 17 | need localmount 18 | keyword -prefix 19 | } 20 | 21 | start() 22 | { 23 | ebegin "Creating and/or trimming log files" 24 | newsyslog -s $newsyslog_args 25 | eend $? 26 | } 27 | -------------------------------------------------------------------------------- /init.d/nscd.in: -------------------------------------------------------------------------------- 1 | #!@SBINDIR@/openrc-run 2 | # Copyright (c) 2007-2015 The OpenRC Authors. 3 | # See the Authors file at the top-level directory of this distribution and 4 | # https://github.com/OpenRC/openrc/blob/HEAD/AUTHORS 5 | # 6 | # This file is part of OpenRC. It is subject to the license terms in 7 | # the LICENSE file found in the top-level directory of this 8 | # distribution and at https://github.com/OpenRC/openrc/blob/HEAD/LICENSE 9 | # This file may not be copied, modified, propagated, or distributed 10 | # except according to the terms contained in the LICENSE file. 11 | 12 | command=/usr/sbin/nscd 13 | command_args=$nscd_args 14 | pidfile=/var/run/nscd.pid 15 | name="Name Service Cache Daemon" 16 | 17 | extra_started_commands="flush" 18 | 19 | depend() { 20 | need localmount 21 | use net dns ldap ypbind 22 | after bootmisc 23 | } 24 | 25 | flush() { 26 | ebegin "Flushing $name" 27 | nscd -I all >/dev/null 28 | eend $? 29 | } 30 | -------------------------------------------------------------------------------- /init.d/numlock.in: -------------------------------------------------------------------------------- 1 | #!@SBINDIR@/openrc-run 2 | # Copyright (c) 2007-2015 The OpenRC Authors. 3 | # See the Authors file at the top-level directory of this distribution and 4 | # https://github.com/OpenRC/openrc/blob/HEAD/AUTHORS 5 | # 6 | # This file is part of OpenRC. It is subject to the license terms in 7 | # the LICENSE file found in the top-level directory of this 8 | # distribution and at https://github.com/OpenRC/openrc/blob/HEAD/LICENSE 9 | # This file may not be copied, modified, propagated, or distributed 10 | # except according to the terms contained in the LICENSE file. 11 | 12 | description="Turns numlock on for the consoles." 13 | 14 | ttyn=${rc_tty_number:-${RC_TTY_NUMBER:-12}} 15 | 16 | depend() 17 | { 18 | keyword -docker -podman -lxc -openvz -prefix -systemd-nspawn -vserver 19 | } 20 | 21 | _setleds() 22 | { 23 | [ -z "$1" ] && return 1 24 | 25 | local dev=/dev/tty t= i=1 retval=0 26 | [ -d /dev/vc ] && dev=/dev/vc/ 27 | 28 | while [ $i -le $ttyn ]; do 29 | setleds -D "$1"num < $dev$i || retval=1 30 | : $(( i += 1 )) 31 | done 32 | 33 | return $retval 34 | } 35 | 36 | start() 37 | { 38 | ebegin "Enabling numlock on ttys" 39 | _setleds + 40 | eend $? "Failed to enable numlock" 41 | } 42 | 43 | stop() 44 | { 45 | yesno $RC_GOINGDOWN && return 0 46 | 47 | ebegin "Disabling numlock on ttys" 48 | _setleds - 49 | eend $? "Failed to disable numlock" 50 | } 51 | -------------------------------------------------------------------------------- /init.d/osclock.in: -------------------------------------------------------------------------------- 1 | #!@SBINDIR@/openrc-run 2 | # Copyright (c) 2014-2015 The OpenRC Authors. 3 | # See the Authors file at the top-level directory of this distribution and 4 | # https://github.com/OpenRC/openrc/blob/HEAD/AUTHORS 5 | # 6 | # This file is part of OpenRC. It is subject to the license terms in 7 | # the LICENSE file found in the top-level directory of this 8 | # distribution and at https://github.com/OpenRC/openrc/blob/HEAD/LICENSE 9 | # This file may not be copied, modified, propagated, or distributed 10 | # except according to the terms contained in the LICENSE file. 11 | 12 | # Can be used on OSs that take care of the clock. 13 | 14 | description="Provides clock" 15 | 16 | depend() 17 | { 18 | provide clock 19 | } 20 | 21 | start() 22 | { 23 | # This stub function is required to avoid OpenRC warning at boot: 24 | # 25 | # * The command variable is undefined. 26 | # * There is nothing for osclock to start. 27 | # * If this is what you intend, please write a start function. 28 | # * This will become a failure in a future release. 29 | # 30 | return 0 31 | } 32 | -------------------------------------------------------------------------------- /init.d/pf.in: -------------------------------------------------------------------------------- 1 | #!@SBINDIR@/openrc-run 2 | # Copyright (c) 2007-2015 The OpenRC Authors. 3 | # See the Authors file at the top-level directory of this distribution and 4 | # https://github.com/OpenRC/openrc/blob/HEAD/AUTHORS 5 | # 6 | # This file is part of OpenRC. It is subject to the license terms in 7 | # the LICENSE file found in the top-level directory of this 8 | # distribution and at https://github.com/OpenRC/openrc/blob/HEAD/LICENSE 9 | # This file may not be copied, modified, propagated, or distributed 10 | # except according to the terms contained in the LICENSE file. 11 | 12 | name="Packet Filter" 13 | : ${pf_conf:=${pf_rules:-/etc/pf.conf}} 14 | required_files=$pf_conf 15 | 16 | extra_commands="checkconfig showstatus" 17 | extra_started_commands="reload" 18 | 19 | depend() { 20 | need localmount 21 | keyword -jail -prefix 22 | } 23 | 24 | start() 25 | { 26 | ebegin "Starting $name" 27 | if command -v kldload >/dev/null 2>&1; then 28 | kldload pf 2>/dev/null 29 | fi 30 | pfctl -q -F all 31 | pfctl -q -f "$pf_conf" $pf_args 32 | pfctl -q -e 33 | eend $? 34 | } 35 | 36 | stop() 37 | { 38 | ebegin "Stopping $name" 39 | pfctl -q -d 40 | eend $? 41 | } 42 | 43 | checkconfig() 44 | { 45 | ebegin "Checking $name configuration" 46 | pfctl -n -f "$pf_conf" 47 | eend $? 48 | } 49 | 50 | reload() 51 | { 52 | ebegin "Reloading $name rules." 53 | pfctl -q -n -f "$pf_conf" && \ 54 | { 55 | # Flush everything but existing state entries that way when 56 | # rules are read in, it doesn't break established connections. 57 | pfctl -q -Fnat -Fqueue -Frules -FSources -Finfo -FTables -Fosfp 58 | pfctl -q -f "$pf_conf" $pf_args 59 | } 60 | eend $? 61 | } 62 | 63 | showstatus() 64 | { 65 | pfctl -s info 66 | } 67 | -------------------------------------------------------------------------------- /init.d/powerd.in: -------------------------------------------------------------------------------- 1 | #!@SBINDIR@/openrc-run 2 | # Copyright (c) 2007-2015 The OpenRC Authors. 3 | # See the Authors file at the top-level directory of this distribution and 4 | # https://github.com/OpenRC/openrc/blob/HEAD/AUTHORS 5 | # 6 | # This file is part of OpenRC. It is subject to the license terms in 7 | # the LICENSE file found in the top-level directory of this 8 | # distribution and at https://github.com/OpenRC/openrc/blob/HEAD/LICENSE 9 | # This file may not be copied, modified, propagated, or distributed 10 | # except according to the terms contained in the LICENSE file. 11 | 12 | command=/usr/sbin/powerd 13 | command_args=$powerd_args 14 | pidfile=/var/run/powerd.pid 15 | name="Power Control Daemon" 16 | 17 | depend() 18 | { 19 | need localmount 20 | use logger 21 | after bootmisc 22 | keyword -jail -prefix 23 | } 24 | 25 | start_pre() 26 | { 27 | if [ -n "$powerd_battery_mode" ]; then 28 | command_args="$command_args -b $powerd_battery_mode" 29 | fi 30 | if [ -n "${powerd_ac_mode}" ]; then 31 | command_args="$command_args -a $powerd_ac_mode" 32 | fi 33 | } 34 | 35 | stop_post() 36 | { 37 | local level=$(sysctl -n dev.cpu.0.freq_levels | 38 | sed -e 's:/.*::') 39 | if [ -n "$level" ]; then 40 | sysctl dev.cpu.0.freq="$level" >/dev/null 41 | fi 42 | } 43 | -------------------------------------------------------------------------------- /init.d/procfs.in: -------------------------------------------------------------------------------- 1 | #!@SBINDIR@/openrc-run 2 | # Copyright (c) 2007-2015 The OpenRC Authors. 3 | # See the Authors file at the top-level directory of this distribution and 4 | # https://github.com/OpenRC/openrc/blob/HEAD/AUTHORS 5 | # 6 | # This file is part of OpenRC. It is subject to the license terms in 7 | # the LICENSE file found in the top-level directory of this 8 | # distribution and at https://github.com/OpenRC/openrc/blob/HEAD/LICENSE 9 | # This file may not be copied, modified, propagated, or distributed 10 | # except according to the terms contained in the LICENSE file. 11 | 12 | description="Mounts misc filesystems in /proc." 13 | 14 | depend() 15 | { 16 | after clock 17 | use devfs 18 | want modules 19 | keyword -docker -podman -lxc -openvz -prefix -systemd-nspawn -vserver 20 | } 21 | 22 | start() 23 | { 24 | # Setup Kernel Support for miscellaneous Binary Formats 25 | if [ -d /proc/sys/fs/binfmt_misc ] && 26 | [ ! -e /proc/sys/fs/binfmt_misc/register ]; then 27 | if ! grep -qs binfmt_misc /proc/filesystems && 28 | modprobe -q binfmt-misc; then 29 | ewarn "The binfmt-misc module needs to be loaded by" \ 30 | "the modules service or built in." 31 | fi 32 | if grep -qs binfmt_misc /proc/filesystems; then 33 | ebegin "Mounting misc binary format filesystem" 34 | mount -t binfmt_misc -o nodev,noexec,nosuid \ 35 | binfmt_misc /proc/sys/fs/binfmt_misc 36 | eend $? 37 | fi 38 | fi 39 | return 0 40 | } 41 | -------------------------------------------------------------------------------- /init.d/rarpd.in: -------------------------------------------------------------------------------- 1 | #!@SBINDIR@/openrc-run 2 | # Copyright (c) 2007-2015 The OpenRC Authors. 3 | # See the Authors file at the top-level directory of this distribution and 4 | # https://github.com/OpenRC/openrc/blob/HEAD/AUTHORS 5 | # 6 | # This file is part of OpenRC. It is subject to the license terms in 7 | # the LICENSE file found in the top-level directory of this 8 | # distribution and at https://github.com/OpenRC/openrc/blob/HEAD/LICENSE 9 | # This file may not be copied, modified, propagated, or distributed 10 | # except according to the terms contained in the LICENSE file. 11 | 12 | command=/usr/sbin/rarpd 13 | command_args="-f $rarpd_args" 14 | pidfile=/var/run/rarpd.pid 15 | name="Reverse ARP Daemon" 16 | required_files=/etc/ethers 17 | 18 | if [ -z "$rarpd_interface" ]; then 19 | command_args="$command_args -a" 20 | else 21 | command_args="$command_args $rarpd_interface" 22 | fi 23 | command_background=YES 24 | 25 | depend() 26 | { 27 | need localmount 28 | after bootmisc 29 | need net 30 | } 31 | -------------------------------------------------------------------------------- /init.d/rc-enabled.in: -------------------------------------------------------------------------------- 1 | #!@SBINDIR@/openrc-run 2 | # Copyright (c) 2007-2015 The OpenRC Authors. 3 | # See the Authors file at the top-level directory of this distribution and 4 | # https://github.com/OpenRC/openrc/blob/HEAD/AUTHORS 5 | # 6 | # This file is part of OpenRC. It is subject to the license terms in 7 | # the LICENSE file found in the top-level directory of this 8 | # distribution and at https://github.com/OpenRC/openrc/blob/HEAD/LICENSE 9 | # This file may not be copied, modified, propagated, or distributed 10 | # except according to the terms contained in the LICENSE file. 11 | 12 | depend() 13 | { 14 | need localmount net 15 | after * 16 | before local 17 | keyword -prefix 18 | } 19 | 20 | start() 21 | { 22 | ebegin "Starting local rc services" 23 | local svc= enabled= retval=0 service= pkgdir= 24 | [ -n "@PKG_PREFIX@" ] && pkgdir="@PKG_PREFIX@/etc/rc.d/*" 25 | for svc in $(rcorder /etc/rc.d/* $pkgdir 2>/dev/null); do 26 | [ -x "$svc" ] || continue 27 | service=${svc##*/} 28 | 29 | # Skip these services 30 | for s in cleartmp moused; do 31 | [ "$s" = "$service" ] && continue 2 32 | done 33 | 34 | # If we have an init script for this service, continue 35 | rc-service --exists "$service" && continue 36 | 37 | # Ensure that the users rc.conf will start us 38 | eval enabled=\$${svc##*/}_enable 39 | yesno $enabled || yesno ${svc##*/} || continue 40 | 41 | # Good to go! 42 | "$svc" start && started="$started $svc" 43 | : $(( retval += $? )) 44 | done 45 | service_set_value started "$started" 46 | eend $retval "Some local rc services failed to start" 47 | return 0 48 | } 49 | 50 | stop() 51 | { 52 | ebegin "Stopping local rc services" 53 | local svc= retval=0 54 | for svc in $(rcorder $(service_get_value started) 2>/dev/null | sort -r); do 55 | "$svc" stop 56 | : $(( retval += $? )) 57 | done 58 | eend $retval "Some local rc services failed to stop" 59 | return 0 60 | } 61 | -------------------------------------------------------------------------------- /init.d/root.in: -------------------------------------------------------------------------------- 1 | #!@SBINDIR@/openrc-run 2 | # Copyright (c) 2007-2015 The OpenRC Authors. 3 | # See the Authors file at the top-level directory of this distribution and 4 | # https://github.com/OpenRC/openrc/blob/HEAD/AUTHORS 5 | # 6 | # This file is part of OpenRC. It is subject to the license terms in 7 | # the LICENSE file found in the top-level directory of this 8 | # distribution and at https://github.com/OpenRC/openrc/blob/HEAD/LICENSE 9 | # This file may not be copied, modified, propagated, or distributed 10 | # except according to the terms contained in the LICENSE file. 11 | 12 | description="Mount the root fs read/write" 13 | 14 | depend() 15 | { 16 | after clock 17 | need fsck 18 | keyword -docker -podman -jail -lxc -openvz -prefix -systemd-nspawn -vserver 19 | } 20 | 21 | start() 22 | { 23 | local root_opts=",$(fstabinfo -o /)," 24 | case "$root_opts" in 25 | *,ro,*) 26 | ;; 27 | *) 28 | # Check if the rootfs isn't already writable. 29 | if checkpath -W /; then 30 | rm -f /fastboot /forcefsck 31 | else 32 | ebegin "Remounting root filesystem read/write" 33 | case "$RC_UNAME" in 34 | Linux) 35 | mount -n -o remount,rw / 36 | ;; 37 | *) 38 | mount -u -o rw / 39 | ;; 40 | esac 41 | eend $? "Root filesystem could not be mounted read/write" 42 | if [ $? -eq 0 ]; then 43 | rm -f /fastboot /forcefsck 44 | fi 45 | fi 46 | ;; 47 | esac 48 | 49 | case "$root_opts" in 50 | *,shared,*|*,rshared,*) 51 | ebegin "Making root filesystem shared" 52 | case "$RC_UNAME" in 53 | Linux) 54 | mount --make-rshared / 55 | ;; 56 | *) 57 | ewarn "Ignoring 'shared' option for / on non-linux" 58 | ;; 59 | esac 60 | eend $? "Root filesystem could not be made shared" 61 | ;; 62 | esac 63 | 64 | ebegin "Remounting filesystems" 65 | local mountpoint 66 | for mountpoint in $(fstabinfo); do 67 | case "${mountpoint}" in 68 | /*) # Don't remount swap etc. 69 | mountinfo -q "${mountpoint}" && \ 70 | fstabinfo --remount "${mountpoint}" 71 | ;; 72 | esac 73 | done 74 | eend 0 75 | } 76 | -------------------------------------------------------------------------------- /init.d/rpcbind.in: -------------------------------------------------------------------------------- 1 | #!@SBINDIR@/openrc-run 2 | # Copyright (c) 2007-2015 The OpenRC Authors. 3 | # See the Authors file at the top-level directory of this distribution and 4 | # https://github.com/OpenRC/openrc/blob/HEAD/AUTHORS 5 | # 6 | # This file is part of OpenRC. It is subject to the license terms in 7 | # the LICENSE file found in the top-level directory of this 8 | # distribution and at https://github.com/OpenRC/openrc/blob/HEAD/LICENSE 9 | # This file may not be copied, modified, propagated, or distributed 10 | # except according to the terms contained in the LICENSE file. 11 | 12 | command=/usr/sbin/rpcbind 13 | command_args=$rpcbind_args 14 | name="RPC program number mapper" 15 | 16 | depend() 17 | { 18 | provide rpc 19 | need localmount 20 | use net logger dns 21 | before inetd xinetd ntpd ntp-client 22 | } 23 | 24 | stop_post() 25 | { 26 | # rpcbind returns too fast, so sleep for a second 27 | sleep 1 28 | } 29 | -------------------------------------------------------------------------------- /init.d/runsvdir.in: -------------------------------------------------------------------------------- 1 | #!@SBINDIR@/openrc-run 2 | # Copyright (c) 2016 The OpenRC Authors. 3 | # See the Authors file at the top-level directory of this distribution and 4 | # https://github.com/OpenRC/openrc/blob/HEAD/AUTHORS 5 | # 6 | # This file is part of OpenRC. It is subject to the license terms in 7 | # the LICENSE file found in the top-level directory of this 8 | # distribution and at https://github.com/OpenRC/openrc/blob/HEAD/LICENSE 9 | # This file may not be copied, modified, propagated, or distributed 10 | # except according to the terms contained in the LICENSE file. 11 | 12 | supervisor=supervise-daemon 13 | command=/usr/bin/runsvdir 14 | pidfile="/var/run/${RC_SVCNAME}.pid" 15 | command_args="-P $RC_SVCDIR/sv 'log: ...........................................................................................................................................................................................................................................................................................................................................................................................................'" 16 | 17 | start_pre() 18 | { 19 | checkpath -m 0755 -o root:root -d ${RC_SVCDIR}/sv 20 | } 21 | -------------------------------------------------------------------------------- /init.d/s6-svscan.in: -------------------------------------------------------------------------------- 1 | #!@SBINDIR@/openrc-run 2 | # Copyright (c) 2015 The OpenRC Authors. 3 | # See the Authors file at the top-level directory of this distribution and 4 | # https://github.com/OpenRC/openrc/blob/HEAD/AUTHORS 5 | # 6 | # This file is part of OpenRC. It is subject to the license terms in 7 | # the LICENSE file found in the top-level directory of this 8 | # distribution and at https://github.com/OpenRC/openrc/blob/HEAD/LICENSE 9 | # This file may not be copied, modified, propagated, or distributed 10 | # except according to the terms contained in the LICENSE file. 11 | 12 | command=/bin/s6-svscan 13 | command_args="${RC_SVCDIR}"/s6-scan 14 | command_background=yes 15 | pidfile=/var/run/s6-svscan.pid 16 | 17 | depend() 18 | { 19 | need localmount 20 | } 21 | 22 | start_pre() 23 | { 24 | if [ ! -e "$command" ]; then 25 | eerror "$command is missing (please install s6)" 26 | else 27 | einfo "Creating s6 scan directory" 28 | checkpath -d -m 0755 "$RC_SVCDIR"/s6-scan 29 | fi 30 | return 31 | } 32 | 33 | stop_post() 34 | { 35 | ebegin "Stopping any remaining s6 services" 36 | s6-svc -dx "${RC_SVCDIR}"/s6-scan/* 2>/dev/null || true 37 | eend $? 38 | 39 | ebegin "Stopping any remaining s6 service loggers" 40 | s6-svc -dx "${RC_SVCDIR}"/s6-scan/*/log 2>/dev/null || true 41 | eend $? 42 | } 43 | -------------------------------------------------------------------------------- /init.d/save-keymaps.in: -------------------------------------------------------------------------------- 1 | #!@SBINDIR@/openrc-run 2 | # Copyright (c) 2018 Sony Interactive Entertainment, Inc. 3 | # 4 | # This file is part of OpenRC. It is subject to the license terms in 5 | # the LICENSE file found in the top-level directory of this 6 | # distribution and at https://github.com/OpenRC/openrc/blob/HEAD/LICENSE 7 | # This file may not be copied, modified, propagated, or distributed 8 | # except according to the terms contained in the LICENSE file. 9 | 10 | description="Save the keymap for use as early as possible" 11 | 12 | depend() 13 | { 14 | need termencoding 15 | after bootmisc clock keymaps 16 | keyword -docker -podman -lxc -openvz -prefix -systemd-nspawn -uml -vserver -xenu 17 | } 18 | 19 | start() 20 | { 21 | # Save the keymapping for use immediately at boot 22 | ebegin "Saving key mapping" 23 | if checkpath -W "$RC_LIBEXECDIR"; then 24 | mkdir -p "$RC_LIBEXECDIR"/console 25 | dumpkeys >"$RC_LIBEXECDIR"/console/keymap 26 | fi 27 | eend $? "Unable to save keymapping" 28 | } 29 | -------------------------------------------------------------------------------- /init.d/save-termencoding.in: -------------------------------------------------------------------------------- 1 | #!@SBINDIR@/openrc-run 2 | # Copyright (c) 2018 Sony Interactive Entertainment, Inc. 3 | # 4 | # This file is part of OpenRC. It is subject to the license terms in 5 | # the LICENSE file found in the top-level directory of this 6 | # distribution and at https://github.com/OpenRC/openrc/blob/HEAD/LICENSE 7 | # This file may not be copied, modified, propagated, or distributed 8 | # except according to the terms contained in the LICENSE file. 9 | 10 | description="Configures terminal encoding." 11 | 12 | ttyn=${rc_tty_number:-${RC_TTY_NUMBER:-12}} 13 | : ${unicode:=${UNICODE}} 14 | 15 | depend() 16 | { 17 | keyword -docker -podman -lxc -openvz -prefix -systemd-nspawn -uml -vserver -xenu 18 | use root 19 | after bootmisc clock termencoding 20 | } 21 | 22 | start() 23 | { 24 | ebegin "Saving terminal encoding" 25 | # Save the encoding for use immediately at boot 26 | if checkpath -W "$RC_LIBEXECDIR"; then 27 | mkdir -p "$RC_LIBEXECDIR"/console 28 | if yesno ${unicode:-yes}; then 29 | echo "" > "$RC_LIBEXECDIR"/console/unicode 30 | else 31 | rm -f "$RC_LIBEXECDIR"/console/unicode 32 | fi 33 | fi 34 | eend 0 35 | } 36 | -------------------------------------------------------------------------------- /init.d/savecore.in: -------------------------------------------------------------------------------- 1 | #!@SBINDIR@/openrc-run 2 | # Copyright (c) 2007-2015 The OpenRC Authors. 3 | # See the Authors file at the top-level directory of this distribution and 4 | # https://github.com/OpenRC/openrc/blob/HEAD/AUTHORS 5 | # 6 | # This file is part of OpenRC. It is subject to the license terms in 7 | # the LICENSE file found in the top-level directory of this 8 | # distribution and at https://github.com/OpenRC/openrc/blob/HEAD/LICENSE 9 | # This file may not be copied, modified, propagated, or distributed 10 | # except according to the terms contained in the LICENSE file. 11 | 12 | description="Saves a kernel dump." 13 | 14 | depend() 15 | { 16 | need dumpon localmount 17 | after clock 18 | before encswap 19 | keyword -jail -prefix 20 | } 21 | 22 | start() 23 | { 24 | : ${dump_dir:=/var/crash} 25 | if ! [ -d "$dump_dir" ]; then 26 | mkdir -p "$dump_dir" 27 | chmod 700 "$dump_dir" 28 | fi 29 | 30 | if [ "$RC_UNAME" = FreeBSD ]; then 31 | # Don't quote ${dump_device}, so that if it's unset, 32 | # savecore will check on the partitions listed in fstab 33 | # without errors in the output 34 | savecore -C $dump_device >/dev/null 35 | else 36 | ls "$dump_dir"/bsd* > /dev/null 2>&1 37 | fi 38 | [ $? = 0 ] || return 0 39 | 40 | local sopts="$dump_dir $dump_device" 41 | yesno $dump_compress && sopts="-z $sopts" 42 | ebegin "Saving kernel core dump in $dump_dir" 43 | savecore $sopts >/dev/null 44 | eend $? 45 | } 46 | -------------------------------------------------------------------------------- /init.d/seedrng.in: -------------------------------------------------------------------------------- 1 | #!@SBINDIR@/openrc-run 2 | # Copyright (c) 2007-2022 The OpenRC Authors. 3 | # See the Authors file at the top-level directory of this distribution and 4 | # https://github.com/OpenRC/openrc/blob/HEAD/AUTHORS 5 | # 6 | # This file is part of OpenRC. It is subject to the license terms in 7 | # the LICENSE file found in the top-level directory of this 8 | # distribution and at https://github.com/OpenRC/openrc/blob/HEAD/LICENSE 9 | # This file may not be copied, modified, propagated, or distributed 10 | # except according to the terms contained in the LICENSE file. 11 | 12 | description="Initializes the random number generator." 13 | 14 | depend() 15 | { 16 | after clock 17 | need localmount 18 | keyword -docker -podman -jail -lxc -openvz -prefix -systemd-nspawn 19 | provide urandom 20 | } 21 | 22 | seedrng_with_options() 23 | { 24 | set -- 25 | [ -n "${seed_dir}" ] && set -- "$@" --seed-dir "${seed_dir}" 26 | yesno "${skip_credit}" && set -- "$@" --skip-credit 27 | seedrng "$@" 28 | } 29 | 30 | start() 31 | { 32 | ebegin "Seeding random number generator" 33 | seedrng_with_options 34 | eend $? "Error seeding random number generator" 35 | return 0 36 | } 37 | 38 | stop() 39 | { 40 | ebegin "Saving random number generator seed" 41 | seedrng_with_options 42 | eend $? "Error saving random number generator seed" 43 | return 0 44 | } 45 | -------------------------------------------------------------------------------- /init.d/swap-blk.in: -------------------------------------------------------------------------------- 1 | #!@SBINDIR@/openrc-run 2 | # Copyright (c) 2007-2015 The OpenRC Authors. 3 | # See the Authors file at the top-level directory of this distribution and 4 | # https://github.com/OpenRC/openrc/blob/HEAD/AUTHORS 5 | # 6 | # This file is part of OpenRC. It is subject to the license terms in 7 | # the LICENSE file found in the top-level directory of this 8 | # distribution and at https://github.com/OpenRC/openrc/blob/HEAD/LICENSE 9 | # This file may not be copied, modified, propagated, or distributed 10 | # except according to the terms contained in the LICENSE file. 11 | 12 | depend() 13 | { 14 | after clock 15 | before fsck 16 | keyword -jail -prefix 17 | } 18 | 19 | start() 20 | { 21 | ebegin "Activating block swap devices" 22 | swapctl -A -t blk >/dev/null 23 | eend 0 # If swapon has nothing todo it errors, so always return 0 24 | } 25 | 26 | stop() 27 | { 28 | ebegin "Deactivating block swap devices" 29 | swapctl -U -t blk >/dev/null 30 | eend 0 31 | } 32 | -------------------------------------------------------------------------------- /init.d/swap.in: -------------------------------------------------------------------------------- 1 | #!@SBINDIR@/openrc-run 2 | # Copyright (c) 2007-2015 The OpenRC Authors. 3 | # See the Authors file at the top-level directory of this distribution and 4 | # https://github.com/OpenRC/openrc/blob/HEAD/AUTHORS 5 | # 6 | # This file is part of OpenRC. It is subject to the license terms in 7 | # the LICENSE file found in the top-level directory of this 8 | # distribution and at https://github.com/OpenRC/openrc/blob/HEAD/LICENSE 9 | # This file may not be copied, modified, propagated, or distributed 10 | # except according to the terms contained in the LICENSE file. 11 | 12 | depend() 13 | { 14 | after clock root 15 | before localmount 16 | keyword -docker -podman -jail -lxc -openvz -prefix -systemd-nspawn -vserver 17 | } 18 | 19 | start() 20 | { 21 | ebegin "Activating swap devices" 22 | case "$RC_UNAME" in 23 | NetBSD|OpenBSD) swapctl -A -t noblk >/dev/null;; 24 | *) swapon -a >/dev/null;; 25 | esac 26 | eend 0 # If swapon has nothing todo it errors, so always return 0 27 | } 28 | 29 | stop() 30 | { 31 | ebegin "Deactivating swap devices" 32 | case "$RC_UNAME" in 33 | NetBSD|OpenBSD) swapctl -U -t noblk >/dev/null;; 34 | *) swapoff -a >/dev/null;; 35 | esac 36 | eend 0 37 | } 38 | -------------------------------------------------------------------------------- /init.d/swclock.in: -------------------------------------------------------------------------------- 1 | #!@SBINDIR@/openrc-run 2 | # Copyright (c) 2009-2015 The OpenRC Authors. 3 | # See the Authors file at the top-level directory of this distribution and 4 | # https://github.com/OpenRC/openrc/blob/HEAD/AUTHORS 5 | # 6 | # This file is part of OpenRC. It is subject to the license terms in 7 | # the LICENSE file found in the top-level directory of this 8 | # distribution and at https://github.com/OpenRC/openrc/blob/HEAD/LICENSE 9 | # This file may not be copied, modified, propagated, or distributed 10 | # except according to the terms contained in the LICENSE file. 11 | 12 | description="Sets the local clock to the mtime of a given file." 13 | swclock_file="${swclock_file:-/var/lib/misc/openrc-shutdowntime}" 14 | 15 | depend() 16 | { 17 | provide clock 18 | keyword -docker -podman -lxc -openvz -prefix -systemd-nspawn -uml -vserver -xenu 19 | } 20 | 21 | # swclock is an OpenRC built in 22 | 23 | start() 24 | { 25 | ebegin "Setting the local clock based on last shutdown time" 26 | if ! swclock "${swclock_file}" 2> /dev/null; then 27 | swclock --warn @SBINDIR@/openrc-run 28 | fi 29 | eend $? 30 | } 31 | 32 | stop() 33 | { 34 | ebegin "Saving the shutdown time" 35 | swclock --save "${swclock_file}" 36 | eend $? 37 | } 38 | -------------------------------------------------------------------------------- /init.d/sysctl.in: -------------------------------------------------------------------------------- 1 | #!@SBINDIR@/openrc-run 2 | # Copyright (c) 2007-2015 The OpenRC Authors. 3 | # See the Authors file at the top-level directory of this distribution and 4 | # https://github.com/OpenRC/openrc/blob/HEAD/AUTHORS 5 | # 6 | # This file is part of OpenRC. It is subject to the license terms in 7 | # the LICENSE file found in the top-level directory of this 8 | # distribution and at https://github.com/OpenRC/openrc/blob/HEAD/LICENSE 9 | # This file may not be copied, modified, propagated, or distributed 10 | # except according to the terms contained in the LICENSE file. 11 | 12 | depend() 13 | { 14 | after clock 15 | before bootmisc logger 16 | keyword -prefix -systemd-nspawn -vserver 17 | } 18 | 19 | BSD_sysctl() 20 | { 21 | [ -e /etc/sysctl.conf ] || return 0 22 | local retval=0 var= comments= conf= 23 | eindent 24 | for conf in /etc/sysctl.conf /etc/sysctl.d/*.conf; do 25 | if [ -r "$conf" ]; then 26 | vebegin "applying $conf" 27 | while read var comments; do 28 | case "$var" in 29 | ""|"#"*) continue;; 30 | esac 31 | sysctl -w "$var" >/dev/null || retval=1 32 | done < "$conf" 33 | veend $retval 34 | fi 35 | done 36 | eoutdent 37 | return $retval 38 | } 39 | 40 | Linux_sysctl() 41 | { 42 | local quiet 43 | yesno $rc_verbose || quiet=-q 44 | 45 | sysctl ${quiet} --system 46 | } 47 | 48 | start() 49 | { 50 | local rc=0 51 | 52 | ebegin "Configuring kernel parameters" 53 | case "$RC_UNAME" in 54 | *BSD|GNU) BSD_sysctl; rc=$? ;; 55 | Linux) Linux_sysctl; rc=$? ;; 56 | esac 57 | eend $rc "Unable to configure some kernel parameters" 58 | } 59 | -------------------------------------------------------------------------------- /init.d/syslogd.in: -------------------------------------------------------------------------------- 1 | #!@SBINDIR@/openrc-run 2 | # Copyright (c) 2007-2015 The OpenRC Authors. 3 | # See the Authors file at the top-level directory of this distribution and 4 | # https://github.com/OpenRC/openrc/blob/HEAD/AUTHORS 5 | # 6 | # This file is part of OpenRC. It is subject to the license terms in 7 | # the LICENSE file found in the top-level directory of this 8 | # distribution and at https://github.com/OpenRC/openrc/blob/HEAD/LICENSE 9 | # This file may not be copied, modified, propagated, or distributed 10 | # except according to the terms contained in the LICENSE file. 11 | 12 | command=/usr/sbin/syslogd 13 | command_args=$syslogd_args 14 | case "$RC_UNAME" in 15 | FreeBSD|DragonFly) pidfile=/var/run/syslog.pid;; 16 | *) pidfile=/var/run/syslogd.pid;; 17 | esac 18 | name="System Logger Daemon" 19 | 20 | depend() 21 | { 22 | provide logger 23 | use net newsyslog 24 | need localmount 25 | after bootmisc clock 26 | keyword -prefix 27 | } 28 | -------------------------------------------------------------------------------- /init.d/termencoding.in: -------------------------------------------------------------------------------- 1 | #!@SBINDIR@/openrc-run 2 | # Copyright (c) 2008-2015 The OpenRC Authors. 3 | # See the Authors file at the top-level directory of this distribution and 4 | # https://github.com/OpenRC/openrc/blob/HEAD/AUTHORS 5 | # 6 | # This file is part of OpenRC. It is subject to the license terms in 7 | # the LICENSE file found in the top-level directory of this 8 | # distribution and at https://github.com/OpenRC/openrc/blob/HEAD/LICENSE 9 | # This file may not be copied, modified, propagated, or distributed 10 | # except according to the terms contained in the LICENSE file. 11 | 12 | description="Configures terminal encoding." 13 | 14 | ttyn=${rc_tty_number:-${RC_TTY_NUMBER:-12}} 15 | : ${unicode:=${UNICODE}} 16 | 17 | depend() 18 | { 19 | keyword -docker -podman -lxc -openvz -prefix -systemd-nspawn -uml -vserver -xenu 20 | after devfs 21 | } 22 | 23 | start() 24 | { 25 | local ttydev=/dev/tty n= 26 | [ -d /dev/vc ] && ttydev=/dev/vc/ 27 | 28 | # Set terminal encoding to either ASCII or UNICODE. 29 | # See utf-8(7) for more information. 30 | local termencoding="%@" termmsg="ASCII" 31 | if yesno ${unicode:-yes}; then 32 | termencoding="%G" 33 | termmsg="UTF-8" 34 | fi 35 | 36 | ebegin "Setting terminal encoding [$termmsg]" 37 | n=1 38 | while [ ${n} -le "$ttyn" ]; do 39 | printf "\033%s" "$termencoding" >$ttydev$n 40 | : $(( n += 1 )) 41 | done 42 | 43 | # Save the encoding for use immediately at boot 44 | if checkpath -W "$RC_LIBEXECDIR"; then 45 | mkdir -p "$RC_LIBEXECDIR"/console 46 | if yesno ${unicode:-yes}; then 47 | echo "" > "$RC_LIBEXECDIR"/console/unicode 48 | else 49 | rm -f "$RC_LIBEXECDIR"/console/unicode 50 | fi 51 | fi 52 | 53 | eend 0 54 | } 55 | -------------------------------------------------------------------------------- /init.d/ttys.in: -------------------------------------------------------------------------------- 1 | #!@SBINDIR@/openrc-run 2 | # Copyright (c) 2008-2015 The OpenRC Authors. 3 | # See the Authors file at the top-level directory of this distribution and 4 | # https://github.com/OpenRC/openrc/blob/HEAD/AUTHORS 5 | # 6 | # This file is part of OpenRC. It is subject to the license terms in 7 | # the LICENSE file found in the top-level directory of this 8 | # distribution and at https://github.com/OpenRC/openrc/blob/HEAD/LICENSE 9 | # This file may not be copied, modified, propagated, or distributed 10 | # except according to the terms contained in the LICENSE file. 11 | 12 | depend() 13 | { 14 | after clock fsck 15 | keyword -prefix 16 | } 17 | 18 | start() 19 | { 20 | ebegin "Setting tty flags" 21 | ttyflags -a 22 | eend $? || return $? 23 | 24 | if [ -c /dev/ttyp0 ]; then 25 | chmod 666 /dev/tty[p-uw-zP-T][0-9a-zA-Z] 26 | fi 27 | if [ -c /dev/ttyv1 ]; then 28 | chmod 666 /dev/ttyv[0-9a-zA-Z] 29 | fi 30 | } 31 | -------------------------------------------------------------------------------- /init.d/urandom.in: -------------------------------------------------------------------------------- 1 | #!@SBINDIR@/openrc-run 2 | # Copyright (c) 2007-2022 The OpenRC Authors. 3 | # See the Authors file at the top-level directory of this distribution and 4 | # https://github.com/OpenRC/openrc/blob/HEAD/AUTHORS 5 | # 6 | # This file is part of OpenRC. It is subject to the license terms in 7 | # the LICENSE file found in the top-level directory of this 8 | # distribution and at https://github.com/OpenRC/openrc/blob/HEAD/LICENSE 9 | # This file may not be copied, modified, propagated, or distributed 10 | # except according to the terms contained in the LICENSE file. 11 | 12 | : ${urandom_seed:=${URANDOM_SEED:-/var/lib/misc/random-seed}} 13 | description="Initializes the random number generator." 14 | 15 | depend() 16 | { 17 | after clock 18 | need localmount 19 | keyword -docker -podman -jail -lxc -openvz -prefix -systemd-nspawn 20 | } 21 | 22 | save_seed() 23 | { 24 | ( # sub shell to prevent umask pollution 25 | umask 077 26 | dd if=/dev/urandom of="$urandom_seed" count=1 2>/dev/null 27 | ) 28 | } 29 | 30 | start() 31 | { 32 | [ -c /dev/urandom ] || return 33 | if [ -f "$urandom_seed" ]; then 34 | ebegin "Initializing random number generator" 35 | cat "$urandom_seed" > /dev/urandom 36 | eend $? "Error initializing random number generator" 37 | fi 38 | rm -f "$urandom_seed" && save_seed 39 | return 0 40 | } 41 | 42 | stop() 43 | { 44 | ebegin "Saving random seed" 45 | save_seed 46 | eend $? "Failed to save random seed" 47 | } 48 | -------------------------------------------------------------------------------- /init.d/user.in: -------------------------------------------------------------------------------- 1 | #!@SBINDIR@/openrc-run 2 | # Copyright (c) 2017 The OpenRC Authors. 3 | # See the Authors file at the top-level directory of this distribution and 4 | # https://github.com/OpenRC/openrc/blob/HEAD/AUTHORS 5 | # 6 | # This file is part of OpenRC. It is subject to the license terms in 7 | # the LICENSE file found in the top-level directory of this 8 | # distribution and at https://github.com/OpenRC/openrc/blob/HEAD/LICENSE 9 | # This file may not be copied, modified, propagated, or distributed 10 | # except according to the terms contained in the LICENSE file. 11 | 12 | description="starts an openrc session for an user" 13 | user="${RC_SVCNAME#*.}" 14 | 15 | extra_started_commands="runtime_directory" 16 | 17 | runtime_directory() { 18 | service_get_value xdg_runtime_dir 19 | } 20 | 21 | start_pre() { 22 | if [ "$user" = "$RC_SVCNAME" ]; then 23 | eerror "${RC_SVCNAME} cannot be started directly. You must create" 24 | eerror "symbolic links to it for the users you want to start" 25 | return 1 26 | fi 27 | 28 | if [ -z "$XDG_RUNTIME_DIR" ]; then 29 | export XDG_RUNTIME_DIR="/run/user/$(id -u $user)" 30 | checkpath -d -o "$user:$user" "$XDG_RUNTIME_DIR" || return 1 31 | fi 32 | 33 | service_set_value xdg_runtime_dir "$XDG_RUNTIME_DIR" 34 | } 35 | 36 | start() { 37 | ebegin "Starting user session for $user" 38 | user_init $user start 39 | eend $? 40 | return 0 41 | } 42 | 43 | stop() { 44 | ebegin "Stopping user session for $user" 45 | user_init $user stop 46 | eend $? 47 | return 0 48 | } 49 | -------------------------------------------------------------------------------- /local.d/README: -------------------------------------------------------------------------------- 1 | This directory should contain programs or scripts which are to be run 2 | when the local service is started or stopped. 3 | 4 | If a file in this directory is executable and it has a .start extension, 5 | it will be run when the local service is started. If a file is 6 | executable and it has a .stop extension, it will be run when the local 7 | service is stopped. 8 | 9 | All files are processed in lexical order. 10 | 11 | Keep in mind that files in this directory are processed sequentially, 12 | and the local service is not considered started or stopped until 13 | everything is processed, so if you have a process which takes a long 14 | time to run, it can delay your boot or shutdown processing. 15 | -------------------------------------------------------------------------------- /local.d/meson.build: -------------------------------------------------------------------------------- 1 | local_d_dir = get_option('sysconfdir') / 'local.d' 2 | 3 | local_data = [ 4 | 'README' 5 | ] 6 | 7 | install_data(local_data, install_dir : local_d_dir) 8 | -------------------------------------------------------------------------------- /man/meson.build: -------------------------------------------------------------------------------- 1 | man3 = [ 2 | 'einfo.3', 3 | 'rc_config.3', 4 | 'rc_deptree.3', 5 | 'rc_find_pids.3', 6 | 'rc_plugin_hook.3', 7 | 'rc_runlevel.3', 8 | 'rc_service.3', 9 | 'rc_stringlist.3', 10 | ] 11 | 12 | man8 = [ 13 | 'openrc.8', 14 | 'openrc-run.8', 15 | 'rc-service.8', 16 | 'rc-status.8', 17 | 'rc-update.8', 18 | 'start-stop-daemon.8', 19 | 'supervise-daemon.8', 20 | ] 21 | 22 | if os == 'Linux' 23 | man8 = man8 + [ 24 | 'rc-sstat.8', 25 | 'openrc-init.8', 26 | 'openrc-shutdown.8', 27 | ] 28 | endif 29 | 30 | install_data(man3, 31 | install_dir : get_option('mandir') / 'man3') 32 | install_data(man8, 33 | install_dir : get_option('mandir') / 'man8') 34 | meson.add_install_script('meson_man_links.sh', get_option('mandir'), man3 + man8) 35 | -------------------------------------------------------------------------------- /man/meson_man_links.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | get_links() { 4 | sed -e 's/ ,//g' \ 5 | -e '/^\.Sh NAME$/,/\.Sh/ s/\.Nm //p' \ 6 | -n ${MESON_SOURCE_ROOT}/man/${1} 7 | } 8 | 9 | MANDIR="$1" 10 | shift 11 | for man in $@; do 12 | prefix=${man%%.*} 13 | suffix=${man#*.} 14 | links=$(get_links ${man}) 15 | for link in ${links}; do 16 | if [ "${link}" != "${prefix}" ]; then 17 | ln -sf ${man} ${MESON_INSTALL_DESTDIR_PREFIX}/${MANDIR}/man${suffix}/${link}.${suffix} 18 | fi 19 | done 20 | done 21 | -------------------------------------------------------------------------------- /man/openrc-init.8: -------------------------------------------------------------------------------- 1 | .\" Copyright (c) 2017 The OpenRC Authors. 2 | .\" See the Authors file at the top-level directory of this distribution and 3 | .\" https://github.com/OpenRC/openrc/blob/HEAD/AUTHORS 4 | .\" 5 | .\" This file is part of OpenRC. It is subject to the license terms in 6 | .\" the LICENSE file found in the top-level directory of this 7 | .\" distribution and at https://github.com/OpenRC/openrc/blob/HEAD/LICENSE 8 | .\" This file may not be copied, modified, propagated, or distributed 9 | .\" except according to the terms contained in the LICENSE file. 10 | .\" 11 | .Dd April 6, 2017 12 | .Dt openrc-init 8 SMM 13 | .Os OpenRC 14 | .Sh NAME 15 | .Nm openrc-init 16 | .Nd the parent of all processes 17 | .Sh SYNOPSIS 18 | .Nm 19 | .Sh DESCRIPTION 20 | .Nm 21 | is an init process which can be an alternative to sysvinit or any other 22 | init process. 23 | .Pp 24 | To use 25 | .Nm 26 | configure your boot loader to invoke it or symlink it to /sbin/init. 27 | Also, you will need to use 28 | .Xr openrc-shutdown 8 , 29 | to halt, reboot or poweroff the system. 30 | .Pp 31 | The default runlevel is read from the init command line, the 32 | rc_default_runlevel setting in rc.conf, the kernel command line, or it is 33 | assumed to be "default" if it is not set in any of these places. 34 | .Pp 35 | .Nm 36 | doesn't manage getty's directly, so you will need to manage them another 37 | way. For example, you can use the agetty service script as described in 38 | agetty-guide.md in this distribution. 39 | .Sh BUGS 40 | This was first released as part of OpenRC 0.25. 41 | I do not know of any specific issues. However, since this is the first 42 | release of openrc-init, please test and report any issues you find. 43 | .Sh SEE ALSO 44 | .Xr openrc-shutdown 8 , 45 | .Sh AUTHORS 46 | .An William Hubbs 47 | -------------------------------------------------------------------------------- /man/rc-sstat.8: -------------------------------------------------------------------------------- 1 | .\" Copyright (c) 2015 The OpenRC Authors. 2 | .\" See the Authors file at the top-level directory of this distribution and 3 | .\" https://github.com/OpenRC/openrc/blob/HEAD/AUTHORS 4 | .\" 5 | .\" This file is part of OpenRC. It is subject to the license terms in 6 | .\" the LICENSE file found in the top-level directory of this 7 | .\" distribution and at https://github.com/OpenRC/openrc/blob/HEAD/LICENSE 8 | .\" This file may not be copied, modified, propagated, or distributed 9 | .\" except according to the terms contained in the LICENSE file. 10 | .\" 11 | .Dd April 24, 2008 12 | .Dt RC-sstat 8 SMM 13 | .Os OpenRC 14 | .Sh NAME 15 | .Nm rc-sstat 16 | .Nd show status info about services supervised by s6 then rc-status 17 | info 18 | .Sh SYNOPSIS 19 | .Nm 20 | .Sh DESCRIPTION 21 | .Nm 22 | gathers and displays information about the status of services supervised 23 | by s6 then runs rc-status to show info about normal OpenRC services. 24 | .Pp 25 | .Sh EXIT STATUS 26 | .Nm 27 | exits 1 if there is an internal error or exits with the same exit codes 28 | as rc-status. 29 | .Sh SEE ALSO 30 | .Xr rc-status 8 , 31 | .Xr rc-update 8 32 | .Sh AUTHORS 33 | .An William Hubbs 34 | -------------------------------------------------------------------------------- /man/rc_config.3: -------------------------------------------------------------------------------- 1 | .\" Copyright (c) 2007-2015 The OpenRC Authors. 2 | .\" See the Authors file at the top-level directory of this distribution and 3 | .\" https://github.com/OpenRC/openrc/blob/HEAD/AUTHORS 4 | .\" 5 | .\" This file is part of OpenRC. It is subject to the license terms in 6 | .\" the LICENSE file found in the top-level directory of this 7 | .\" distribution and at https://github.com/OpenRC/openrc/blob/HEAD/LICENSE 8 | .\" This file may not be copied, modified, propagated, or distributed 9 | .\" except according to the terms contained in the LICENSE file. 10 | .\" 11 | .Dd Mar 17, 2008 12 | .Dt RC_CONFIG 3 SMM 13 | .Os OpenRC 14 | .Sh NAME 15 | .Nm rc_config_list , rc_config_load , rc_config_value , rc_yesno 16 | .Nd functions to query OpenRC service configurations 17 | .Sh LIBRARY 18 | Run Command library (librc, -lrc) 19 | .Sh SYNOPSIS 20 | .In rc.h 21 | .Ft "RC_STRINGLIST *" Fn rc_config_list "const char *file" 22 | .Ft "RC_STRINGLIST *" Fn rc_config_load "const char *file" 23 | .Ft "char *" Fn rc_config_value "const char *const *list" "const char *entry" 24 | .Ft bool Fn rc_yesno "const char *value" 25 | .Sh DESCRIPTION 26 | These functions provide an easy means of querying OpenRC configuration files. 27 | .Pp 28 | .Fn rc_config_list 29 | returns a list of non comment lines in 30 | .Fa file . 31 | .Fn rc_config_load 32 | does the same, but attempts to parse the line as if it was 33 | a shell assignment. 34 | .Fn rc_config_value 35 | returns the value of 36 | .Fa entry 37 | found in 38 | .Fa list . 39 | .Pp 40 | Each list should be freed using 41 | .Fn rc_stringlist_free 42 | when done. 43 | .Pp 44 | .Fn rc_yesno 45 | returns if 46 | .Fa value 47 | is true, yes, on or 1 regardless of case, otherwise false. 48 | If 49 | .Fa value 50 | is also not false, no, off or 0 regardless of case then 51 | .Va errno 52 | is set to 53 | .Va EINVAL . 54 | .Sh SEE ALSO 55 | .Xr malloc 3 , 56 | .Xr rc_stringlist_free 3 , 57 | .Xr sh 1 58 | .Sh AUTHORS 59 | .An Roy Marples 60 | -------------------------------------------------------------------------------- /man/rc_find_pids.3: -------------------------------------------------------------------------------- 1 | .\" Copyright (c) 2007-2015 The OpenRC Authors. 2 | .\" See the Authors file at the top-level directory of this distribution and 3 | .\" https://github.com/OpenRC/openrc/blob/HEAD/AUTHORS 4 | .\" 5 | .\" This file is part of OpenRC. It is subject to the license terms in 6 | .\" the LICENSE file found in the top-level directory of this 7 | .\" distribution and at https://github.com/OpenRC/openrc/blob/HEAD/LICENSE 8 | .\" This file may not be copied, modified, propagated, or distributed 9 | .\" except according to the terms contained in the LICENSE file. 10 | .\" 11 | .Dd Mar 17, 2008 12 | .Dt RC_FIND_PIDS 3 SMM 13 | .Os OpenRC 14 | .Sh NAME 15 | .Nm rc_find_pids 16 | .Nd finds the pids of processes that match the given criteria 17 | .Sh LIBRARY 18 | Run Command library (librc, -lrc) 19 | .Sh SYNOPSIS 20 | .In rc.h 21 | .Ft "RC_PIDLIST *" Fo rc_find_pids 22 | .Fa "const char *const *argv" 23 | .Fa "const char *cmd" 24 | .Fa "uid_t uid" 25 | .Fa "pid_t pid" 26 | .Fc 27 | .Sh DESCRIPTION 28 | .Fn rc_find_pids 29 | returns RC_PIDLIST, a structure based on the LIST macro from 30 | .Xr queue 3 31 | which contains all the pids found matching the given criteria. 32 | If 33 | .Fa pid 34 | is given then only that pid is returned if it is running. Otherwise we check 35 | all instances of 36 | .Fa argv 37 | with a process name of 38 | .Fa cmd 39 | owned by 40 | .Fa uid , 41 | all of which are optional. 42 | .Pp 43 | The returned list should be freed when done. 44 | .Sh IMPLEMENTATION NOTES 45 | On BSD systems we use 46 | .Lb libkvm 47 | and on Linux systems we use the 48 | .Pa /proc 49 | filesystem to find our processes. 50 | .Pp 51 | Each RC_PID should be freed in the list as well as the list itself when done. 52 | .Sh SEE ALSO 53 | .Xr free 3 , 54 | .Xr queue 3 55 | .Sh AUTHORS 56 | .An Roy Marples 57 | -------------------------------------------------------------------------------- /man/rc_plugin_hook.3: -------------------------------------------------------------------------------- 1 | .\" Copyright (c) 2007-2015 The OpenRC Authors. 2 | .\" See the Authors file at the top-level directory of this distribution and 3 | .\" https://github.com/OpenRC/openrc/blob/HEAD/AUTHORS 4 | .\" 5 | .\" This file is part of OpenRC. It is subject to the license terms in 6 | .\" the LICENSE file found in the top-level directory of this 7 | .\" distribution and at https://github.com/OpenRC/openrc/blob/HEAD/LICENSE 8 | .\" This file may not be copied, modified, propagated, or distributed 9 | .\" except according to the terms contained in the LICENSE file. 10 | .\" 11 | .Dd Mar 16, 2008 12 | .Dt RC_PLUGIN_HOOK 3 SMM 13 | .Os OpenRC 14 | .Sh NAME 15 | .Nm rc_plugin_hook 16 | .Nd hooks plugins into OpenRC services 17 | .Sh LIBRARY 18 | Run Command library (librc, -lrc) 19 | .Sh SYNOPSIS 20 | .In rc.h 21 | .Ft int Fn rc_plugin_hook "RC_HOOK hook" "const char *name" 22 | .Sh DESCRIPTION 23 | .Fn rc_plugin_hook 24 | is called for each shareable object found in 25 | .Pa /lib/rc/plugins . 26 | .Fa hook 27 | is set to the hook running, and 28 | .Fa name 29 | is set to the name of the runlevel or name of the service. 30 | .Pp 31 | Plugins can affect the parent environment by writing NULL separated strings to 32 | .Va rc_environ_fd . 33 | .Sh SEE ALSO 34 | .Xr openrc 8 , 35 | .Xr openrc-run 8 36 | .Sh AUTHORS 37 | .An Roy Marples 38 | -------------------------------------------------------------------------------- /man/rc_runlevel.3: -------------------------------------------------------------------------------- 1 | .\" Copyright (c) 2007-2015 The OpenRC Authors. 2 | .\" See the Authors file at the top-level directory of this distribution and 3 | .\" https://github.com/OpenRC/openrc/blob/HEAD/AUTHORS 4 | .\" 5 | .\" This file is part of OpenRC. It is subject to the license terms in 6 | .\" the LICENSE file found in the top-level directory of this 7 | .\" distribution and at https://github.com/OpenRC/openrc/blob/HEAD/LICENSE 8 | .\" This file may not be copied, modified, propagated, or distributed 9 | .\" except according to the terms contained in the LICENSE file. 10 | .\" 11 | .Dd Mar 16, 2008 12 | .Dt RC_RUNLEVEL 3 SMM 13 | .Os OpenRC 14 | .Sh NAME 15 | .Nm rc_runlevel_get , rc_runlevel_exists , rc_runlevel_list , rc_runlevel_set , 16 | .Nm rc_runlevel_starting , rc_runlevel_stopping 17 | .Nd RC runlevel functions 18 | .Sh LIBRARY 19 | Run Command library (librc, -lrc) 20 | .Sh SYNOPSIS 21 | .In rc.h 22 | .Ft "char *" Fn rc_runlevel_get void 23 | .Ft bool Fn rc_runlevel_exists 24 | .Ft "RC_STRINGLIST *" Fn rc_runlevel_list void 25 | .Ft bool Fn rc_runlevel_set "const char *runlevel" 26 | .Ft bool Fn rc_runlevel_starting void 27 | .Ft bool Fn rc_runlevel_stopping void 28 | .Sh DESCRIPTION 29 | These functions provide a means of querying OpenRC to find out which runlevel 30 | we are in and what services are in which runlevel. 31 | .Sh IMPLEMENTATION NOTES 32 | Each function that returns 33 | .Fr "char *" 34 | returns a malloced NULL terminated string that should be freed when done. 35 | .Pp 36 | Each function that returns 37 | .Fr "RC_STRINGLIST *" 38 | should by freed by calling 39 | .Fn rc_stringlist_free 40 | when done. 41 | .Sh FILES 42 | .Pa /etc/init.d/functions.sh 43 | is provided by OpenRC, which allows shell scripts to use the above functions. 44 | For historical reasons our verbose functions are prefixed with v instead of 45 | suffixed. So einfov becomes veinfo, einfovn becomes veinfon. 46 | Rinse and repeat for the other verbose functions. 47 | .Sh SEE ALSO 48 | .Xr malloc 3 , 49 | .Xr free 3 50 | .Xr rc_stringlist_free 3 51 | .Sh AUTHORS 52 | .An Roy Marples 53 | -------------------------------------------------------------------------------- /meson_options.txt: -------------------------------------------------------------------------------- 1 | option('audit', type : 'feature', value : 'auto', 2 | description : 'enable libaudit support') 3 | option('bash-completions', type : 'boolean', 4 | description : 'install bash completions') 5 | option('branding', type : 'string', 6 | description : 'Add branding to OpenRC') 7 | option('local_prefix', type : 'string', value : '/usr/local', 8 | description : 'default location of user maintained packages') 9 | option('newnet', type : 'boolean', 10 | description : 'build and install our networking scripts') 11 | option('os', type : 'combo', 12 | choices : 13 | [ '', 'DragonFly', 'FreeBSD', 'GNU', 'GNU-kFreeBSD', 'Linux', 'NetBSD' ], 14 | description : 'Operating System (autodetected if not specified)') 15 | option('pam', type : 'boolean', 16 | description : 'enable PAM support') 17 | option('capabilities', type : 'feature', value: 'auto', 18 | description : 'enable capabilities support') 19 | option('pkg_prefix', type : 'string', 20 | description : 'default location where packages are installed') 21 | option('pkgconfig', type : 'boolean', 22 | description : 'build PKGConfig files') 23 | option('rootprefix', type : 'string', 24 | description : 'override the root prefix') 25 | option('selinux', type : 'feature', value : 'auto', 26 | description : 'enable SELinux support') 27 | option('shell', type : 'string', value : '/bin/sh', 28 | description : 'Default posix compatible shell') 29 | option('sysvinit', type : 'boolean', value : false, 30 | description : 'enable SysVinit compatibility (linux only)') 31 | option('zsh-completions', type : 'boolean', 32 | description : 'install zsh completions') 33 | -------------------------------------------------------------------------------- /runit-guide.md: -------------------------------------------------------------------------------- 1 | Using runit with OpenRC 2 | ======================= 3 | 4 | Beginning with OpenRC-0.21, we support using runit [1] in place of 5 | start-stop-daemon for monitoring and restarting daemons. 6 | 7 | ## Setup 8 | 9 | Documenting runit in detail is beyond the scope of this guide. It will 10 | document how to set up OpenRC services to communicate with runit. 11 | 12 | ### Use Default start, stop and status functions 13 | 14 | If you write your own start, stop and status functions in your service 15 | script, none of this will work. You must allow OpenRC to use the default 16 | functions. 17 | 18 | ### Dependencies 19 | 20 | All OpenRC service scripts that want their daemons monitored by runit 21 | should have the following line added to their dependencies to make sure 22 | the runit scan directory is being monitored. 23 | 24 | need runsvdir 25 | 26 | ### Variable Settings 27 | 28 | The most important setting is the supervisor variable. At the top of 29 | your service script, you should set this variable as follows: 30 | 31 | supervisor=runit 32 | 33 | The second variable you need is runit_service. This is the path to the 34 | runit service you wish to control via OpenRC. The default is 35 | /etc/sv/${RC_SVCNAME}. This means that for an OpenRC service 36 | /etc/init.d/foo, you will need to create the same runit service in 37 | /etc/sv/foo. 38 | 39 | This is very early support, so feel free to file bugs if you have 40 | issues. 41 | 42 | [1] http://www.smarden.org/runit 43 | -------------------------------------------------------------------------------- /s6-guide.md: -------------------------------------------------------------------------------- 1 | Using S6 with OpenRC 2 | ==================== 3 | 4 | Beginning with OpenRC-0.16, we support using the s6 supervision suite 5 | from Skarnet Software in place of start-stop-daemon for monitoring 6 | daemons [1]. 7 | 8 | ## Setup 9 | 10 | Documenting s6 in detail is beyond the scope of this guide. It will 11 | document how to set up OpenRC services to communicate with s6. 12 | 13 | ### Use Default start, stop and status functions 14 | 15 | If you write your own start, stop and status functions in your service 16 | script, none of this will work. You must allow OpenRC to use the default 17 | functions. 18 | 19 | ### Dependencies 20 | 21 | All OpenRC service scripts that want their daemons monitored by s6 22 | should have the following line added to their dependencies to make sure 23 | the s6 scan directory is being monitored. 24 | 25 | need s6-svscan 26 | 27 | ### Variable Settings 28 | 29 | The most important setting is the supervisor variable. At the top of 30 | your service script, you should set this variable as follows: 31 | 32 | supervisor=s6 33 | 34 | Several other variables affect s6 services. They are documented on the 35 | openrc-run man page, but I will list them here for convenience: 36 | 37 | s6_service_path - the path to the s6 service directory. The default is 38 | /var/svc.d/$RC_SVCNAME. 39 | 40 | s6_svwait_options_start - the options to pass to s6-svwait when starting 41 | the service. If this is not set, s6-svwait will not be called. 42 | 43 | s6_force_kill - Should we try to force kill this service if the 44 | s6_service_timeout_stop timeout expires when shutting down this service? 45 | The default is yes. 46 | 47 | s6_service_timeout_stop - the amount of time, in milliseconds, s6-svc 48 | should wait for a service to go down when stopping. 49 | 50 | This is very early support, so feel free to file bugs if you have 51 | issues. 52 | 53 | [1] http://www.skarnet.org/software/s6 54 | -------------------------------------------------------------------------------- /sh/cgroup-release-agent.sh.in: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # This is run by the kernel after the last task is removed from a 3 | # control group in the openrc hierarchy. 4 | 5 | # Copyright (c) 2007-2015 The OpenRC Authors. 6 | # See the Authors file at the top-level directory of this distribution and 7 | # https://github.com/OpenRC/openrc/blob/HEAD/AUTHORS 8 | # 9 | # This file is part of OpenRC. It is subject to the license terms in 10 | # the LICENSE file found in the top-level directory of this 11 | # distribution and at https://github.com/OpenRC/openrc/blob/HEAD/LICENSE 12 | # This file may not be copied, modified, propagated, or distributed 13 | # except according to the terms contained in the LICENSE file. 14 | 15 | cgroup=/sys/fs/cgroup/openrc 16 | PATH=/bin:/usr/bin:/sbin:/usr/sbin 17 | if [ -d ${cgroup}/"$1" ]; then 18 | rmdir ${cgroup}/"$1" 19 | fi 20 | -------------------------------------------------------------------------------- /sh/init.sh.GNU-kFreeBSD.in: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Copyright (c) 2007-2015 The OpenRC Authors. 3 | # See the Authors file at the top-level directory of this distribution and 4 | # https://github.com/OpenRC/openrc/blob/HEAD/AUTHORS 5 | # 6 | # This file is part of OpenRC. It is subject to the license terms in 7 | # the LICENSE file found in the top-level directory of this 8 | # distribution and at https://github.com/OpenRC/openrc/blob/HEAD/LICENSE 9 | # This file may not be copied, modified, propagated, or distributed 10 | # except according to the terms contained in the LICENSE file. 11 | 12 | if [ ! -d /run ]; then 13 | ebegin "Creating /run" 14 | mkdir -p /run 15 | eend $? 16 | fi 17 | 18 | if [ -L $RC_SVCDIR ]; then 19 | rm $RC_SVCDIR 20 | fi 21 | 22 | ebegin "Mounting /run" 23 | if ! fstabinfo --mount /run; then 24 | mount -t tmpfs -o mode=0755,noexec,nosuid,size=10% tmpfs /run 25 | if [ $? != 0 ]; then 26 | eerror "Unable to mount tmpfs on /run." 27 | eerror "Can't continue." 28 | exit 1 29 | fi 30 | fi 31 | eend 32 | 33 | ebegin "Creating $RC_SVCDIR" 34 | mkdir -p $RC_SVCDIR 35 | eend $? 36 | 37 | if [ -e "$RC_LIBEXECDIR"/cache/softlevel ]; then 38 | cp -p "$RC_LIBEXECDIR"/cache/* "$RC_SVCDIR" 2>/dev/null 39 | fi 40 | 41 | echo sysinit >"$RC_SVCDIR"/softlevel 42 | exit 0 43 | -------------------------------------------------------------------------------- /sh/init.sh.GNU.in: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Copyright (c) 2007-2015 The OpenRC Authors. 3 | # See the Authors file at the top-level directory of this distribution and 4 | # https://github.com/OpenRC/openrc/blob/HEAD/AUTHORS 5 | # 6 | # This file is part of OpenRC. It is subject to the license terms in 7 | # the LICENSE file found in the top-level directory of this 8 | # distribution and at https://github.com/OpenRC/openrc/blob/HEAD/LICENSE 9 | # This file may not be copied, modified, propagated, or distributed 10 | # except according to the terms contained in the LICENSE file. 11 | 12 | if [ ! -d /run ]; then 13 | ebegin "Creating /run" 14 | mkdir -p /run 15 | eend $? 16 | fi 17 | 18 | if [ -L $RC_SVCDIR ]; then 19 | rm $RC_SVCDIR 20 | fi 21 | 22 | if ! mountinfo -q /run; then 23 | ebegin "Mounting /run" 24 | if ! fstabinfo --mount /run; then 25 | mount -t tmpfs -o mode=0755,no-suid,size=10% tmpfs /run 26 | if [ $? != 0 ]; then 27 | eerror "Unable to mount tmpfs on /run." 28 | eerror "Can't continue." 29 | exit 1 30 | fi 31 | fi 32 | eend 33 | fi 34 | 35 | ebegin "Creating $RC_SVCDIR" 36 | mkdir -p $RC_SVCDIR 37 | eend $? 38 | 39 | if [ -e "$RC_LIBEXECDIR"/cache/softlevel ]; then 40 | cp -p "$RC_LIBEXECDIR"/cache/* "$RC_SVCDIR" 2>/dev/null 41 | fi 42 | 43 | echo sysinit >"$RC_SVCDIR"/softlevel 44 | exit 0 45 | -------------------------------------------------------------------------------- /sh/user-init.sh.in: -------------------------------------------------------------------------------- 1 | #!@SHELL@ 2 | 3 | . @LIBEXECDIR@/sh/functions.sh 4 | 5 | sourcex() 6 | { 7 | if [ "$1" = "-e" ]; then 8 | shift 9 | [ -e "$1" ] || return 1 10 | fi 11 | if ! . "$1"; then 12 | eerror "$RC_SVCNAME: error loading $1" 13 | exit 1 14 | fi 15 | } 16 | 17 | _sysconf="${XDG_CONFIG_HOME:-${HOME}/.config}/openrc" 18 | 19 | sourcex -e "@SYSCONFDIR@/rc.conf" 20 | sourcex -e "$_sysconf/rc.conf" 21 | 22 | case $1 in 23 | start) _runlevel="${rc_user_runlevel:-default}";; 24 | stop) _runlevel="${rc_user_shutdown_runlevel:-none}";; 25 | *) eerror "no argument given to $0"r exit 1 26 | esac 27 | 28 | mkdir -p "$_sysconf/runlevels/$_runlevel" 29 | 30 | openrc --user "$_runlevel" 31 | -------------------------------------------------------------------------------- /src/checkpath/meson.build: -------------------------------------------------------------------------------- 1 | executable('checkpath', 2 | ['checkpath.c', misc_c, usage_c, selinux_c, 3 | version_h], 4 | c_args : [cc_audit_flags, cc_branding_flags, cc_pam_flags, cc_selinux_flags], 5 | include_directories: [incdir, einfo_incdir, rc_incdir], 6 | link_with: [libeinfo, librc], 7 | dependencies: [audit_dep, pam_dep, pam_misc_dep, selinux_dep, crypt_dep], 8 | install: true, 9 | install_dir: rc_bindir) 10 | -------------------------------------------------------------------------------- /src/einfo/meson.build: -------------------------------------------------------------------------------- 1 | einfo_execs = [ 2 | 'einfon', 3 | 'einfo', 4 | 'ewarnn', 5 | 'ewarn', 6 | 'eerrorn', 7 | 'eerror', 8 | 'ebegin', 9 | 'eend', 10 | 'ewend', 11 | 'eindent', 12 | 'eoutdent', 13 | 'esyslog', 14 | 'eval_ecolors', 15 | 'ewaitfile', 16 | 'veinfo', 17 | 'vewarn', 18 | 'vebegin', 19 | 'veend', 20 | 'vewend', 21 | 'veindent', 22 | 'veoutdent', 23 | ] 24 | 25 | foreach exec: einfo_execs 26 | executable(exec, 27 | ['einfo.c', version_h], 28 | include_directories: [incdir, einfo_incdir, rc_incdir], 29 | link_with: [libeinfo, librc], 30 | install: true, 31 | install_dir: rc_bindir) 32 | endforeach 33 | -------------------------------------------------------------------------------- /src/fstabinfo/meson.build: -------------------------------------------------------------------------------- 1 | executable('fstabinfo', 2 | ['fstabinfo.c', misc_c, usage_c, version_h], 3 | c_args : cc_branding_flags, 4 | include_directories: [incdir, einfo_incdir, rc_incdir], 5 | link_with: [libeinfo, librc], 6 | install: true, 7 | install_dir: rc_bindir) 8 | -------------------------------------------------------------------------------- /src/halt/halt.in: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | option_arg= 4 | poweroff_arg= 5 | while getopts :nwdfiph opt; do 6 | case "$opt" in 7 | n) ;; 8 | w) poweroff_arg=--write-only ;; 9 | d) option_arg=--no-write ;; 10 | f) ;; 11 | i) ;; 12 | p) poweroff_arg=--poweroff ;; 13 | [?]) printf "%s\n" "${0##*/}: invalid command line option" >&2 14 | exit 1 15 | ;; 16 | esac 17 | done 18 | shift $((OPTIND-1)) 19 | 20 | if [ -z "${poweroff_arg}" ]; then 21 | poweroff_arg=--poweroff 22 | fi 23 | 24 | script_args="$@" 25 | if [ -z "${script_args}" ]; then 26 | script_args=now 27 | fi 28 | 29 | exec @SBINDIR@/openrc-shutdown ${option_arg} ${poweroff_arg} "${script_args}" 30 | -------------------------------------------------------------------------------- /src/halt/meson.build: -------------------------------------------------------------------------------- 1 | if os == 'Linux' and get_option('sysvinit') 2 | configure_file(input : 'halt.in', 3 | output : '@BASENAME@', 4 | configuration : script_conf_data, 5 | install_dir: sbindir, 6 | install_mode: 'rwxr-xr-x') 7 | endif 8 | -------------------------------------------------------------------------------- /src/is_newer_than/is_newer_than.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 The OpenRC Authors. 3 | * See the Authors file at the top-level directory of this distribution and 4 | * https://github.com/OpenRC/openrc/blob/HEAD/AUTHORS 5 | * 6 | * This file is part of OpenRC. It is subject to the license terms in 7 | * the LICENSE file found in the top-level directory of this 8 | * distribution and at https://github.com/OpenRC/openrc/blob/HEAD/LICENSE 9 | * This file may not be copied, modified, propagated, or distributed 10 | * except according to the terms contained in the LICENSE file. 11 | */ 12 | 13 | #include 14 | 15 | #include "rc.h" 16 | 17 | int main(int argc, char **argv) 18 | { 19 | int i; 20 | 21 | if (argc < 3) 22 | return EXIT_FAILURE; 23 | 24 | /* This test is correct as it's not present in baselayout */ 25 | for (i = 2; i < argc; ++i) 26 | if (!rc_newer_than(argv[1], argv[i], NULL, NULL)) 27 | return EXIT_FAILURE; 28 | 29 | return EXIT_SUCCESS; 30 | } 31 | -------------------------------------------------------------------------------- /src/is_newer_than/meson.build: -------------------------------------------------------------------------------- 1 | executable('is_newer_than', 2 | ['is_newer_than.c', misc_c, version_h], 3 | include_directories: [incdir, einfo_incdir, rc_incdir], 4 | link_with: [libeinfo, librc], 5 | install: true, 6 | install_dir: rc_bindir) 7 | -------------------------------------------------------------------------------- /src/is_older_than/is_older_than.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 The OpenRC Authors. 3 | * See the Authors file at the top-level directory of this distribution and 4 | * https://github.com/OpenRC/openrc/blob/HEAD/AUTHORS 5 | * 6 | * This file is part of OpenRC. It is subject to the license terms in 7 | * the LICENSE file found in the top-level directory of this 8 | * distribution and at https://github.com/OpenRC/openrc/blob/HEAD/LICENSE 9 | * This file may not be copied, modified, propagated, or distributed 10 | * except according to the terms contained in the LICENSE file. 11 | */ 12 | 13 | #include 14 | 15 | #include "rc.h" 16 | 17 | int main(int argc, char **argv) 18 | { 19 | int i; 20 | 21 | if (argc < 3) 22 | return EXIT_FAILURE; 23 | 24 | /* This test is perverted - historically the baselayout function 25 | * returns 0 on *failure*, which is plain wrong */ 26 | for (i = 2; i < argc; ++i) 27 | if (!rc_newer_than(argv[1], argv[i], NULL, NULL)) 28 | return EXIT_SUCCESS; 29 | 30 | return EXIT_FAILURE; 31 | } 32 | -------------------------------------------------------------------------------- /src/is_older_than/meson.build: -------------------------------------------------------------------------------- 1 | executable('is_older_than', 2 | ['is_older_than.c', misc_c, version_h], 3 | include_directories: [incdir, einfo_incdir, rc_incdir], 4 | link_with: [libeinfo, librc], 5 | install: true, 6 | install_dir: rc_bindir) 7 | -------------------------------------------------------------------------------- /src/kill_all/meson.build: -------------------------------------------------------------------------------- 1 | if os == 'Linux' 2 | executable('kill_all', 3 | ['kill_all.c', usage_c, version_h], 4 | c_args : cc_branding_flags, 5 | include_directories: [incdir, einfo_incdir, rc_incdir], 6 | link_with: [libeinfo,librc], 7 | install: true, 8 | install_dir: rc_bindir) 9 | endif 10 | -------------------------------------------------------------------------------- /src/libeinfo/einfo.map: -------------------------------------------------------------------------------- 1 | EINFO_1.0 { 2 | global: 3 | ecolor; 4 | elog; 5 | einfon; 6 | ewarnn; 7 | eerrorn; 8 | einfo; 9 | ewarn; 10 | ewarnx; 11 | eerror; 12 | eerrorx; 13 | einfovn; 14 | ewarnvn; 15 | ebeginvn; 16 | eendvn; 17 | ewendvn; 18 | einfov; 19 | ewarnv; 20 | ebeginv; 21 | ebegin; 22 | eend; 23 | ewend; 24 | ebracket; 25 | eendv; 26 | ewendv; 27 | eindent; 28 | eoutdent; 29 | eindentv; 30 | eoutdentv; 31 | eprefix; 32 | 33 | local: 34 | *; 35 | }; 36 | -------------------------------------------------------------------------------- /src/libeinfo/meson.build: -------------------------------------------------------------------------------- 1 | libeinfo_version = '1' 2 | 3 | libeinfo = library('einfo', ['libeinfo.c'], 4 | include_directories : incdir, 5 | link_depends : 'einfo.map', 6 | version : libeinfo_version, 7 | install : true, 8 | install_dir : libdir) 9 | 10 | install_headers('einfo.h') 11 | -------------------------------------------------------------------------------- /src/librc/librc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * librc.h 3 | * Internal header file to setup build env for files in librc.so 4 | */ 5 | 6 | /* 7 | * Copyright (c) 2007-2015 The OpenRC Authors. 8 | * See the Authors file at the top-level directory of this distribution and 9 | * https://github.com/OpenRC/openrc/blob/HEAD/AUTHORS 10 | * 11 | * This file is part of OpenRC. It is subject to the license terms in 12 | * the LICENSE file found in the top-level directory of this 13 | * distribution and at https://github.com/OpenRC/openrc/blob/HEAD/LICENSE 14 | * This file may not be copied, modified, propagated, or distributed 15 | * except according to the terms contained in the LICENSE file. 16 | */ 17 | 18 | #ifndef _LIBRC_H_ 19 | #define _LIBRC_H_ 20 | 21 | #define _IN_LIBRC 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | 46 | #if defined(BSD) && !defined(__GNU__) 47 | #include 48 | #include 49 | #include 50 | #include 51 | #else 52 | #include 53 | #endif 54 | 55 | #include "rc.h" 56 | #include "misc.h" 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /src/librc/meson.build: -------------------------------------------------------------------------------- 1 | rc_h_conf_data = configuration_data() 2 | if rootprefix == '/' 3 | rc_h_conf_data.set('PREFIX', '') 4 | else 5 | rc_h_conf_data.set('PREFIX', rootprefix) 6 | endif 7 | rc_h_conf_data.set('LIB', libname) 8 | rc_h_conf_data.set('LIBEXECDIR', rc_libexecdir) 9 | rc_h_conf_data.set('LOCAL_PREFIX', local_prefix) 10 | rc_h_conf_data.set('PKG_PREFIX', pkg_prefix) 11 | rc_h_conf_data.set('SYSCONFDIR', get_option('sysconfdir')) 12 | 13 | librc_version = '1' 14 | 15 | librc_sources = [ 16 | 'librc.c', 17 | 'librc-daemon.c', 18 | 'librc-depend.c', 19 | 'librc-misc.c', 20 | 'librc-stringlist.c', 21 | ] 22 | 23 | rc_h = configure_file(input : 'rc.h.in', output : 'rc.h', 24 | configuration : rc_h_conf_data) 25 | 26 | librc = library('rc', librc_sources, 27 | dependencies: kvm_dep, 28 | include_directories : [incdir, einfo_incdir], 29 | link_depends : 'rc.map', 30 | link_with : libeinfo, 31 | version : librc_version, 32 | install : true, 33 | install_dir : libdir) 34 | 35 | install_headers(rc_h) 36 | -------------------------------------------------------------------------------- /src/librc/rc.map: -------------------------------------------------------------------------------- 1 | RC_1.0 { 2 | global: 3 | rc_conf_value; 4 | rc_config_list; 5 | rc_config_load; 6 | rc_config_value; 7 | rc_deptree_depend; 8 | rc_deptree_depends; 9 | rc_deptree_free; 10 | rc_deptree_load; 11 | rc_deptree_load_file; 12 | rc_deptree_order; 13 | rc_deptree_update; 14 | rc_deptree_update_needed; 15 | rc_environ_fd; 16 | rc_find_pids; 17 | rc_getfile; 18 | rc_getline; 19 | rc_newer_than; 20 | rc_older_than; 21 | rc_proc_getent; 22 | rc_runlevel_exists; 23 | rc_runlevel_get; 24 | rc_runlevel_list; 25 | rc_runlevel_set; 26 | rc_runlevel_stack; 27 | rc_runlevel_stacks; 28 | rc_runlevel_starting; 29 | rc_runlevel_stopping; 30 | rc_runlevel_unstack; 31 | rc_service_add; 32 | rc_service_daemons_crashed; 33 | rc_service_daemon_set; 34 | rc_service_delete; 35 | rc_service_description; 36 | rc_service_exists; 37 | rc_service_extra_commands; 38 | rc_service_in_runlevel; 39 | rc_service_mark; 40 | rc_service_options; 41 | rc_service_resolve; 42 | rc_service_schedule_clear; 43 | rc_service_schedule_start; 44 | rc_services_in_runlevel; 45 | rc_services_in_runlevel_stacked; 46 | rc_services_in_state; 47 | rc_services_scheduled; 48 | rc_services_scheduled_by; 49 | rc_service_started_daemon; 50 | rc_service_state; 51 | rc_service_value_get; 52 | rc_service_value_set; 53 | rc_stringlist_add; 54 | rc_stringlist_addu; 55 | rc_stringlist_delete; 56 | rc_stringlist_find; 57 | rc_stringlist_split; 58 | rc_stringlist_new; 59 | rc_stringlist_sort; 60 | rc_stringlist_free; 61 | rc_sys; 62 | rc_yesno; 63 | 64 | local: 65 | *; 66 | }; 67 | -------------------------------------------------------------------------------- /src/mark_service/meson.build: -------------------------------------------------------------------------------- 1 | mark_service_execs = [ 2 | 'mark_service_starting', 3 | 'mark_service_started', 4 | 'mark_service_stopping', 5 | 'mark_service_stopped', 6 | 'mark_service_inactive', 7 | 'mark_service_wasinactive', 8 | 'mark_service_hotplugged', 9 | 'mark_service_failed', 10 | 'mark_service_crashed', 11 | ] 12 | 13 | foreach exec : mark_service_execs 14 | executable(exec, 15 | ['mark_service.c', misc_c, version_h], 16 | include_directories: [incdir, einfo_incdir, rc_incdir], 17 | link_with: [libeinfo,librc], 18 | install: true, 19 | install_dir: rc_sbindir) 20 | endforeach 21 | -------------------------------------------------------------------------------- /src/meson.build: -------------------------------------------------------------------------------- 1 | script_conf_data = configuration_data() 2 | script_conf_data.set('SBINDIR', sbindir) 3 | 4 | subdir('shared') 5 | subdir('libeinfo') 6 | subdir('librc') 7 | subdir('checkpath') 8 | subdir('einfo') 9 | subdir('fstabinfo') 10 | subdir('halt') 11 | subdir('is_newer_than') 12 | subdir('is_older_than') 13 | subdir('kill_all') 14 | subdir('mark_service') 15 | subdir('mountinfo') 16 | subdir('on_ac_power') 17 | subdir('openrc') 18 | subdir('openrc-init') 19 | subdir('openrc-run') 20 | subdir('openrc-shutdown') 21 | subdir('openrc-pam') 22 | subdir('poweroff') 23 | subdir('rc-abort') 24 | subdir('rc-depend') 25 | subdir('rc-service') 26 | subdir('rc-sstat') 27 | subdir('rc-status') 28 | subdir('rc-update') 29 | subdir('reboot') 30 | subdir('service') 31 | subdir('seedrng') 32 | subdir('shell_var') 33 | subdir('shutdown') 34 | subdir('start-stop-daemon') 35 | subdir('supervise-daemon') 36 | subdir('swclock') 37 | subdir('value') 38 | subdir('user_init') 39 | -------------------------------------------------------------------------------- /src/mountinfo/meson.build: -------------------------------------------------------------------------------- 1 | executable('mountinfo', 2 | ['mountinfo.c', misc_c, usage_c, version_h], 3 | c_args : cc_branding_flags, 4 | include_directories: [incdir, einfo_incdir, rc_incdir], 5 | link_with: [libeinfo, librc], 6 | install: true, 7 | install_dir: rc_bindir) 8 | -------------------------------------------------------------------------------- /src/on_ac_power/meson.build: -------------------------------------------------------------------------------- 1 | install_data('on_ac_power', 2 | install_dir : rc_bindir, 3 | install_mode: 'rwxr-xr-x') 4 | -------------------------------------------------------------------------------- /src/on_ac_power/on_ac_power: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Detect AC power or not in a portable way 3 | # Exit 0 if on AC power, 1 if not and 255 if we don't know how to work it out 4 | 5 | # Copyright (c) 2007-2015 The OpenRC Authors. 6 | # See the Authors file at the top-level directory of this distribution and 7 | # https://github.com/OpenRC/openrc/blob/HEAD/AUTHORS 8 | # 9 | # This file is part of OpenRC. It is subject to the license terms in 10 | # the LICENSE file found in the top-level directory of this 11 | # distribution and at https://github.com/OpenRC/openrc/blob/HEAD/LICENSE 12 | # This file may not be copied, modified, propagated, or distributed 13 | # except according to the terms contained in the LICENSE file. 14 | 15 | if [ -f /proc/acpi/ac_adapter/*/state ]; then 16 | cat /proc/acpi/ac_adapter/*/state | while read line; do 17 | case "$line" in 18 | "state:"*"off-line") exit 128;; 19 | esac 20 | done 21 | elif [ -d /sys/class/power_supply ]; then 22 | for dir in /sys/class/power_supply/*/; do 23 | [ "$(cat "${dir}/type")" != "Mains" ] && continue 24 | [ "$(cat "${dir}/online")" = 0 ] && exit 128 25 | done 26 | elif [ -f /proc/pmu/info ]; then 27 | cat /proc/pmu/info | while read line; do 28 | case "$line" in 29 | "AC Power"*": 0") exit 128;; 30 | esac 31 | done 32 | elif command -v envstat >/dev/null 2>&1; then 33 | # NetBSD has envstat 34 | envstat -d acpiacad0 2>/dev/null | while read line; do 35 | case "$line" in 36 | "connected:"*"OFF") exit 128;; 37 | esac 38 | done 39 | elif sysctl -q hw.acpi.acline >/dev/null 2>/dev/null; then 40 | case $(sysctl -n hw.acpi.acline) in 41 | 0) exit 1;; 42 | *) exit 0;; 43 | esac 44 | else 45 | exit 255 46 | fi 47 | [ $? != 128 ] 48 | -------------------------------------------------------------------------------- /src/openrc-init/meson.build: -------------------------------------------------------------------------------- 1 | if os == 'Linux' 2 | executable('openrc-init', 3 | ['openrc-init.c', plugin_c, wtmp_c, version_h], 4 | c_args : cc_selinux_flags, 5 | include_directories: [incdir, einfo_incdir, rc_incdir], 6 | link_with: [libeinfo, librc], 7 | dependencies: [dl_dep, selinux_dep], 8 | install: true, 9 | install_dir: sbindir) 10 | endif 11 | -------------------------------------------------------------------------------- /src/openrc-pam/meson.build: -------------------------------------------------------------------------------- 1 | if get_option('pam') and pam_dep.found() 2 | shared_module('pam_openrc', 3 | ['openrc-pam.c', misc_c, version_h], 4 | c_args : [cc_branding_flags], 5 | dependencies : [pam_dep], 6 | name_prefix : '', 7 | link_with : [libeinfo, librc], 8 | include_directories : [incdir, einfo_incdir, rc_incdir], 9 | install : true, 10 | install_dir : libdir / 'security') 11 | endif 12 | -------------------------------------------------------------------------------- /src/openrc-run/meson.build: -------------------------------------------------------------------------------- 1 | executable('openrc-run', 2 | ['openrc-run.c', misc_c, plugin_c, selinux_c, usage_c, version_h], 3 | c_args : [cc_audit_flags, cc_branding_flags, cc_pam_flags, cc_selinux_flags], 4 | link_with: [libeinfo, librc], 5 | dependencies: [audit_dep, dl_dep, pam_dep, pam_misc_dep, selinux_dep, util_dep, crypt_dep], 6 | include_directories: [incdir, einfo_incdir, rc_incdir], 7 | install: true, 8 | install_dir: sbindir) 9 | -------------------------------------------------------------------------------- /src/openrc-shutdown/broadcast.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Sony Interactive Entertainment Inc. 3 | * 4 | * This file is part of OpenRC. It is subject to the license terms in 5 | * the LICENSE file found in the top-level directory of this 6 | * distribution and at https://github.com/OpenRC/openrc/blob/HEAD/LICENSE 7 | * This file may not be copied, modified, propagated, or distributed 8 | * except according to the terms contained in the LICENSE file. 9 | */ 10 | 11 | #ifndef BROADCAST_H 12 | #define BROADCAST_H 13 | 14 | void broadcast(char *text); 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /src/openrc-shutdown/meson.build: -------------------------------------------------------------------------------- 1 | if os == 'Linux' 2 | executable('openrc-shutdown', 3 | ['openrc-shutdown.c', 'broadcast.c', 'sysvinit.c', misc_c, 4 | usage_c, wtmp_c, version_h], 5 | c_args : cc_branding_flags, 6 | include_directories: [incdir, einfo_incdir, rc_incdir], 7 | link_with: [libeinfo, librc], 8 | install: true, 9 | install_dir: sbindir) 10 | endif 11 | -------------------------------------------------------------------------------- /src/openrc/meson.build: -------------------------------------------------------------------------------- 1 | executable('openrc', 2 | ['rc.c', 'rc-logger.c', misc_c, plugin_c, usage_c, version_h], 3 | c_args : cc_branding_flags, 4 | link_with: [libeinfo, librc], 5 | dependencies: [dl_dep, util_dep], 6 | include_directories: [incdir, einfo_incdir, rc_incdir], 7 | install: true, 8 | install_dir: sbindir) 9 | -------------------------------------------------------------------------------- /src/openrc/rc-logger.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2007-2015 The OpenRC Authors. 3 | * See the Authors file at the top-level directory of this distribution and 4 | * https://github.com/OpenRC/openrc/blob/HEAD/AUTHORS 5 | * 6 | * This file is part of OpenRC. It is subject to the license terms in 7 | * the LICENSE file found in the top-level directory of this 8 | * distribution and at https://github.com/OpenRC/openrc/blob/HEAD/LICENSE 9 | * This file may not be copied, modified, propagated, or distributed 10 | * except according to the terms contained in the LICENSE file. 11 | */ 12 | 13 | #ifndef RC_LOGGER_H 14 | #define RC_LOGGER_H 15 | 16 | #include 17 | #include 18 | 19 | extern pid_t rc_logger_pid; 20 | extern int rc_logger_tty; 21 | extern bool rc_in_logger; 22 | 23 | void rc_logger_open(const char *runlevel); 24 | void rc_logger_close(void); 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /src/poweroff/meson.build: -------------------------------------------------------------------------------- 1 | if os == 'Linux' and get_option('sysvinit') 2 | configure_file(input : 'poweroff.in', 3 | output : '@BASENAME@', 4 | configuration : script_conf_data, 5 | install_dir: sbindir, 6 | install_mode: 'rwxr-xr-x') 7 | endif 8 | -------------------------------------------------------------------------------- /src/poweroff/poweroff.in: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | option_arg= 4 | poweroff_arg= 5 | while getopts :nwdfiph opt; do 6 | case "$opt" in 7 | n) ;; 8 | w) poweroff_arg=--write-only ;; 9 | d) option_arg=--no-write ;; 10 | f) ;; 11 | i) ;; 12 | [?]) printf "%s\n" "${0##*/}: invalid command line option" >&2 13 | exit 1 14 | ;; 15 | esac 16 | done 17 | shift $((OPTIND-1)) 18 | 19 | if [ -z "${poweroff_arg}" ]; then 20 | poweroff_arg=--poweroff 21 | fi 22 | 23 | script_args="$@" 24 | if [ -z "${script_args}" ]; then 25 | script_args=now 26 | fi 27 | 28 | exec @SBINDIR@/openrc-shutdown ${option_arg} ${poweroff_arg} "${script_args}" 29 | -------------------------------------------------------------------------------- /src/rc-abort/meson.build: -------------------------------------------------------------------------------- 1 | executable('rc-abort', 2 | 'rc-abort.c', 3 | include_directories: [einfo_incdir], 4 | link_with: [libeinfo], 5 | install: true, 6 | install_dir: rc_sbindir) 7 | -------------------------------------------------------------------------------- /src/rc-abort/rc-abort.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2007-2015 The OpenRC Authors. 3 | * See the Authors file at the top-level directory of this distribution and 4 | * https://github.com/OpenRC/openrc/blob/HEAD/AUTHORS 5 | * 6 | * This file is part of OpenRC. It is subject to the license terms in 7 | * the LICENSE file found in the top-level directory of this 8 | * distribution and at https://github.com/OpenRC/openrc/blob/HEAD/LICENSE 9 | * This file may not be copied, modified, propagated, or distributed 10 | * except according to the terms contained in the LICENSE file. 11 | */ 12 | 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | #include "einfo.h" 20 | 21 | int main(void) 22 | { 23 | const char *p = getenv("RC_PID"); 24 | int pid; 25 | 26 | if (p && sscanf(p, "%d", &pid) == 1) { 27 | if (kill(pid, SIGUSR1) != 0) 28 | eerrorx("rc-abort: failed to signal parent %d: %s", 29 | pid, strerror(errno)); 30 | return EXIT_SUCCESS; 31 | } 32 | 33 | return EXIT_FAILURE; 34 | } 35 | -------------------------------------------------------------------------------- /src/rc-depend/meson.build: -------------------------------------------------------------------------------- 1 | executable('rc-depend', 2 | ['rc-depend.c', misc_c, usage_c, version_h], 3 | c_args : cc_branding_flags, 4 | include_directories: [incdir, einfo_incdir, rc_incdir], 5 | link_with: [libeinfo, librc], 6 | install: true, 7 | install_dir: rc_bindir) 8 | -------------------------------------------------------------------------------- /src/rc-service/meson.build: -------------------------------------------------------------------------------- 1 | executable('rc-service', 2 | ['rc-service.c', misc_c, usage_c, version_h], 3 | c_args : cc_branding_flags, 4 | link_with: [libeinfo, librc], 5 | include_directories: [incdir, einfo_incdir, rc_incdir], 6 | install: true, 7 | install_dir: sbindir) 8 | -------------------------------------------------------------------------------- /src/rc-sstat/meson.build: -------------------------------------------------------------------------------- 1 | if os == 'Linux' 2 | install_data('rc-sstat', 3 | install_dir: sbindir, 4 | install_mode: 'rwxr-xr-x') 5 | endif 6 | -------------------------------------------------------------------------------- /src/rc-status/meson.build: -------------------------------------------------------------------------------- 1 | executable('rc-status', 2 | ['rc-status.c', misc_c, usage_c, version_h], 3 | c_args : cc_branding_flags, 4 | link_with: [libeinfo, librc], 5 | dependencies: [util_dep], 6 | include_directories: [incdir, einfo_incdir, rc_incdir], 7 | install: true, 8 | install_dir: bindir) 9 | -------------------------------------------------------------------------------- /src/rc-update/meson.build: -------------------------------------------------------------------------------- 1 | executable('rc-update', 2 | ['rc-update.c', misc_c, usage_c, version_h], 3 | c_args : cc_branding_flags, 4 | link_with: [libeinfo, librc], 5 | include_directories: [incdir, einfo_incdir, rc_incdir], 6 | install: true, 7 | install_dir: sbindir) 8 | -------------------------------------------------------------------------------- /src/reboot/meson.build: -------------------------------------------------------------------------------- 1 | if os == 'Linux' and get_option('sysvinit') 2 | configure_file(input : 'reboot.in', 3 | output : '@BASENAME@', 4 | configuration : script_conf_data, 5 | install_dir: sbindir, 6 | install_mode: 'rwxr-xr-x') 7 | endif 8 | -------------------------------------------------------------------------------- /src/reboot/reboot.in: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | option_arg= 4 | poweroff_arg= 5 | while getopts :nwdfhik opt; do 6 | case "$opt" in 7 | n) ;; 8 | w) poweroff_arg=--write-only ;; 9 | d) option_arg=--no-write ;; 10 | f) ;; 11 | h) ;; 12 | i) ;; 13 | k) poweroff_arg=--kexec ;; 14 | [?]) printf "%s\n" "${0##*/}: invalid command line option" >&2 15 | exit 1 16 | ;; 17 | esac 18 | done 19 | shift $((OPTIND-1)) 20 | 21 | if [ -z "${poweroff_arg}" ]; then 22 | poweroff_arg=--reboot 23 | fi 24 | 25 | script_args="$@" 26 | if [ -z "${script_args}" ]; then 27 | script_args=now 28 | fi 29 | 30 | exec @SBINDIR@/openrc-shutdown ${option_arg} ${poweroff_arg} "${script_args}" 31 | -------------------------------------------------------------------------------- /src/seedrng/meson.build: -------------------------------------------------------------------------------- 1 | if os == 'Linux' 2 | executable('seedrng', 3 | ['seedrng.c', usage_c, version_h], 4 | c_args : cc_branding_flags, 5 | include_directories: [incdir, einfo_incdir, rc_incdir], 6 | link_with: [libeinfo, librc], 7 | install: true, 8 | install_dir: rc_sbindir) 9 | endif 10 | -------------------------------------------------------------------------------- /src/service/meson.build: -------------------------------------------------------------------------------- 1 | service_execs = [ 2 | 'service_starting', 3 | 'service_started', 4 | 'service_stopping', 5 | 'service_stopped', 6 | 'service_inactive', 7 | 'service_wasinactive', 8 | 'service_hotplugged', 9 | 'service_started_daemon', 10 | 'service_crashed', 11 | ] 12 | 13 | foreach exec : service_execs 14 | executable(exec, 15 | ['service.c', misc_c, version_h], 16 | include_directories: [incdir, einfo_incdir, rc_incdir], 17 | link_with: [libeinfo, librc], 18 | install: true, 19 | install_dir: rc_bindir) 20 | endforeach 21 | -------------------------------------------------------------------------------- /src/service/service.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2007-2015 The OpenRC Authors. 3 | * See the Authors file at the top-level directory of this distribution and 4 | * https://github.com/OpenRC/openrc/blob/HEAD/AUTHORS 5 | * 6 | * This file is part of OpenRC. It is subject to the license terms in 7 | * the LICENSE file found in the top-level directory of this 8 | * distribution and at https://github.com/OpenRC/openrc/blob/HEAD/LICENSE 9 | * This file may not be copied, modified, propagated, or distributed 10 | * except according to the terms contained in the LICENSE file. 11 | */ 12 | 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | #include "einfo.h" 20 | #include "rc.h" 21 | #include "misc.h" 22 | #include "helpers.h" 23 | 24 | const char *applet = NULL; 25 | 26 | int main(int argc, char **argv) 27 | { 28 | bool ok = false; 29 | char *service; 30 | char *exec; 31 | int idx = 0; 32 | RC_SERVICE state, bit; 33 | 34 | applet = basename_c(argv[0]); 35 | if (rc_yesno(getenv("RC_USER_SERVICES"))) 36 | rc_set_user(); 37 | 38 | if (argc > 1) 39 | service = argv[1]; 40 | else 41 | service = getenv("RC_SVCNAME"); 42 | 43 | if (service == NULL || *service == '\0') 44 | eerrorx("%s: no service specified", applet); 45 | 46 | state = rc_service_state(service); 47 | bit = lookup_service_state(applet); 48 | if (bit) { 49 | ok = (state & bit); 50 | } else if (strcmp(applet, "service_started_daemon") == 0) { 51 | service = getenv("RC_SVCNAME"); 52 | exec = argv[1]; 53 | if (argc > 3) { 54 | service = argv[1]; 55 | exec = argv[2]; 56 | sscanf(argv[3], "%d", &idx); 57 | } else if (argc == 3) { 58 | if (sscanf(argv[2], "%d", &idx) != 1) { 59 | service = argv[1]; 60 | exec = argv[2]; 61 | } 62 | } 63 | ok = rc_service_started_daemon(service, exec, NULL, idx); 64 | 65 | } else if (strcmp(applet, "service_crashed") == 0) { 66 | ok = ( rc_service_daemons_crashed(service) && errno != EACCES); 67 | } else 68 | eerrorx("%s: unknown applet", applet); 69 | 70 | return ok ? EXIT_SUCCESS : EXIT_FAILURE; 71 | } 72 | -------------------------------------------------------------------------------- /src/shared/meson.build: -------------------------------------------------------------------------------- 1 | misc_c = files([ 2 | 'misc.c', 3 | ]) 4 | 5 | plugin_c = files([ 6 | 'plugin.c', 7 | ]) 8 | 9 | schedules_c = files([ 10 | 'schedules.c', 11 | ]) 12 | 13 | pipes_c = files([ 14 | 'pipes.c', 15 | ]) 16 | 17 | if selinux_dep.found() 18 | selinux_c = files([ 19 | 'selinux.c', 20 | ]) 21 | else 22 | selinux_c = [] 23 | endif 24 | 25 | wtmp_c = files([ 26 | 'wtmp.c', 27 | ]) 28 | 29 | usage_c = files([ 30 | '_usage.c', 31 | ]) 32 | 33 | version_h = vcs_tag( 34 | input : 'version.h.in', 35 | output : 'version.h') 36 | 37 | version_f = vcs_tag( 38 | input : 'version.in', 39 | output : 'version') 40 | -------------------------------------------------------------------------------- /src/shared/pipes.c: -------------------------------------------------------------------------------- 1 | /* 2 | * pipes.c 3 | * Helper to handle spawning processes and connecting them to pipes. 4 | */ 5 | 6 | /* 7 | * Copyright (c) 2018 The OpenRC Authors. 8 | * See the Authors file at the top-level directory of this distribution and 9 | * https://github.com/OpenRC/openrc/blob/HEAD/AUTHORS 10 | * 11 | * This file is part of OpenRC. It is subject to the license terms in 12 | * the LICENSE file found in the top-level directory of this 13 | * distribution and at https://github.com/OpenRC/openrc/blob/HEAD/LICENSE 14 | * This file may not be copied, modified, propagated, or distributed 15 | * except according to the terms contained in the LICENSE file. 16 | */ 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | #include "pipes.h" 23 | 24 | static const int pipe_read_end = 0; 25 | static const int pipe_write_end = 1; 26 | 27 | /* 28 | * Starts a command with stdin redirected from a pipe 29 | * Returns the write end of the pipe or -1 30 | */ 31 | int rc_pipe_command(char *cmd) 32 | { 33 | int pfd[2]; 34 | pid_t pid; 35 | 36 | if (pipe(pfd) < 0) 37 | return -1; 38 | 39 | pid = fork(); 40 | if (pid > 0) { 41 | /* parent */ 42 | close(pfd[pipe_read_end]); 43 | return pfd[pipe_write_end]; 44 | } else if (pid == 0) { 45 | /* child */ 46 | close(pfd[pipe_write_end]); 47 | if (pfd[pipe_read_end] != STDIN_FILENO) { 48 | if (dup2(pfd[pipe_read_end], STDIN_FILENO) < 0) 49 | exit(1); 50 | close(pfd[pipe_read_end]); 51 | } 52 | execl("/bin/sh", "sh", "-c", cmd, NULL); 53 | exit(1); 54 | } 55 | return -1; 56 | } 57 | -------------------------------------------------------------------------------- /src/shared/pipes.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 The OpenRC Authors. 3 | * See the Authors file at the top-level directory of this distribution and 4 | * https://github.com/OpenRC/openrc/blob/HEAD/AUTHORS 5 | * 6 | * This file is part of OpenRC. It is subject to the license terms in 7 | * the LICENSE file found in the top-level directory of this 8 | * distribution and at https://github.com/OpenRC/openrc/blob/HEAD/LICENSE 9 | * This file may not be copied, modified, propagated, or distributed 10 | * except according to the terms contained in the LICENSE file. 11 | */ 12 | 13 | #ifndef RC_PIPES_H 14 | #define RC_PIPES_H 15 | 16 | int rc_pipe_command(char *cmd); 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /src/shared/plugin.h: -------------------------------------------------------------------------------- 1 | /* 2 | * plugin.h 3 | * Private instructions to use plugins 4 | */ 5 | 6 | /* 7 | * Copyright (c) 2007-2015 The OpenRC Authors. 8 | * See the Authors file at the top-level directory of this distribution and 9 | * https://github.com/OpenRC/openrc/blob/HEAD/AUTHORS 10 | * 11 | * This file is part of OpenRC. It is subject to the license terms in 12 | * the LICENSE file found in the top-level directory of this 13 | * distribution and at https://github.com/OpenRC/openrc/blob/HEAD/LICENSE 14 | * This file may not be copied, modified, propagated, or distributed 15 | * except according to the terms contained in the LICENSE file. 16 | */ 17 | 18 | #ifndef __LIBRC_PLUGIN_H__ 19 | #define __LIBRC_PLUGIN_H__ 20 | 21 | #include 22 | #include 23 | 24 | #include "rc.h" 25 | 26 | /* A simple flag to say if we're in a plugin process or not. 27 | * Mainly used in atexit code. */ 28 | extern bool rc_in_plugin; 29 | 30 | int rc_waitpid(pid_t pid); 31 | void rc_plugin_load(void); 32 | void rc_plugin_unload(void); 33 | void rc_plugin_run(RC_HOOK, const char *value); 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /src/shared/schedules.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 The OpenRC Authors. 3 | * See the Authors file at the top-level directory of this distribution and 4 | * https://github.com/OpenRC/openrc/blob/HEAD/AUTHORS 5 | * 6 | * This file is part of OpenRC. It is subject to the license terms in 7 | * the LICENSE file found in the top-level directory of this 8 | * distribution and at https://github.com/OpenRC/openrc/blob/HEAD/LICENSE 9 | * This file may not be copied, modified, propagated, or distributed 10 | * except according to the terms contained in the LICENSE file. 11 | */ 12 | 13 | #ifndef __RC_SCHEDULES_H 14 | #define __RC_SCHEDULES_H 15 | 16 | #include 17 | #include 18 | 19 | void free_schedulelist(void); 20 | int parse_signal(const char *applet, const char *sig); 21 | void parse_schedule(const char *applet, const char *string, int timeout); 22 | int do_stop(const char *applet, const char *exec, const char *const *argv, 23 | pid_t pid, uid_t uid,int sig, bool test, bool quiet); 24 | int run_stop_schedule(const char *applet, 25 | const char *exec, const char *const *argv, 26 | pid_t pid, uid_t uid, 27 | bool test, bool progress, bool quiet); 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /src/shared/selinux.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014-2015 The OpenRC Authors. 3 | * See the Authors file at the top-level directory of this distribution and 4 | * https://github.com/OpenRC/openrc/blob/HEAD/AUTHORS 5 | * 6 | * This file is part of OpenRC. It is subject to the license terms in 7 | * the LICENSE file found in the top-level directory of this 8 | * distribution and at https://github.com/OpenRC/openrc/blob/HEAD/LICENSE 9 | * This file may not be copied, modified, propagated, or distributed 10 | * except according to the terms contained in the LICENSE file. 11 | */ 12 | 13 | #ifndef RC_SELINUX_UTIL_H 14 | #define RC_SELINUX_UTIL_H 15 | 16 | #ifdef HAVE_SELINUX 17 | 18 | int selinux_util_open(void); 19 | int selinux_util_label(const char *path); 20 | int selinux_util_close(void); 21 | 22 | void selinux_setup(char **argv); 23 | 24 | #else 25 | 26 | /* always return false for selinux_util_open() */ 27 | #define selinux_util_open() (0) 28 | #define selinux_util_label(x) do { } while (0) 29 | #define selinux_util_close() do { } while (0) 30 | 31 | #define selinux_setup(x) do { } while (0) 32 | 33 | #endif 34 | 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /src/shared/version.h.in: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2007-2015 The OpenRC Authors. 3 | * See the Authors file at the top-level directory of this distribution and 4 | * https://github.com/OpenRC/openrc/blob/HEAD/AUTHORS 5 | * 6 | * This file is part of OpenRC. It is subject to the license terms in 7 | * the LICENSE file found in the top-level directory of this 8 | * distribution and at https://github.com/OpenRC/openrc/blob/HEAD/LICENSE 9 | * This file may not be copied, modified, propagated, or distributed 10 | * except according to the terms contained in the LICENSE file. 11 | */ 12 | 13 | #ifndef _VERSION_H_ 14 | #define _VERSION_H_ 15 | 16 | #define VERSION "@VCS_TAG@" 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /src/shared/version.in: -------------------------------------------------------------------------------- 1 | @VCS_TAG@ 2 | -------------------------------------------------------------------------------- /src/shared/wtmp.c: -------------------------------------------------------------------------------- 1 | /* 2 | * wtmp.c 3 | * This file contains routines to deal with the wtmp file. 4 | */ 5 | 6 | /* 7 | * Copyright 2017 The OpenRC Authors. 8 | * See the Authors file at the top-level directory of this distribution and 9 | * https://github.com/OpenRC/openrc/blob/HEAD/AUTHORS 10 | * 11 | * This file is part of OpenRC. It is subject to the license terms in 12 | * the LICENSE file found in the top-level directory of this 13 | * distribution and at https://github.com/OpenRC/openrc/blob/HEAD/LICENSE 14 | * This file may not be copied, modified, propagated, or distributed 15 | * except according to the terms contained in the LICENSE file. 16 | */ 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | #include "wtmp.h" 26 | 27 | void log_wtmp(const char *user, const char *id, pid_t pid, int type, 28 | const char *line) 29 | { 30 | struct timeval tv; 31 | struct utmp utmp; 32 | struct utsname uname_buf; 33 | 34 | memset(&utmp, 0, sizeof(utmp)); 35 | gettimeofday(&tv, NULL); 36 | utmp.ut_tv.tv_sec = tv.tv_sec; 37 | utmp.ut_tv.tv_usec = tv.tv_usec; 38 | utmp.ut_pid = pid; 39 | utmp.ut_type = type; 40 | strncpy(utmp.ut_name, user, sizeof(utmp.ut_name)); 41 | strncpy(utmp.ut_id , id , sizeof(utmp.ut_id )); 42 | strncpy(utmp.ut_line, line, sizeof(utmp.ut_line)); 43 | 44 | /* Put the OS version in place of the hostname */ 45 | if (uname(&uname_buf) == 0) 46 | strncpy(utmp.ut_host, uname_buf.release, sizeof(utmp.ut_host)); 47 | 48 | updwtmp(WTMP_FILE, &utmp); 49 | } 50 | -------------------------------------------------------------------------------- /src/shared/wtmp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * rc-wtmp.h 3 | * This is private to us and not for user consumption 4 | */ 5 | 6 | /* 7 | * Copyright (c) 2017 The OpenRC Authors. 8 | * See the Authors file at the top-level directory of this distribution and 9 | * https://github.com/OpenRC/openrc/blob/HEAD/AUTHORS 10 | * 11 | * This file is part of OpenRC. It is subject to the license terms in 12 | * the LICENSE file found in the top-level directory of this 13 | * distribution and at https://github.com/OpenRC/openrc/blob/HEAD/LICENSE 14 | * This file may not be copied, modified, propagated, or distributed 15 | * except according to the terms contained in the LICENSE file. 16 | */ 17 | 18 | #ifndef __RC_WTMP_H__ 19 | #define __RC_WTMP_H__ 20 | 21 | #include 22 | #include 23 | 24 | void log_wtmp(const char *user, const char *id, pid_t pid, int type, 25 | const char *line); 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /src/shell_var/meson.build: -------------------------------------------------------------------------------- 1 | executable('shell_var', 2 | ['shell_var.c'], 3 | install: true, 4 | install_dir: rc_bindir) 5 | -------------------------------------------------------------------------------- /src/shell_var/shell_var.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2007-2015 The OpenRC Authors. 3 | * See the Authors file at the top-level directory of this distribution and 4 | * https://github.com/OpenRC/openrc/blob/HEAD/AUTHORS 5 | * 6 | * This file is part of OpenRC. It is subject to the license terms in 7 | * the LICENSE file found in the top-level directory of this 8 | * distribution and at https://github.com/OpenRC/openrc/blob/HEAD/LICENSE 9 | * This file may not be copied, modified, propagated, or distributed 10 | * except according to the terms contained in the LICENSE file. 11 | */ 12 | 13 | #include 14 | #include 15 | #include 16 | 17 | int main(int argc, char **argv) 18 | { 19 | int i; 20 | char *p; 21 | int c; 22 | 23 | for (i = 1; i < argc; i++) { 24 | p = argv[i]; 25 | if (i != 1) 26 | putchar(' '); 27 | while (*p) { 28 | c = (unsigned char)*p++; 29 | if (!isalnum(c)) 30 | c = '_'; 31 | putchar(c); 32 | } 33 | } 34 | putchar('\n'); 35 | return EXIT_SUCCESS; 36 | } 37 | -------------------------------------------------------------------------------- /src/shutdown/meson.build: -------------------------------------------------------------------------------- 1 | if os == 'Linux' and get_option('sysvinit') 2 | configure_file(input : 'shutdown.in', 3 | output : '@BASENAME@', 4 | configuration : script_conf_data, 5 | install_dir: sbindir, 6 | install_mode: 'rwxr-xr-x') 7 | endif 8 | -------------------------------------------------------------------------------- /src/shutdown/shutdown.in: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | do_halt=false 4 | while getopts :akrhPHfFnct: opt; do 5 | case "$opt" in 6 | a) ;; 7 | k) ;; 8 | r) 9 | shutdown_arg=--reboot 10 | ;; 11 | h) 12 | do_halt=true 13 | shutdown_arg=--poweroff 14 | ;; 15 | P) 16 | if ! ${do_halt}; then 17 | printf "%s\n" "The -P flag requires the -h flag" >&2 18 | exit 1 19 | fi 20 | shutdown_arg=--poweroff 21 | ;; 22 | H) 23 | if ! ${do_halt}; then 24 | printf "%s\n" "The -H flag requires the -h flag" >&2 25 | exit 1 26 | fi 27 | shutdown_arg=--halt 28 | ;; 29 | f) ;; 30 | F) ;; 31 | n) ;; 32 | c) ;; 33 | t) ;; 34 | [?]) printf "%s\n" "${0##*/}: invalid command line option" >&2 35 | exit 1 36 | ;; 37 | esac 38 | done 39 | shift $((OPTIND-1)) 40 | 41 | if [ -z "${shutdown_arg}" ]; then 42 | shutdown_arg=--single 43 | fi 44 | 45 | printf "%s %s\n" "@SBINDIR@/openrc-shutdown ${shutdown_arg}" "$@" 46 | exec @SBINDIR@/openrc-shutdown ${shutdown_arg} "$@" 47 | -------------------------------------------------------------------------------- /src/start-stop-daemon/meson.build: -------------------------------------------------------------------------------- 1 | executable('start-stop-daemon', 2 | ['start-stop-daemon.c', pipes_c, misc_c, schedules_c, 3 | selinux_c, usage_c, version_h], 4 | c_args : [cc_audit_flags, cc_branding_flags, cc_pam_flags, cc_cap_flags, cc_selinux_flags], 5 | link_with: [libeinfo, librc], 6 | dependencies: [audit_dep, dl_dep, pam_dep, cap_dep, pam_misc_dep, util_dep, selinux_dep, crypt_dep, dependency('threads')], 7 | include_directories: [incdir, einfo_incdir, rc_incdir], 8 | install: true, 9 | install_dir: sbindir) 10 | 11 | if get_option('pam') 12 | install_data('start-stop-daemon.pam', 13 | rename : 'start-stop-daemon', 14 | install_dir : pamdir) 15 | endif 16 | -------------------------------------------------------------------------------- /src/start-stop-daemon/start-stop-daemon.pam: -------------------------------------------------------------------------------- 1 | #%PAM-1.0 2 | 3 | auth required pam_permit.so 4 | account required pam_permit.so 5 | password required pam_deny.so 6 | session optional pam_limits.so 7 | -------------------------------------------------------------------------------- /src/supervise-daemon/meson.build: -------------------------------------------------------------------------------- 1 | executable('supervise-daemon', 2 | ['supervise-daemon.c', pipes_c, misc_c, plugin_c, schedules_c, usage_c, version_h], 3 | c_args : [cc_branding_flags, cc_pam_flags, cc_cap_flags, cc_selinux_flags], 4 | link_with: [libeinfo, librc], 5 | dependencies: [dl_dep, pam_dep, cap_dep, util_dep, selinux_dep], 6 | include_directories: [incdir, einfo_incdir, rc_incdir], 7 | install: true, 8 | install_dir: sbindir) 9 | 10 | if get_option('pam') 11 | install_data('supervise-daemon.pam', 12 | rename : 'supervise-daemon', 13 | install_dir : pamdir) 14 | endif 15 | -------------------------------------------------------------------------------- /src/supervise-daemon/supervise-daemon.pam: -------------------------------------------------------------------------------- 1 | #%PAM-1.0 2 | 3 | auth required pam_permit.so 4 | account required pam_permit.so 5 | password required pam_deny.so 6 | session optional pam_limits.so 7 | -------------------------------------------------------------------------------- /src/swclock/meson.build: -------------------------------------------------------------------------------- 1 | executable('swclock', 2 | ['swclock.c', misc_c, usage_c, version_h], 3 | c_args : cc_branding_flags, 4 | include_directories: [incdir, einfo_incdir, rc_incdir], 5 | link_with: [libeinfo,librc], 6 | install: true, 7 | install_dir: rc_sbindir) 8 | -------------------------------------------------------------------------------- /src/user_init/meson.build: -------------------------------------------------------------------------------- 1 | executable('user_init', ['user_init.c'], 2 | include_directories: [incdir, einfo_incdir, rc_incdir], 3 | link_with: [libeinfo, librc], 4 | install: true, 5 | install_dir: rc_bindir) 6 | -------------------------------------------------------------------------------- /src/user_init/user_init.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include "helpers.h" 9 | #include "rc.h" 10 | 11 | #define USERINIT RC_LIBEXECDIR "/sh/user-init.sh" 12 | 13 | int main(int argc, char **argv) { 14 | struct passwd *user; 15 | char *cmd; 16 | int nullfd = -1; 17 | if (argc < 3) 18 | return 1; 19 | 20 | user = getpwnam(argv[1]); 21 | if (!user || initgroups(user->pw_name, user->pw_gid) == -1 22 | || setgid(user->pw_gid) == -1 23 | || setuid(user->pw_uid) == -1) 24 | return 1; 25 | 26 | setenv("HOME", user->pw_dir, true); 27 | setenv("SHELL", user->pw_shell, true); 28 | 29 | nullfd = open("/dev/null", O_RDWR); 30 | dup2(nullfd, STDIN_FILENO); 31 | close(nullfd); 32 | 33 | xasprintf(&cmd, "%s %s", USERINIT, argv[2]); 34 | execl(user->pw_shell, "-", "-c", cmd, NULL); 35 | } 36 | -------------------------------------------------------------------------------- /src/value/meson.build: -------------------------------------------------------------------------------- 1 | value_execs = [ 2 | 'service_get_value', 3 | 'service_set_value', 4 | 'get_options', 5 | 'save_options', 6 | ] 7 | 8 | foreach exec : value_execs 9 | executable(exec, 10 | ['value.c', misc_c, version_h], 11 | include_directories: [incdir, einfo_incdir, rc_incdir], 12 | link_with: [libeinfo, librc], 13 | install: true, 14 | install_dir: rc_bindir) 15 | endforeach 16 | -------------------------------------------------------------------------------- /src/value/value.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 The OpenRC Authors. 3 | * See the Authors file at the top-level directory of this distribution and 4 | * https://github.com/OpenRC/openrc/blob/HEAD/AUTHORS 5 | * 6 | * This file is part of OpenRC. It is subject to the license terms in 7 | * the LICENSE file found in the top-level directory of this 8 | * distribution and at https://github.com/OpenRC/openrc/blob/HEAD/LICENSE 9 | * This file may not be copied, modified, propagated, or distributed 10 | * except according to the terms contained in the LICENSE file. 11 | */ 12 | 13 | #define SYSLOG_NAMES 14 | 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | #include "einfo.h" 21 | #include "rc.h" 22 | #include "helpers.h" 23 | 24 | const char *applet = NULL; 25 | 26 | int main(int argc, char **argv) 27 | { 28 | bool ok = false; 29 | char *service = getenv("RC_SVCNAME"); 30 | char *option; 31 | 32 | applet = basename_c(argv[0]); 33 | if (rc_yesno(getenv("RC_USER_SERVICES"))) 34 | rc_set_user(); 35 | 36 | if (service == NULL) 37 | eerrorx("%s: no service specified", applet); 38 | 39 | if (argc < 2 || !argv[1] || *argv[1] == '\0') 40 | eerrorx("%s: no option specified", applet); 41 | 42 | if (strcmp(applet, "service_get_value") == 0 || 43 | strcmp(applet, "get_options") == 0) 44 | { 45 | option = rc_service_value_get(service, argv[1]); 46 | if (option) { 47 | printf("%s", option); 48 | free(option); 49 | ok = true; 50 | } 51 | } else if (strcmp(applet, "service_set_value") == 0 || 52 | strcmp(applet, "save_options") == 0) 53 | ok = rc_service_value_set(service, argv[1], argv[2]); 54 | else 55 | eerrorx("%s: unknown applet", applet); 56 | 57 | return ok ? EXIT_SUCCESS : EXIT_FAILURE; 58 | } 59 | -------------------------------------------------------------------------------- /support/deptree2dot/README.md: -------------------------------------------------------------------------------- 1 | deptree2dot - Graph the OpenRC Dependency Tree 2 | ============================================== 3 | 4 | This utility can be used to graph the OpenRC dependency tree. It 5 | requires perl5.x and converts the tree to a .dot file which can be 6 | processed by graphviz. 7 | 8 | Example usage: 9 | 10 | $ chmod +x deptree2dot 11 | $deptree2dot > deptree.dot 12 | $deptree2dot | dot -Tpng -o deptree.png 13 | -------------------------------------------------------------------------------- /support/deptree2dot/deptree2dot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/navi-desu/openrc/b8251bd4717db9d0101a614a35b928a17c85ffa4/support/deptree2dot/deptree2dot -------------------------------------------------------------------------------- /support/deptree2dot/meson.build: -------------------------------------------------------------------------------- 1 | deptree2dot_dir = support_dir / 'deptree2dot' 2 | 3 | deptree2dot_bin = ['deptree2dot'] 4 | deptree2dot_data = ['README.md'] 5 | 6 | install_data(deptree2dot_bin, 7 | install_dir : deptree2dot_dir, 8 | install_mode : 'rwxr-xr-x') 9 | 10 | install_data(deptree2dot_data, 11 | install_dir : deptree2dot_dir) 12 | -------------------------------------------------------------------------------- /support/init.d.examples/README.md: -------------------------------------------------------------------------------- 1 | Example OpenRC Service Scripts 2 | ############################## 3 | 4 | The service scripts in this directory are meant as examples only. 5 | They are not installed by default as the scripts will need tweaking on a 6 | per distro basis. They are also non essential to the operation of the system. 7 | -------------------------------------------------------------------------------- /support/init.d.examples/avahi-dnsconfd.in: -------------------------------------------------------------------------------- 1 | #!@SBINDIR@/openrc-run 2 | # Copyright (c) 2007-2015 The OpenRC Authors. 3 | # See the Authors file at the top-level directory of this distribution and 4 | # https://github.com/OpenRC/openrc/blob/HEAD/AUTHORS 5 | # 6 | # This file is part of OpenRC. It is subject to the license terms in 7 | # the LICENSE file found in the top-level directory of this 8 | # distribution and at https://github.com/OpenRC/openrc/blob/HEAD/LICENSE 9 | # This file may not be copied, modified, propagated, or distributed 10 | # except according to the terms contained in the LICENSE file. 11 | 12 | command=/sbin/avahi-dnsconfd 13 | command_args="$avahi_dnsconfd_args -D" 14 | pidfile=/var/run/avahi-dnsconfd.pid 15 | name="Avahi DNS Configuration Daemon" 16 | 17 | depend() 18 | { 19 | use dns 20 | need localmount dbus 21 | after bootmisc 22 | } 23 | -------------------------------------------------------------------------------- /support/init.d.examples/avahid.in: -------------------------------------------------------------------------------- 1 | #!@SBINDIR@/openrc-run 2 | # Copyright (c) 2007-2015 The OpenRC Authors. 3 | # See the Authors file at the top-level directory of this distribution and 4 | # https://github.com/OpenRC/openrc/blob/HEAD/AUTHORS 5 | # 6 | # This file is part of OpenRC. It is subject to the license terms in 7 | # the LICENSE file found in the top-level directory of this 8 | # distribution and at https://github.com/OpenRC/openrc/blob/HEAD/LICENSE 9 | # This file may not be copied, modified, propagated, or distributed 10 | # except according to the terms contained in the LICENSE file. 11 | 12 | command=/sbin/avahi-daemon 13 | command_args="$avahid_args -D" 14 | pidfile=/var/run/avahi-daemon/pid 15 | name="Avahi Service Advertisement Daemon" 16 | 17 | depend() 18 | { 19 | use dns 20 | need localmount dbus 21 | after bootmisc 22 | } 23 | -------------------------------------------------------------------------------- /support/init.d.examples/dbus.in: -------------------------------------------------------------------------------- 1 | #!@SBINDIR@/openrc-run 2 | # Copyright (c) 2007-2015 The OpenRC Authors. 3 | # See the Authors file at the top-level directory of this distribution and 4 | # https://github.com/OpenRC/openrc/blob/HEAD/AUTHORS 5 | # 6 | # This file is part of OpenRC. It is subject to the license terms in 7 | # the LICENSE file found in the top-level directory of this 8 | # distribution and at https://github.com/OpenRC/openrc/blob/HEAD/LICENSE 9 | # This file may not be copied, modified, propagated, or distributed 10 | # except according to the terms contained in the LICENSE file. 11 | 12 | command=/bin/dbus-daemon 13 | pidfile=/var/run/dbus/pid 14 | command_args="${dbusd_args---system}" 15 | name="Message Bus Daemon" 16 | 17 | depend() 18 | { 19 | need localmount net 20 | after bootmisc 21 | } 22 | 23 | start_pre() 24 | { 25 | mkdir -p $(dirname $pidfile) 26 | } 27 | -------------------------------------------------------------------------------- /support/init.d.examples/dhcpcd.in: -------------------------------------------------------------------------------- 1 | #!@SBINDIR@/openrc-run 2 | # Copyright (c) 2007-2015 The OpenRC Authors. 3 | # See the Authors file at the top-level directory of this distribution and 4 | # https://github.com/OpenRC/openrc/blob/HEAD/AUTHORS 5 | # 6 | # This file is part of OpenRC. It is subject to the license terms in 7 | # the LICENSE file found in the top-level directory of this 8 | # distribution and at https://github.com/OpenRC/openrc/blob/HEAD/LICENSE 9 | # This file may not be copied, modified, propagated, or distributed 10 | # except according to the terms contained in the LICENSE file. 11 | 12 | command=/sbin/dhcpcd 13 | pidfile=/var/run/dhcpcd.pid 14 | command_args=-q 15 | name="DHCP Client Daemon" 16 | 17 | depend() 18 | { 19 | provide net 20 | need localmount 21 | use logger 22 | after bootmisc modules 23 | before dns 24 | } 25 | 26 | stop_pre() 27 | { 28 | # When shutting down, kill dhcpcd but preserve network 29 | # We do this as /var/run/dhcpcd could be cleaned out when we 30 | # return to multiuser. 31 | if yesno $RC_GOINGDOWN; then 32 | : ${stopsig:=SIGKILL} 33 | fi 34 | } 35 | -------------------------------------------------------------------------------- /support/init.d.examples/dnsmasq.in: -------------------------------------------------------------------------------- 1 | #!@SBINDIR@/openrc-run 2 | # Copyright (c) 2007-2015 The OpenRC Authors. 3 | # See the Authors file at the top-level directory of this distribution and 4 | # https://github.com/OpenRC/openrc/blob/HEAD/AUTHORS 5 | # 6 | # This file is part of OpenRC. It is subject to the license terms in 7 | # the LICENSE file found in the top-level directory of this 8 | # distribution and at https://github.com/OpenRC/openrc/blob/HEAD/LICENSE 9 | # This file may not be copied, modified, propagated, or distributed 10 | # except according to the terms contained in the LICENSE file. 11 | 12 | command=/sbin/dnsmasq 13 | command_args=$dnsmasq_args 14 | pidfile=/var/run/dnsmasq.pid 15 | required_files=/etc/dnsmasq.conf 16 | 17 | extra_started_commands="reload" 18 | 19 | depend() 20 | { 21 | provide dns 22 | need localmount net 23 | after bootmisc 24 | } 25 | 26 | reload() 27 | { 28 | ebegin "Reloading $RC_SVCNAME" 29 | start-stop-daemon --signal SIGHUP --pidfile "$pidfile" 30 | eend $? 31 | } 32 | -------------------------------------------------------------------------------- /support/init.d.examples/hald.in: -------------------------------------------------------------------------------- 1 | #!@SBINDIR@/openrc-run 2 | # Copyright (c) 2007-2015 The OpenRC Authors. 3 | # See the Authors file at the top-level directory of this distribution and 4 | # https://github.com/OpenRC/openrc/blob/HEAD/AUTHORS 5 | # 6 | # This file is part of OpenRC. It is subject to the license terms in 7 | # the LICENSE file found in the top-level directory of this 8 | # distribution and at https://github.com/OpenRC/openrc/blob/HEAD/LICENSE 9 | # This file may not be copied, modified, propagated, or distributed 10 | # except according to the terms contained in the LICENSE file. 11 | 12 | command=/sbin/hald 13 | pidfile=/var/run/hald/hald.pid 14 | command_args=$hald_args 15 | name="Hardware Abstraction Layer Daemon" 16 | 17 | depend() 18 | { 19 | need dbus 20 | } 21 | -------------------------------------------------------------------------------- /support/init.d.examples/meson.build: -------------------------------------------------------------------------------- 1 | init_d_examples_dir = support_dir / 'init.d.examples' 2 | 3 | init_d_examples = [ 4 | 'avahi-dnsconfd.in', 5 | 'avahid.in', 6 | 'dhcpcd.in', 7 | 'dbus.in', 8 | 'hald.in', 9 | 'named.in', 10 | 'ntpd.in', 11 | 'openvpn.in', 12 | 'polkitd.in', 13 | 'sshd.in', 14 | 'wpa_supplicant.in', 15 | ] 16 | 17 | init_d_examples_data = [ 18 | 'README.md', 19 | ] 20 | 21 | foreach init_d_example: init_d_examples 22 | configure_file(input : init_d_example, 23 | output : '@BASENAME@', 24 | configuration : init_d_conf_data, 25 | install_dir : init_d_examples_dir, 26 | install_mode : 'rwxr-xr-x') 27 | endforeach 28 | 29 | install_data(init_d_examples_data, 30 | install_dir : init_d_examples_dir) 31 | -------------------------------------------------------------------------------- /support/init.d.examples/ntpd.in: -------------------------------------------------------------------------------- 1 | #!@SBINDIR@/openrc-run 2 | # Copyright (c) 2007-2015 The OpenRC Authors. 3 | # See the Authors file at the top-level directory of this distribution and 4 | # https://github.com/OpenRC/openrc/blob/HEAD/AUTHORS 5 | # 6 | # This file is part of OpenRC. It is subject to the license terms in 7 | # the LICENSE file found in the top-level directory of this 8 | # distribution and at https://github.com/OpenRC/openrc/blob/HEAD/LICENSE 9 | # This file may not be copied, modified, propagated, or distributed 10 | # except according to the terms contained in the LICENSE file. 11 | 12 | : ${ntpd_config:=/etc/ntp.conf} 13 | : ${ntpd_drift:=/var/db/ntpd.drift} 14 | 15 | command=/usr/sbin/ntpd 16 | required_files=$ntpd_config 17 | pidfile=/var/run/ntpd.pid 18 | command_args="$ntpd_args -c $ntpd_config -f $ntpd_drift -p $pidfile" 19 | name="Network Time Protocol Daemon" 20 | 21 | depend() 22 | { 23 | use dns 24 | need localmount 25 | after bootmisc ntp-client 26 | } 27 | 28 | start_pre() 29 | { 30 | if [ -n "$ntpd_chroot" ]; then 31 | case "$RC_UNAME" in 32 | *BSD|DragonFly) 33 | if [ ! -c "$ntpd_chroot/dev/clockctl" ]; then 34 | rm -f "$ntpd_chroot/dev/clockctl" 35 | (cd /dev; /bin/pax -rw -pe clockctl \ 36 | "$ntpd_chroot/dev") 37 | fi 38 | ;; 39 | esac 40 | ln -fs "$ntpd_chroot$ntpd_drift" "$ntpd_drift" 41 | 42 | command_args="$command_args -u ntpd:ntpd -i $ntpd_chroot" 43 | fi 44 | } 45 | -------------------------------------------------------------------------------- /support/init.d.examples/polkitd.in: -------------------------------------------------------------------------------- 1 | #!@SBINDIR@/openrc-run 2 | # Copyright (c) 2007-2015 The OpenRC Authors. 3 | # See the Authors file at the top-level directory of this distribution and 4 | # https://github.com/OpenRC/openrc/blob/HEAD/AUTHORS 5 | # 6 | # This file is part of OpenRC. It is subject to the license terms in 7 | # the LICENSE file found in the top-level directory of this 8 | # distribution and at https://github.com/OpenRC/openrc/blob/HEAD/LICENSE 9 | # This file may not be copied, modified, propagated, or distributed 10 | # except according to the terms contained in the LICENSE file. 11 | 12 | command=/sbin/polkitd 13 | pidfile=/var/run/polkitd/polkitd.pid 14 | command_args="$polkitd_args" 15 | name="PolicyKit Daemon" 16 | 17 | depend() 18 | { 19 | need dbus 20 | } 21 | -------------------------------------------------------------------------------- /support/init.d.examples/sshd.in: -------------------------------------------------------------------------------- 1 | #!@SBINDIR@/openrc-run 2 | # Copyright (c) 2007-2015 The OpenRC Authors. 3 | # See the Authors file at the top-level directory of this distribution and 4 | # https://github.com/OpenRC/openrc/blob/HEAD/AUTHORS 5 | # 6 | # This file is part of OpenRC. It is subject to the license terms in 7 | # the LICENSE file found in the top-level directory of this 8 | # distribution and at https://github.com/OpenRC/openrc/blob/HEAD/LICENSE 9 | # This file may not be copied, modified, propagated, or distributed 10 | # except according to the terms contained in the LICENSE file. 11 | 12 | command=/usr/sbin/sshd 13 | command_args=$sshd_args 14 | pidfile=/var/run/sshd.pid 15 | required_files=/etc/ssh/sshd_config 16 | 17 | depend() 18 | { 19 | use logger dns 20 | need net 21 | } 22 | 23 | start_pre() 24 | { 25 | if [ ! -e /etc/ssh/ssh_host_key ]; then 26 | ebegin "Generating Hostkey" 27 | ssh-keygen -t rsa1 -b 1024 -f /etc/ssh/ssh_host_key -N '' 28 | eend $? || return 1 29 | fi 30 | if [ ! -e /etc/ssh/ssh_host_dsa_key ]; then 31 | ebegin "Generating DSA Hostkey" 32 | ssh-keygen -d -f /etc/ssh/ssh_host_dsa_key -N '' 33 | eend $? || return 1 34 | fi 35 | if [ ! -e /etc/ssh/ssh_host_rsa_key ]; then 36 | ebegin "Generating RSA Hostkey" 37 | ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key -N '' 38 | eend $? || return 1 39 | fi 40 | 41 | $command -t 42 | } 43 | -------------------------------------------------------------------------------- /support/init.d.examples/wpa_supplicant.in: -------------------------------------------------------------------------------- 1 | #!@SBINDIR@/openrc-run 2 | # Copyright (c) 2007-2015 The OpenRC Authors. 3 | # See the Authors file at the top-level directory of this distribution and 4 | # https://github.com/OpenRC/openrc/blob/HEAD/AUTHORS 5 | # 6 | # This file is part of OpenRC. It is subject to the license terms in 7 | # the LICENSE file found in the top-level directory of this 8 | # distribution and at https://github.com/OpenRC/openrc/blob/HEAD/LICENSE 9 | # This file may not be copied, modified, propagated, or distributed 10 | # except according to the terms contained in the LICENSE file. 11 | 12 | command=/usr/sbin/wpa_supplicant 13 | : ${wpa_supplicant_conf:=/etc/wpa_supplicant.conf} 14 | wpa_supplicant_if=${wpa_supplicant_if:+-i}$wpa_supplicant_if 15 | command_args="$wpa_supplicant_args -B -c$wpa_supplicant_conf $wpa_supplicant_if" 16 | name="WPA Supplicant Daemon" 17 | 18 | depend() 19 | { 20 | need localmount 21 | use logger 22 | after bootmisc modules 23 | before dns dhcpcd net 24 | keyword -shutdown 25 | } 26 | 27 | find_wireless() 28 | { 29 | local iface= 30 | 31 | case "$RC_UNAME" in 32 | Linux) 33 | for iface in /sys/class/net/*; do 34 | if [ -e "$iface"/wireless -o \ 35 | -e "$iface"/phy80211 ] 36 | then 37 | echo "${iface##*/}" 38 | return 0 39 | fi 40 | done 41 | ;; 42 | FreeBSD) 43 | for iface in $(sysctl -b net.wlan.devices 2>/dev/null); do 44 | echo "${iface##*/}" 45 | done 46 | ;; 47 | *) 48 | for iface in /dev/net/* $(ifconfig -l 2>/dev/null); do 49 | if ifconfig "${iface##*/}" 2>/dev/null | \ 50 | grep -q "[ ]*ssid " 51 | then 52 | echo "${iface##*/}" 53 | return 0 54 | fi 55 | done 56 | ;; 57 | esac 58 | 59 | return 1 60 | } 61 | 62 | append_wireless() 63 | { 64 | local iface= i= 65 | 66 | iface=$(find_wireless) 67 | if [ -n "$iface" ]; then 68 | for i in $iface; do 69 | command_args="$command_args -i$i" 70 | done 71 | else 72 | eerror "Could not find a wireless interface" 73 | fi 74 | } 75 | 76 | start_pre() 77 | { 78 | case " $command_args" in 79 | *" -i"*) ;; 80 | *) append_wireless;; 81 | esac 82 | } 83 | -------------------------------------------------------------------------------- /support/meson.build: -------------------------------------------------------------------------------- 1 | support_dir = get_option('datadir') / meson.project_name().to_lower() 2 | support_dir = support_dir / 'support' 3 | 4 | subdir('deptree2dot') 5 | subdir('init.d.examples') 6 | subdir('user.d.examples') 7 | subdir('openvpn') 8 | subdir('sysvinit') 9 | -------------------------------------------------------------------------------- /support/openvpn/README.md: -------------------------------------------------------------------------------- 1 | Example OpenVPN Scripts 2 | ======================= 3 | 4 | These handy scripts setup any dns information that OpenVPN may push. 5 | They also handle the interaction with OpenRC so that the OpenVPN service 6 | can become "inactive". This means that when it starts, it goes inactive and 7 | OpenRC continues on its merry way booting the system. When OpenVPN connects 8 | to an endpoint it then re-starts the OpenVPN service and starts up any 9 | services that depend on us. A similar thing happens when we shut down. 10 | 11 | Of course, this is all optional. 12 | -------------------------------------------------------------------------------- /support/openvpn/down.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Copyright (c) 2007-2015 The OpenRC Authors. 3 | # See the Authors file at the top-level directory of this distribution and 4 | # https://github.com/OpenRC/openrc/blob/HEAD/AUTHORS 5 | # 6 | # This file is part of OpenRC. It is subject to the license terms in 7 | # the LICENSE file found in the top-level directory of this 8 | # distribution and at https://github.com/OpenRC/openrc/blob/HEAD/LICENSE 9 | # This file may not be copied, modified, propagated, or distributed 10 | # except according to the terms contained in the LICENSE file. 11 | 12 | # If we have a service specific script, run this now 13 | [ -x "${RC_SVCNAME}"-down.sh ] && "${RC_SVCNAME}"-down.sh 14 | 15 | # Restore resolv.conf to how it was 16 | if command -v resolvconf >/dev/null 2>&1; then 17 | resolvconf -d "${dev}" 18 | elif [ -e /etc/resolv.conf-"${dev}".sv ]; then 19 | # Important that we copy instead of move incase resolv.conf is 20 | # a symlink and not an actual file 21 | cp -p /etc/resolv.conf-"${dev}".sv /etc/resolv.conf 22 | rm -f /etc/resolv.conf-"${dev}".sv 23 | fi 24 | 25 | # Re-enter the init script to stop any dependant services 26 | if [ -x "${RC_SERVICE}" ]; then 27 | if "${RC_SERVICE}" --quiet status; then 28 | IN_BACKGROUND=YES 29 | export IN_BACKGROUND 30 | "${RC_SERVICE}" --quiet stop 31 | fi 32 | fi 33 | 34 | exit 0 35 | -------------------------------------------------------------------------------- /support/openvpn/meson.build: -------------------------------------------------------------------------------- 1 | openvpn_dir = support_dir / 'openvpn' 2 | 3 | openvpn_bin = ['down.sh', 'up.sh'] 4 | openvpn_data = ['README.md'] 5 | 6 | install_data(openvpn_bin, 7 | install_dir : openvpn_dir, 8 | install_mode : 'rwxr-xr-x') 9 | install_data(openvpn_data, 10 | install_dir : openvpn_dir) 11 | -------------------------------------------------------------------------------- /support/sysvinit/README.md: -------------------------------------------------------------------------------- 1 | OpenRC Sysvinit Support 2 | ======================== 3 | 4 | Here's a sample inittab for use with sysvinit for Linux based systems. 5 | We don't install it by default as sysvinit packages normally own this file. 6 | -------------------------------------------------------------------------------- /support/sysvinit/halt.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | if [ "$INIT_HALT" = HALT ]; then 3 | exec /sbin/halt -dhn 4 | else 5 | exec /sbin/poweroff -dhn 6 | fi 7 | -------------------------------------------------------------------------------- /support/sysvinit/inittab: -------------------------------------------------------------------------------- 1 | # /etc/inittab: This file describes how the INIT process should set up 2 | # the system in a certain run-level. 3 | 4 | # Default runlevel. 5 | id:3:initdefault: 6 | 7 | # System initialization, mount local filesystems, etc. 8 | si::sysinit:/sbin/openrc sysinit 9 | 10 | # Further system initialization, brings up the boot runlevel. 11 | rc::bootwait:/sbin/openrc boot 12 | 13 | l0u:0:wait:/sbin/telinit u 14 | l0:0:wait:/sbin/openrc shutdown 15 | l0s:0:wait:/sbin/halt.sh 16 | l1:S1:wait:/sbin/openrc single 17 | l2:2:wait:/sbin/openrc nonetwork 18 | l3:3:wait:/sbin/openrc default 19 | l4:4:wait:/sbin/openrc default 20 | l5:5:wait:/sbin/openrc default 21 | l6u:6:wait:/sbin/telinit u 22 | l6:6:wait:/sbin/openrc reboot 23 | l6r:6:wait:/sbin/reboot -d 24 | #z6:6:respawn:/sbin/sulogin 25 | 26 | # new-style single-user 27 | su0:S:wait:/sbin/openrc single 28 | su1:S:wait:/sbin/sulogin 29 | 30 | # TERMINALS 31 | c1:12345:respawn:/sbin/agetty 38400 tty1 linux 32 | c2:2345:respawn:/sbin/agetty 38400 tty2 linux 33 | c3:2345:respawn:/sbin/agetty 38400 tty3 linux 34 | c4:2345:respawn:/sbin/agetty 38400 tty4 linux 35 | c5:2345:respawn:/sbin/agetty 38400 tty5 linux 36 | c6:2345:respawn:/sbin/agetty 38400 tty6 linux 37 | 38 | # SERIAL CONSOLES 39 | #s0:12345:respawn:/sbin/agetty -L 9600 ttyS0 vt100 40 | #s1:12345:respawn:/sbin/agetty -L 9600 ttyS1 vt100 41 | 42 | # What to do at the "Three Finger Salute". 43 | ca:12345:ctrlaltdel:/sbin/shutdown -r now 44 | -------------------------------------------------------------------------------- /support/sysvinit/meson.build: -------------------------------------------------------------------------------- 1 | sysvinit_dir = support_dir / 'sysvinit' 2 | 3 | sysvinit_data = ['halt.sh', 'inittab', 'README.md'] 4 | 5 | install_data(sysvinit_data, 6 | install_dir : sysvinit_dir) 7 | -------------------------------------------------------------------------------- /support/user.d.examples/README.md: -------------------------------------------------------------------------------- 1 | Example OpenRC Service User Scripts 2 | ################################### 3 | 4 | The service scripts in this directory are meant as examples only. 5 | They are not installed by default as the scripts will need tweaking on a 6 | per distro basis. They are also non essential to the operation of the system. 7 | -------------------------------------------------------------------------------- /support/user.d.examples/dbus.in: -------------------------------------------------------------------------------- 1 | #!@SBINDIR@/openrc-run --user 2 | # Copyright (c) 2024 The OpenRC Authors. 3 | # See the Authors file at the top-level directory of this distribution and 4 | # https://github.com/OpenRC/openrc/blob/HEAD/AUTHORS 5 | # 6 | # This file is part of OpenRC. It is subject to the license terms in 7 | # the LICENSE file found in the top-level directory of this 8 | # distribution and at https://github.com/OpenRC/openrc/blob/HEAD/LICENSE 9 | # This file may not be copied, modified, propagated, or distributed 10 | # except according to the terms contained in the LICENSE file. 11 | 12 | DBUS_SESSION_BUS_ADDRESS="unix:path=${XDG_RUNTIME_DIR}/bus" 13 | 14 | command="/usr/bin/dbus-daemon" 15 | command_args="--session --syslog --nofork --address ${DBUS_SESSION_BUS_ADDRESS}" 16 | command_background=yes 17 | pidfile="${XDG_RUNTIME_DIR}/dbus.pid" 18 | 19 | extra_commands="socket" 20 | socket() { 21 | echo ${DBUS_SESSION_BUS_ADDRESS} 22 | } 23 | -------------------------------------------------------------------------------- /support/user.d.examples/dunst.in: -------------------------------------------------------------------------------- 1 | #!@SBINDIR@/openrc-run --user 2 | # Copyright (c) 2024 The OpenRC Authors. 3 | # See the Authors file at the top-level directory of this distribution and 4 | # https://github.com/OpenRC/openrc/blob/HEAD/AUTHORS 5 | # 6 | # This file is part of OpenRC. It is subject to the license terms in 7 | # the LICENSE file found in the top-level directory of this 8 | # distribution and at https://github.com/OpenRC/openrc/blob/HEAD/LICENSE 9 | # This file may not be copied, modified, propagated, or distributed 10 | # except according to the terms contained in the LICENSE file. 11 | 12 | depend() { 13 | need dbus 14 | } 15 | 16 | DBUS_SESSION_BUS_ADDRESS=$(rc-service --user dbus socket) 17 | command="/usr/bin/dunst" 18 | command_background="true" 19 | pidfile="${XDG_RUNTIME_DIR}/dunst.pid" 20 | -------------------------------------------------------------------------------- /support/user.d.examples/meson.build: -------------------------------------------------------------------------------- 1 | user_d_examples_dir = support_dir / 'user.d.examples' 2 | 3 | user_d_examples = [ 4 | 'dbus.in', 5 | 'dunst.in', 6 | 'pipewire.in', 7 | 'pipewire-pulse.in', 8 | 'ssh-agent.in', 9 | 'wireplumber.in', 10 | ] 11 | 12 | user_d_examples_data = [ 13 | 'README.md', 14 | ] 15 | 16 | foreach user_d_example: user_d_examples 17 | configure_file(input : user_d_example, 18 | output : '@BASENAME@', 19 | configuration : init_d_conf_data, 20 | install_dir : user_d_examples_dir, 21 | install_mode : 'rwxr-xr-x') 22 | endforeach 23 | 24 | install_data(user_d_examples_data, 25 | install_dir : user_d_examples_dir) 26 | -------------------------------------------------------------------------------- /support/user.d.examples/pipewire-pulse.in: -------------------------------------------------------------------------------- 1 | #!@SBINDIR@/openrc-run --user 2 | # Copyright (c) 2024 The OpenRC Authors. 3 | # See the Authors file at the top-level directory of this distribution and 4 | # https://github.com/OpenRC/openrc/blob/HEAD/AUTHORS 5 | # 6 | # This file is part of OpenRC. It is subject to the license terms in 7 | # the LICENSE file found in the top-level directory of this 8 | # distribution and at https://github.com/OpenRC/openrc/blob/HEAD/LICENSE 9 | # This file may not be copied, modified, propagated, or distributed 10 | # except according to the terms contained in the LICENSE file. 11 | 12 | depend() { 13 | need pipewire dbus 14 | } 15 | 16 | DBUS_SESSION_BUS_ADDRESS=$(rc-service --user dbus socket) 17 | command="/usr/bin/pipewire" 18 | command_args="-c pipewire-pulse.conf" 19 | command_background="true" 20 | pidfile="${XDG_RUNTIME_DIR}/pipewire-pulse.pid" 21 | -------------------------------------------------------------------------------- /support/user.d.examples/pipewire.in: -------------------------------------------------------------------------------- 1 | #!@SBINDIR@/openrc-run --user 2 | # Copyright (c) 2024 The OpenRC Authors. 3 | # See the Authors file at the top-level directory of this distribution and 4 | # https://github.com/OpenRC/openrc/blob/HEAD/AUTHORS 5 | # 6 | # This file is part of OpenRC. It is subject to the license terms in 7 | # the LICENSE file found in the top-level directory of this 8 | # distribution and at https://github.com/OpenRC/openrc/blob/HEAD/LICENSE 9 | # This file may not be copied, modified, propagated, or distributed 10 | # except according to the terms contained in the LICENSE file. 11 | 12 | depend() { 13 | need dbus 14 | } 15 | 16 | DBUS_SESSION_BUS_ADDRESS=$(rc-service --user dbus socket) 17 | command="/usr/bin/pipewire" 18 | command_background="true" 19 | pidfile="${XDG_RUNTIME_DIR}/pipewire.pid" 20 | -------------------------------------------------------------------------------- /support/user.d.examples/ssh-agent.in: -------------------------------------------------------------------------------- 1 | #!@SBINDIR@/openrc-run --user 2 | # Copyright (c) 2024 The OpenRC Authors. 3 | # See the Authors file at the top-level directory of this distribution and 4 | # https://github.com/OpenRC/openrc/blob/HEAD/AUTHORS 5 | # 6 | # This file is part of OpenRC. It is subject to the license terms in 7 | # the LICENSE file found in the top-level directory of this 8 | # distribution and at https://github.com/OpenRC/openrc/blob/HEAD/LICENSE 9 | # This file may not be copied, modified, propagated, or distributed 10 | # except according to the terms contained in the LICENSE file. 11 | 12 | SSH_AUTH_SOCK="${XDG_RUNTIME_DIR}/ssh-agent.sock" 13 | 14 | command="/usr/bin/ssh-agent" 15 | command_args="-D -a $SSH_AUTH_SOCK" 16 | command_background=yes 17 | pidfile="${XDG_RUNTIME_DIR}/ssh-agent.pid" 18 | 19 | extra_commands="socket" 20 | socket() { 21 | echo ${SSH_AUTH_SOCK} 22 | } 23 | -------------------------------------------------------------------------------- /support/user.d.examples/wireplumber.in: -------------------------------------------------------------------------------- 1 | #!@SBINDIR@/openrc-run --user 2 | # Copyright (c) 2024 The OpenRC Authors. 3 | # See the Authors file at the top-level directory of this distribution and 4 | # https://github.com/OpenRC/openrc/blob/HEAD/AUTHORS 5 | # 6 | # This file is part of OpenRC. It is subject to the license terms in 7 | # the LICENSE file found in the top-level directory of this 8 | # distribution and at https://github.com/OpenRC/openrc/blob/HEAD/LICENSE 9 | # This file may not be copied, modified, propagated, or distributed 10 | # except according to the terms contained in the LICENSE file. 11 | 12 | depend() { 13 | need pipewire dbus 14 | } 15 | 16 | DBUS_SESSION_BUS_ADDRESS=$(rc-service --user dbus socket) 17 | command="/usr/bin/wireplumber" 18 | command_background=true 19 | pidfile="${XDG_RUNTIME_DIR}/wireplumber.pid" 20 | -------------------------------------------------------------------------------- /sysctl.d/README: -------------------------------------------------------------------------------- 1 | Kernel system variables configuration files 2 | 3 | Files found under the /etc/sysctl.d directory that end with .conf are 4 | parsed within sysctl(8) at boot time. If you want to set kernel variables 5 | you can either edit /etc/sysctl.conf or make a new file. 6 | 7 | The filename isn't important, but don't make it a package name as it may clash 8 | with something the package builder needs later. The file name must end 9 | with .conf, or it will not be read. 10 | 11 | The recommended location for local system settings is /etc/sysctl.d/local.conf 12 | but as long as you follow the rules for the name of the file, anything will 13 | work. see the sysctl.conf(5) man page for details of the format. 14 | -------------------------------------------------------------------------------- /sysctl.d/meson.build: -------------------------------------------------------------------------------- 1 | sysctl_data = [ 2 | 'README', 3 | ] 4 | 5 | sysctldir = get_option('sysconfdir') / 'sysctl.d' 6 | install_data(sysctl_data, install_dir : sysctldir) 7 | -------------------------------------------------------------------------------- /test/check-obsolete-functions.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | top_srcdir=${SOURCE_ROOT:-..} 4 | . ${top_srcdir}/test/setup_env.sh 5 | 6 | ebegin "Checking for obsolete functions" 7 | out=$(cd ${top_srcdir}; find src -name '*.[ch]' \ 8 | ! -name queue.h \ 9 | -exec grep -n -E '\<(malloc|memory|sys/(errno|fcntl|signal|stropts|termios|unistd))\.h\>' {} +) 10 | [ -z "${out}" ] 11 | eend $? "Avoid these obsolete functions:"$'\n'"${out}" 12 | -------------------------------------------------------------------------------- /test/check-spacing-style.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | top_srcdir=${SOURCE_ROOT:-..} 4 | . ${top_srcdir}/test/setup_env.sh 5 | 6 | ebegin "Checking spacing style" 7 | out=$(cd ${top_srcdir}; find src -name '*.[ch]' \ 8 | ! -name queue.h \ 9 | -exec grep -n -E \ 10 | -e '\<(for|if|switch|while)\(' \ 11 | -e '\<(for|if|switch|while) \( ' \ 12 | -e ' ;' \ 13 | -e '[[:space:]]$' \ 14 | -e '\){' \ 15 | -e '(^|[^:])//' \ 16 | {} +) 17 | [ -z "${out}" ] 18 | eend $? "These lines violate style rules:"$'\n'"${out}" 19 | -------------------------------------------------------------------------------- /test/check-trailing-newlines.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | top_srcdir=${SOURCE_ROOT:-..} 4 | . ${top_srcdir}/test/setup_env.sh 5 | 6 | ebegin "Checking trailing newlines in code" 7 | out=$(cd ${top_srcdir}; 8 | for f in $(find */ -name '*.[ch]') ; do 9 | while read -r line; do 10 | if [ -n "${line}" ]; then 11 | blankline= 12 | else 13 | blankline=1 14 | fi 15 | done < "${f}" 16 | [ -n "${blankline}" ] && printf "%s\n" "${f}" 17 | done) 18 | [ -z "${out}" ] 19 | eend $? "Trailing newlines need to be deleted:"$'\n'"${out}" 20 | -------------------------------------------------------------------------------- /test/check-trailing-whitespace.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | top_srcdir=${SOURCE_ROOT:-..} 4 | . ${top_srcdir}/test/setup_env.sh 5 | 6 | ebegin "Checking trailing whitespace in code" 7 | # XXX: Should we check man pages too ? 8 | out=$(cd ${top_srcdir}; find */ \ 9 | '(' -name '*.[ch]' -o -name '*.in' -o -name '*.sh' ')' \ 10 | -exec grep -n -E '[[:space:]]+$' {} +) 11 | [ -z "${out}" ] 12 | eend $? "Trailing whitespace needs to be deleted:"$'\n'"${out}" 13 | -------------------------------------------------------------------------------- /test/check-xfunc-usage.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | top_srcdir=${SOURCE_ROOT:-..} 4 | . ${top_srcdir}/test/setup_env.sh 5 | 6 | ebegin "Checking for x* func usage" 7 | out=$(cd ${top_srcdir}; find src -name '*.[ch]' \ 8 | ! -name queue.h \ 9 | -exec grep -n -E '\<(malloc|strdup)[[:space:]]*\(' {} + \ 10 | | grep -v \ 11 | -e src/shared/helpers.h \ 12 | -e src/libeinfo/libeinfo.c) 13 | 14 | [ -z "${out}" ] 15 | eend $? "These need to be using the x* variant:"$'\n'"${out}" 16 | -------------------------------------------------------------------------------- /test/meson.build: -------------------------------------------------------------------------------- 1 | if meson.version().version_compare('>=0.56.0') 2 | build_root = meson.project_build_root() 3 | source_root = meson.project_source_root() 4 | else 5 | build_root = meson.build_root() 6 | source_root = meson.source_root() 7 | endif 8 | 9 | test_env = [ 10 | 'BUILD_ROOT=' + build_root, 11 | 'SOURCE_ROOT=' + source_root 12 | ] 13 | 14 | check_obsolete_functions = find_program('check-obsolete-functions.sh') 15 | check_spacing_style = find_program('check-spacing-style.sh') 16 | check_trailing_newlines = find_program('check-trailing-newlines.sh') 17 | check_trailing_whitespace = find_program('check-trailing-whitespace.sh') 18 | check_xfunc_usage = find_program('check-xfunc-usage.sh') 19 | 20 | test('check for obsolete functions', check_obsolete_functions, env : test_env) 21 | test('check spacing style', check_spacing_style, env : test_env) 22 | test('check trailing newlines', check_trailing_newlines, env : test_env) 23 | test('check trailing whitespace', check_trailing_whitespace, env : test_env) 24 | test('check xfunc usage', check_xfunc_usage, env : test_env) 25 | 26 | subdir('units') 27 | -------------------------------------------------------------------------------- /test/setup_env.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ -z "${BUILD_ROOT}" ] ; then 4 | printf "%s\n" "You must export BUILD_ROOT before sourcing this file" >&2 5 | exit 1 6 | fi 7 | 8 | if [ -z "${SOURCE_ROOT}" ] ; then 9 | printf "%s\n" "You must export SOURCE_ROOT before sourcing this file" >&2 10 | exit 1 11 | fi 12 | 13 | if [ ! -f ${BUILD_ROOT}/sh/functions.sh ] ; then 14 | printf "%s\n" "functions.sh not yet created !?" >&2 15 | exit 1 16 | elif ! . ${BUILD_ROOT}/sh/functions.sh; then 17 | printf "%s\n" "Sourcing functions.sh failed !?" >&2 18 | exit 1 19 | fi 20 | 21 | PATH="${BUILD_ROOT}"/src/einfo:${PATH} 22 | -------------------------------------------------------------------------------- /test/units/check-sh-yesno.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Copyright (c) 2008-2015 The OpenRC Authors. 3 | # See the Authors file at the top-level directory of this distribution and 4 | # https://github.com/OpenRC/openrc/blob/HEAD/AUTHORS 5 | # 6 | # This file is part of OpenRC. It is subject to the license terms in 7 | # the LICENSE file found in the top-level directory of this 8 | # distribution and at https://github.com/OpenRC/openrc/blob/HEAD/LICENSE 9 | # This file may not be copied, modified, propagated, or distributed 10 | # except according to the terms contained in the LICENSE file. 11 | 12 | top_srcdir=${SOURCE_ROOT:-..} 13 | . $top_srcdir/test/setup_env.sh 14 | 15 | ret=0 16 | 17 | tret=0 18 | for f in yes YES Yes true TRUE True 1 ; do 19 | if ! yesno $f; then 20 | : $(( tret += 1 )) 21 | echo "!$f!" 22 | fi 23 | done 24 | for f in no NO No false FALSE False 0 ; do 25 | if yesno $f; then 26 | : $(( tret += 1 )) 27 | echo "!$f!" 28 | fi 29 | done 30 | : $(( ret += $tret )) 31 | 32 | eend $ret 33 | exit $ret 34 | -------------------------------------------------------------------------------- /test/units/meson.build: -------------------------------------------------------------------------------- 1 | is_older_than = find_program('check-is-older-than.sh') 2 | sh_yesno = find_program('check-sh-yesno.sh') 3 | 4 | test('is_older_than', is_older_than, env : test_env) 5 | test('sh_yesno', sh_yesno, env : test_env) 6 | -------------------------------------------------------------------------------- /tools/meson_final.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | set -u 5 | 6 | rc_libexecdir="$1" 7 | sbindir="$2" 8 | os="$3" 9 | sysvinit="$4" 10 | 11 | if [ "${os}" != Linux ]; then 12 | install -d "${DESTDIR}/${rc_libexecdir}"/init.d 13 | fi 14 | install -m 644 "${MESON_BUILD_ROOT}/src/shared/version" "${DESTDIR}/${rc_libexecdir}" 15 | if [ "${os}" = Linux ] && [ "${sysvinit}" = yes ]; then 16 | ln -sf openrc-init "${DESTDIR}/${sbindir}"/init 17 | fi 18 | -------------------------------------------------------------------------------- /zsh-completion/_openrc: -------------------------------------------------------------------------------- 1 | #compdef openrc 2 | 3 | if (( CURRENT == 2 )); then 4 | _values "runlevels" $(rc-status --list) 5 | fi 6 | 7 | # vim: set et sw=2 ts=2 ft=zsh: 8 | -------------------------------------------------------------------------------- /zsh-completion/_rc-service: -------------------------------------------------------------------------------- 1 | #compdef rc-service 2 | 3 | _rc_services() { 4 | if [[ -n "${opt_args[(i)-l|--list]}" ]]; then 5 | _nothing 6 | else 7 | _values 'service' $(rc-service -l) 8 | fi 9 | } 10 | 11 | _rc_actions() { 12 | local service="${line[1]}" 13 | 14 | if [[ -n "${opt_args[(i)-e|--exists|-r|--resolve]}" ]] || ! $(rc-service -e $service) ; then 15 | _nothing 16 | else 17 | local -a actions=(${(f)"$(rc-service -C $service describe 2>&1)"}) 18 | shift actions 19 | actions=(${actions# \* }) 20 | actions=(${actions/:*}) 21 | actions=(stop start restart describe zap ${actions[@]}) 22 | _describe -V 'action' actions 23 | fi 24 | 25 | } 26 | 27 | _arguments -C -s \ 28 | '(-e --exists)'{-e,--exists}'[tests if the service exists or not]' \ 29 | '(-l --list)'{-l,--list}'[list all available services]' \ 30 | '(-r --resolve)'{-r,--resolve}'[resolve the service name to an init script]' \ 31 | '(-C --nocolor)'{-C,--nocolor}'[Disable color output]' \ 32 | '(-v --verbose)'{-v,--verbose}'[Run verbosely]' \ 33 | '(-q --quiet)'{-q,--quiet}'[Run quietly]' \ 34 | '1:service:_rc_services' \ 35 | '2:action:_rc_actions' 36 | 37 | # vim: set et sw=2 ts=2 ft=zsh: 38 | -------------------------------------------------------------------------------- /zsh-completion/_rc-status: -------------------------------------------------------------------------------- 1 | #compdef rc-status 2 | 3 | _arguments -s \ 4 | {'(--all)-a','(-a)--all'}'[Show services at all runlevels]' \ 5 | {'(--crashed)-c','(-c)--crashed'}'[Show crashed services]' \ 6 | {'(--list)-l','(-l)--list'}'[Show list of runlevels]' \ 7 | {'(--runlevel)-r','(-r)--runlevel'}'[Show the name of the current runlevel]' \ 8 | {'(--servicelist)-s','(-s)--servicelist'}'[Show all services]' \ 9 | {'(--unused)-u','(-u)--unused'}'[Show services not assigned to any run level]' \ 10 | {'(--help)-h','(-h)--help'}'[Print this help output]' \ 11 | {'(--nocolor)-C','(-C)--nocolor'}'[Disable color output]' \ 12 | {'(--version)-V','(-V)--version'}'[Display software version]' \ 13 | {'(--verbose)-v','(-v)--verbose'}'[Run verbosely]' \ 14 | {'(--quiet)-q','(-q)--quiet'}'[Run quietly (Does not affect errors)]' 15 | 16 | _values 'runlevels' $(rc-status --list) 17 | 18 | # vim: set et sw=2 ts=2 ft=zsh: 19 | -------------------------------------------------------------------------------- /zsh-completion/_rc-update: -------------------------------------------------------------------------------- 1 | #compdef rc-update 2 | 3 | local used_init 4 | used_init=(${=${(M)${(f)"$(rc-update show 2>/dev/null)"}:#*|*[a-z]*}% |*}) 5 | 6 | if (( CURRENT == 2 )); then 7 | _values "rc-update actions" \ 8 | 'add[Add script to a runlevel]' \ 9 | 'del[Delete script from a runlevel]' \ 10 | 'show[Show scripts in a runlevel]' \ 11 | '-a[Process all runlevels]' \ 12 | '-s[Stack a runlevel instead of a service]' 13 | elif (( CURRENT == 3 )); then 14 | case "$words[2]" in 15 | add) 16 | _values "service" $(rc-service --list) 17 | ;; 18 | del) 19 | _values "service" $used_init 20 | ;; 21 | show) 22 | _values "runlevels" $(rc-status --list) \ 23 | '-v[Show all service scripts]' \ 24 | '--verbose[Show all service scripts]' 25 | ;; 26 | esac 27 | elif (( CURRENT == 4 )); then 28 | _values "runlevels" $(rc-status --list) 29 | fi 30 | 31 | # vim: set et sw=2 ts=2 ft=zsh: 32 | -------------------------------------------------------------------------------- /zsh-completion/meson.build: -------------------------------------------------------------------------------- 1 | if get_option('zsh-completions') 2 | zsh_completions = [ 3 | '_openrc', 4 | '_rc-service', 5 | '_rc-status', 6 | '_rc-update', 7 | ] 8 | 9 | install_data(zsh_completions, 10 | install_dir : get_option('datadir') / 'zsh/site-functions') 11 | endif 12 | --------------------------------------------------------------------------------