Commit Graph

385 Commits

Author SHA1 Message Date
Colin Booth
30c3561b6b sh/s6.sh: update s6-svc syntax to be valid for 2.2.0.0+
The s6-svc syntax changed for wait-up, wait-ready, wait-down, and
wait-finished. This changes the s6 handling script to use the current
valid syntax.

This fixes #65.
2016-01-19 16:52:58 -06:00
William Hubbs
000503fad7 Convert OpenRC to a centralized copyright/license structure
In the past, OpenRC was a hybrid of a centralized and file-scope
license/copyright structure.

I followed the instructions from the Software Freedom Law Center [1] to
convert to a Centralized structure where possible, for easier future
maintenance.

[1] https://softwarefreedom.org/resources/2012/ManagingCopyrightInformation.html
2015-12-21 12:16:06 -06:00
William Hubbs
cc9c23c848 Complete support for rc.conf.d
- gendepends.sh needs to read this directory to allow dependencies to be
  overridden
  - init.sh for Linux and Bsd need to read it to allow config settings
    they use to be overridden.
2015-12-09 12:38:10 -06:00
William Hubbs
627e925463 add support for -containers keyword 2015-12-03 16:52:15 -06:00
William Hubbs
bd9456ff31 rc-functions.sh: add support for user-defined want dependencies 2015-12-01 12:31:28 -06:00
Ian Stakenvicius
33d3f33b3c Implement "want" dependency
The want dependency is similar to the use dependency. If a service
script, for example called service1, adds "want service2" to its depend
function, OpenRC will attempt to start service2, if it exists on the
system,  when service1 is started.

However, service1 will start regardless of the status of
service2.

X-Gentoo-Bug: 406021
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=406021
2015-11-12 12:32:45 -06:00
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