Commit Graph

379 Commits

Author SHA1 Message Date
William Hubbs
c09eeca491 Add rc.conf.d support
This makes it possible to override settings in rc.conf by adding a
directory @SYSCONFDIR@/rc.conf.d and putting files in this directory.
The files will be processed in lexical order, and the last setting in
these files will be used.
2015-11-05 10:40:24 -06:00
William Hubbs
7da72ce487 openrc-run.sh: fix new required_* tests to exit properly 2015-10-13 17:45:05 -05:00
William Hubbs
fc777aeaf3 typo fix
X-Gentoo-Bug: 563010
X-Gentoo-Bug: https://bugs.gentoo.org/show_bug.cgi?id=563010
2015-10-13 15:51:15 -05:00
William Hubbs
29f7e33592 openrc-run.sh: allow spaces in required_{files,dirs}
X-Gentoo-Bug: 562320
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=562320
2015-10-13 07:59:50 -05:00
Austin S. Hemmelgarn
80d3928b0d cgroups: Add the hugetlb, net_cls and pids controllers
Note from WilliamH: I slightly rearranged the code and added the
settings in rc.conf.

X-Gentoo-Bug: 555488
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=555488
2015-10-06 15:05:35 -05:00
William Hubbs
b20a1951ad rc-cgroup.sh: Do not add leading spaces to cgroup values
We were starting the value we write to the cgroup setting file with
leading spaces and this was causing issues. This change makes sure that
we aren't adding leading spaces to the value.

X-Gentoo-Bug: 562354
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=562354
2015-10-06 12:11:29 -05:00
William Hubbs
a59365a582 start-stop-daemon.sh: complain in start if command is undefined
The default start-stop-daemon start function expects the command
variable to be defined to point to the daemon we want to start.

If the variable is undefined, this means that there will be nothing to
start, and in this case we should complain because it is possible that
the script writer made a typo in the variable name.
2015-10-02 16:34:15 -05:00
Jason Zaman
6a42298257 tmpfiles: run restorecon on the entire path
The tmpfiles "d" entry will create a full path and only the last dir in
the path will have its SELinux label set correctly. This patch will
restorecon the parents as well so that the selinux labels are correct.

eg, "d /run/libvirt/lxc", then "lxc" would have the correct SELinux
label but "libvirt" would not.

Signed-off-by: Jason Zaman <jason@perfinion.com>
2015-08-03 12:51:16 -07:00
Mike Gilbert
a36a635b01 tmpfiles: Recognize type 'v' (create btrfs subvol)
This change does NOT implement btrfs subvol creation.  Instead, it
treats 'v' the same as 'd', which is an acceptable fallback
according to the manual.

Fixes #58
2015-06-24 22:40:35 -07:00
Mike Gilbert
9310ccc06b Remove execute bit from tmpfiles.sh.in 2015-06-24 22:40:02 -07:00
William Hubbs
a7fcc1e264 S6: kick the scanner and sleep 1.5 seconds to avoid a race condition 2015-05-14 14:26:52 -05:00
William Hubbs
b79d058f16 s6: Use s6-svc -Dd to stop services
This allows us to get rid of the sleep call in the stop function. Also,
we set a configurable timeout value for stopping daemons.
2015-05-14 11:40:29 -05:00
William Hubbs
ddce529c71 More s6 fixes
- When no service link is in the scan directory, show the default
  stopped message.
- Do not remove the service link when stopping the service.
2015-05-13 16:51:55 -05:00
William Hubbs
e372f97beb Fix the s6 handling
This changes the default s6 service directory to /var/svc.d, also
it changes the code to work with the individual services instead of
forcing a rescan when a service is started or stopped.
2015-05-13 16:10:08 -05:00
William Hubbs
bb2d7becfd Add support for the s6 supervision suite 2015-05-11 18:36:49 -05:00
William Hubbs
a15fa1a3b1 Rework supervisor integration framework
The original way of doing this allowed users to change the supervisor in
conf.d/*. This changes this so that the supervisor setup can be done in
the service script itself.
2015-05-11 09:44:06 -05:00
William Hubbs
abef2fcb2d Make the default start, stop and status functions overridable
This will make it possible to add support for supervision suites such as
runit and s6.
2015-05-08 11:39:39 -05:00
William Hubbs
c709e6077c Add support for systemd-nspawn containers
This adds support for running OpenRC in a container created by
the systemd-nspawn utility.

This fixes #52.

X-Gentoo-Bug: 548058
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=548058
2015-05-01 09:04:07 -05:00
William Hubbs
8b93492086 convert all references from runscript to openrc-run 2015-04-27 11:21:29 -05:00
William Hubbs
15ab3f39c6 cgroups: use printf to write to cgroup files
This fixes #33.
2015-04-21 11:30:24 -05:00
William Hubbs
ee1768a419 Add binfmt service to sysinit runlevel
This makes binfmt processing behave like tmpfiles processing which
follows the same specification as systemd.

This fixes #48.

X-Gentoo-Bug: 545162
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=545162
2015-04-20 17:10:07 -05:00
William Hubbs
1eab656ca1 Fix tmpfiles processing
Tmpfiles.d processing had /run overriding /usr/lib and /etc, but this is
not correct. The correct order, from lowest to highest, for tmpfiles
processing is:

* /usr/lib/tmpfiles.d/*.conf
* /run/tmpfiles.d/*.conf
* /etc/tmpfiles.d

This means /run/tmpfiles.d/*.conf can override /etc/tmpfiles.d/*.conf,
but /etc/tmpfiles.d/*.conf can override both of them.

This fixes #49.
2015-04-08 09:57:46 -05:00
William Hubbs
c068762c4c Fix rc_verbose processing
We were processing the rc_verbose setting before we sourced the
configuration file where it was set; this fixes the issue.

Fixes #46
2015-03-29 23:05:32 +00:00
William Hubbs
7e3a33c8f5 Add description for cgroup_cleanup
X-Gentoo-Bug: 535184
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=535184
2015-01-12 14:45:06 -06:00
Svante Signell
203b754f84 add missing files for GNU/Hurd 2014-10-23 13:00:24 -05:00
Gabriele Giacone
d8e1d9a6ed Add missing files for GNU/kFreeBSD 2014-10-22 11:09:58 -05:00
William Hubbs
8c7ea4e9e8 runscript.sh: add chroot support
This adds support for a chroot variable which will be passed to the
start-stop-daemon --chroot switch to runscript.sh when starting a
daemon. This also needs to be saved so it can be used in locating the
pid file when stopping the daemon.

X-Gentoo-Bug: 524388
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=524388
2014-10-20 15:44:19 -05:00
Roy Marples
50658449bd Use exception-based approach for cgroup/ulimit setup
Note from William Hubbs:
I spoke with Roy about this, and he pointed out that user-defined
functions may need the limits applied, so it is better to go with a
method that uses exceptions to determine which functions apply the
limits.

X-Gentoo-Bug: 522408
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=522408
2014-09-11 13:26:58 -05:00
William Hubbs
de60ffeebe runscript: move verbose mode setting near debug setting 2014-09-11 12:02:51 -05:00
Andrew Gregory
d4204a97a2 tmpfiles.sh: add support for C action
Recursively copies files or directories.  Added by systemd in 849958d1.
2014-08-27 17:49:00 -05:00
Andrew Gregory
6f3f50d453 tmpfiles.sh: add support for + modifier
systemd added support for b+, c+, p+, and L+ in 2e78fa79 and 1554afae to
remove the target path if it already exists.
2014-08-27 17:48:34 -05:00
William Hubbs
c8018d04a7 tmpfiles: fix relabel to run restorecon before chown and chmod 2014-08-13 15:26:37 -05:00
Jason Zaman
6f080e9c1a tmpfiles: Move relabelling before any other calls for device nodes
Device nodes are normally never device_t so this type does not
have many permissions. After the mknod, the device should have
its label corrected before any other operations (like chmod).
2014-08-13 10:02:20 -05:00
Jason Zaman
647e08eb91 tmpfiles.sh: do not use install
install is in /usr which causes problems if /usr is not mounted.
Instead, checkpath and "mkdir -p" can do everything required and are
both available before /usr is mounted.
Since checkpath also handles selinux labels correctly,
_restorecon after is not required.

X-Gentoo-Bug: 503408
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=503408
2014-08-07 12:54:04 -05:00
Jason Zaman
4f784bd469 tmpfiles: set the proper SELinux context
Restore the label on the created file / dir based on the policy
fcontexts.

X-Gentoo-Bug: 516956
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=516956
2014-07-16 10:53:25 -05:00
William Hubbs
75e06d8558 Style Fixes 2014-07-10 10:57:56 -05:00
Alexander V Vershilov
1a44be0f16 cgroups: only run cgroup setup when starting a service
Status call should not set limits as it requires root permissions,
also this is not safe, as current process may reach limitation.

Solution is to set limits and move process to service cgroup only
on start.

X-GENTOO-BUG: 500364
X-GENTOO-BUG-URL: https://bugs.gentoo.org/show_bug.cgi?id=500364
2014-07-10 10:56:37 -05:00
William Hubbs
094bc17cb0 tmpfiles.sh: fix comment processing
If you happened to format a comment with no white space after the '#',
it was not being processed.

Reported-by: consus@gmx.com
X-Gentoo-Bug: 511804
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=511804
2014-06-20 19:39:07 -05:00
Robin H. Johnson
19cccb2e94 sh/tmpfiles.sh: license under 2-clause BSD
As the author of our tmpfiles.sh script, I hereby license it under
2-clause BSD, like the rest of openrc.

Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
2014-06-20 16:19:25 -05:00
Andrew Gregory
686ee62a79 tmpfiles: add support for --boot option
For compatibility with systemd-tmpfiles.

Fixes #17

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
2014-03-27 11:36:41 -04:00
Andrew Gregory
c081633762 tmpfiles: ignore all files starting with systemd-
systemd recently moved creation of /run/nologin to systemd-nologin.conf

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
2014-03-27 11:36:41 -04:00
William Hubbs
cdc0dd061b init-Linux.sh: do not mount /run with nosuid
This is so that we will be consistent with the systemd spec forr the
/run directory mentioned in this wiki article:

http://www.freedesktop.org/wiki/Software/systemd/InitrdInterface/
2014-01-18 02:34:39 -06:00
William Hubbs
54ab12d218 Merge init-common-post code into BSD init script
This code is no longer part of the initialization script for Linux, so
we can move it into the init script for *BSD which is the only place it
is used.
2014-01-11 13:32:43 -06:00
William Hubbs
3470eda3f5 Rename runscript to openrc-run
This was requested by Debian, because the minicom software, which is
available on Debian and other distros, has a binary named runscript. We
are keeping a backward compatibility symlink for now, but this allows
Debian or any other distro to safely remove the symlink.

X-Gentoo-Bug: 494220
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=494220
2013-12-29 22:57:31 -06:00
William Hubbs
7b5fa011ac Rename the rc binary to openrc
Debian requested this rename due to the "rc" binary conflicting with the
"rc" binary from the plan 9 shell.

We also add a deprecation warning to the binary when it is run as rc to
encourage users to switch to openrc instead.

X-Gentoo-Bug: 493958
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=493958
2013-12-12 18:31:29 -06:00
William Hubbs
09733d3fae tmpfiles.sh: small fixes
Change "sort | uniq" to "sort -u". Also, change `...` to $(...).

X-Gentoo-Bug: 493736
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=493736
2013-12-10 22:34:40 -06:00
William Hubbs
60d288a877 remove type command
The posix equivalent of the type command is "command -v", so now we use
that. Thanks to Jonathan Callen <jcallen@gentoo.org> for informing me
wrt the fix.
2013-12-02 02:08:40 -06:00
Mike Frysinger
af30c4b86e functions.sh: yesno: (mostly) fix eval logic
We need to quote the expansion.

X-Gentoo-Bug: 475032
X-Gentoo-Bug: https://bugs.gentoo.org/475032
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2013-11-30 16:33:31 -05:00
William Hubbs
6965d85f2e Fix the service-level rc_verbose setting
This commit fixes the rc_verbose setting so that it is honored if it is
set for an individual service.

Thanks to whissi@whissi.de for the original patch; this one is slightly
modified to be more posix.

X-Gentoo-Bug: 489358
X-Gentoo-Bug: https://bugs.gentoo.org/show_bug.cgi?id=489358
2013-10-31 16:04:19 -05:00
William Hubbs
993e7d7044 fix cgroup_cleanup function
The yesno test for rc_cgroup_cleanup belongs at the point where this
function is called from runscript, not in the function itself.

X-Gentoo-Bug: 486210
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=486210
2013-09-27 15:55:46 -05:00