Commit Graph

479 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
William Hubbs
838c9efb36 Remove gentoo's net.* scripts
It has been determined that it will be best for gentoo's net.* scripts
to be in a separate package to allow independent development.
This package will be called netifrc and maintained by Gentoo.
2013-08-13 16:33:41 -05:00
Dirk Sondermann
e90dcf39dd tmpfiles: do not signal an error if device nodes already exist
X-Gentoo-Bug: 478336
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=478336
2013-07-27 10:53:32 -05:00
William Hubbs
bee59c68c5 rc-cgroup: make sure the tasks file exists before adding the pid 2013-07-25 20:33:51 -05:00
William Hubbs
e9189cd8a2 tmpfiles: add --prefix and --exclude-prefix options 2013-07-25 00:58:38 -05:00
William Hubbs
19579687fd tmpfiles: make b and c commands set ownership and permissions
The b and c commands in tmpfiles.sh were not setting ownership and
permissions for the device nodes.
2013-07-23 17:58:42 -05:00
Hank Leininger
3af434a4e9 typo fix
X-Gentoo-Bug: 477006
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=477006
2013-07-16 17:12:45 -05:00
William Hubbs
a7a6092f01 cgroups: change '$$' to 0 for consistency 2013-07-05 11:04:45 -05:00
William Hubbs
88cdcc145e Merge branch 'cgroup.systemd'
Conflicts:
	sh/rc-cgroup.sh.in
2013-07-05 10:38:51 -05:00
Alexander V Vershilov
992807de55 Put a service on into a top hierarchy of each cgroup
This change will fix unwanted cgroup inheriting from user cgroups,
and fixes issues with systemd cgroup tracking by logind.

However this fix can lead to incorrect work for some user cgroup
controllers - so more advanced solution, that coveres such cases
will be created later.

Thanks to Fabio Erculiani (lxnay) for testing and general idea.
2013-07-01 09:18:02 +04:00
William Hubbs
2391ddff77 cgroups: add support for systemd cgroup hierarchy
The systemd cgroup hierarchy support is being added so we can run
logind outside of systemd. This is needed because software that was
using consolekit is now migrating to logind.
We do not create this hierarchy, we just add services to it if it
exists.
2013-06-25 10:58:27 -05:00
Alexander V Vershilov
9f14fd7ae1 Fix quoting in cgroup-release-agent 2013-06-16 14:22:23 -05:00
Alexander V Vershilov
dce989e96d cgroups: hide messages about non-existent processes 2013-06-16 14:14:30 -05:00
William Hubbs
e451d173fa runscript.sh: run cgroup_cleanup automatically after stop 2013-05-25 21:04:10 -05:00
Alexander V Vershilov
b5cb1f5020 rc_cgroup.sh: fix typo
This fixes an incorrect variable assignment in cgroup_get_pids
2013-05-25 19:58:08 -05:00
William Hubbs
248434329b fix setfont detection in early startup on Linux
Most of the time, setfont is an external command (part of the kbd
package), but it can also be a builtin if busybox is being used. This
corrects the test in early startup to work for both cases. I would like
to thank Steve L. for pointing this out.
2013-05-05 13:47:45 -05:00
Alexander Vershilov
c984506537 add cgroup cleanup support
This adds the ability to kill all processes within a service's cgroup
when that service is stopped or restarted.
2013-04-25 16:59:19 -05:00
William Hubbs
9314ac64ea migrate-to-run: fix test for successful migration
This script originally tested the file system type for the source
location of the data we were migrating to determine if the migration was
complete. Now we test the destination, and if the softlevel file is
there the migration was successful.

Reported-by: Piotr Karbowski <piotr.karbowski@gmail.com>
2013-04-03 11:25:19 -05:00
William Hubbs
6794441224 Make fuser command time out
This avoids situations in which fuser hangs because of open files on
remote file systems when the remote system goes down.
I have also passed this bug on to the maintainers of psmisc since it
should really be fixed in fuser.
This is based on a patch submitted by evermind@tuxfamily.org

Reported-by: evermind@tuxfamily.org
X-Gentoo-Bug: 455458
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=455458
2013-03-12 12:57:44 -05:00
William Hubbs
274d6eee66 tmpfiles: add support for the new X line type
tmpfiles now has a new line type, X, which is similar to the x line type
used by the cleanup function.
This is not supported yet by OpenRc, because we do not have the cleanup
function in tmpfiles.sh, so I have added a dummy procedure for it so
we don't get complaints about this line type.

Reported-by: mgorny@gentoo.org
X-Gentoo-Bug: 460880
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=460880
2013-03-11 01:03:06 -05:00
Andrew Gregory
a82a2b5f7c include BINDIR and SBINDIR in the sanitized PATH
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
2013-02-23 20:30:40 -06:00
Andrew Gregory
8a44067838 Fix shebangs in services to point to the correct location of runscript
SBINDIR and BINDIR can be set independently of PREFIX.  This fixes
broken shebangs in service files when SBINDIR is set to something other
than PREFIX/sbin

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
2013-02-23 20:30:39 -06:00
William Hubbs
fac96b4df4 cgroups: major update to cgroups support
This reworks cgroups support so we have one variable in rc.conf for each
controller instead of each setting.

Also we add support for all of the possible cgroup controllers.

I would like to thank Alexander Vershilov for his help with testing and
reworking this code.
2013-02-19 17:09:30 -06:00
William Hubbs
ebf85d598e cgroups: fix shebang line in rc-cgroup.sh 2013-02-19 16:52:49 -06:00
Andrew Gregory
cd4becf6cd make init.sh and init-early.sh honor SYSCONFDIR
Fixes hardcoded paths that break when built with SYSCONFDIR
set to anything other than /etc/

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
2013-02-16 19:56:47 -06:00
Andrew Gregory
746bf5f783 consolefont: use setfont to save the current font
Using setfont directly to save the font prevents breakage
when a distro stores consolefonts in a location other than
/usr/share/consolefonts such as Arch which stores them in
/usr/share/kbd/consolefonts

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
2013-02-16 19:51:15 -06:00
Alexander Vershilov
b46747f998 Add module for cgroup processing
sh/rc-cgroup.sh.in: new script to handle cgroup processing
sh/rc-cgroup.sh.in: do not use grep or cut (modification by William Hubbs)
sh/runscript.sh.in: use the cgroup script
2013-02-16 01:28:35 -06:00
Mike Frysinger
8328b88360 rc-functions.sh: add ceph to net fs list
X-Gentoo-Bug: 452552
X-Gentoo-Bug-URL: https://bugs.gentoo.org/452552
Reported-by: Tomas Mozes <hydrapolic@gmail.com>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2013-01-16 22:17:45 -05:00
William Hubbs
cb31b13276 typo fix 2013-01-15 12:36:12 -06:00
William Hubbs
6b3a4110cc runscript: fix stopping changed service issues
If an init script or service was upgraded while it was running and the
settings for the pid file, command and process name were changed, it
would not be possible to stop the old service.

Runscript now saves the values it used to start the service and re-uses
them to stop the service.

Reported-by: flameeyes@gentoo.org
X-Gentoo-Bug: 434032
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=434032
2013-01-15 12:14:05 -06:00
William Hubbs
7bda62d844 udhcpc: fix resolv.conf setting for domain
The value that was supposed to be in the domain setting was being added
incorrectly to search.

Reported-by: bug@mejor.pl
X-Gentoo-Bug: 446862
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=446862
2012-12-22 09:38:38 -06:00
William Hubbs
b00f85864d Set a default size for /run on Linux
Reported-by: alpiturchi@gmail.com
X-Gentoo-Bug: 447076
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=447076
2012-12-22 08:37:45 -06:00
William Hubbs
b44f96ac9b init.sh.Linux: do not try to remove the /run/openrc symlink
In order to make migration from /lib*/rc/init.d to /run/openrc possible
without rebooting, the migration script creates a symlink from
/run/openrc to /lib*/rc/init.d. We were trying to remove it on the next
reboot, but this is not possible since / is ro when /run is mounted.

Reported-by: fturco@fastmail.fm
X-Gentoo-Bug: 447678
X-Gentoo-Bug-URL: http://bugs.gentoo.org/show_bug.cgi?id=447678
2012-12-19 11:42:32 -06:00
William Hubbs
230a678824 init-linux: Do not remove the $rc_libexecdir/init.d directory
Reported-by: toralf.foerster@gmx.de
X-Gentoo-Bug: 446342
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=446342
2012-12-07 09:39:12 -06:00
William Hubbs
e5173b9127 migrate-to-run: do not require a reboot
The script that migrates the @libexecdir@/rc/init.d directory to
/run/openrc should not require a reboot.

Reported-by: chainsaw@gentoo.org
2012-12-06 16:43:24 -06:00
William Hubbs
a9272f50f7 Do not add a prefix to the /run directory
This doesn't affect us on gentoo, but on archlinux, which has done the
/usr merge, OpenRC was looking for /run under PREFIX. /run is always at
the root level, so it shouldn't have prefix appended to it.

Reported-by: udeved@openrc4arch.site40.net
2012-12-03 18:33:21 -06:00
William Hubbs
0a72893c8b migrate-to-run: Remove old RC_SVCDIR after unmounting tmpfs
reporrrrted-by: netfab@gmail.com
X-Gentoo-Bug: 443996
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=443996
2012-11-25 21:27:36 -06:00
Alexander Vershilov
4f19c2f512 Support cpu usage management for Linux
This commit was modified by William Hubbs as follows:

- The paths in the cgroup fs were put into variables to ease
  maintenance.
- Documentation was added to rc.conf.Linux.
- The services were added originally to openrc/svcname cgroups under the
  controller cgroups, but this left an "openrc" cgroup which was unused.
  Now they are added to individual cgroups with the name openrc_${RC_SVCNAME}.
2012-11-12 10:58:00 -06:00
Robin H. Johnson
23f975dfcd checkbashisms: Fix redirection order.
Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
2012-11-07 01:44:56 +00:00
Robin H. Johnson
1b0130961e checkbashisms: clean up export statements.
Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
2012-11-07 00:22:33 +00:00
William Hubbs
ec60e20331 tmpfiles: fix bashism
reported-by: <pesa@gentoo.org>
2012-11-06 16:32:59 -06:00
Robin H. Johnson
4936b72e0f tmpfilesd: Doing both create+remove at the same time is valid.
Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
2012-11-05 21:25:32 +00:00
Andrew Gregory
525c731f0e tmpfilesd: parse arguments with spaces
systemd allows the final arg in tmpfiles to contain spaces.  Using the read()
call to set the variables includes all trailing components in $arg so it
doesn't get cut off.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
2012-10-21 19:50:54 -05:00
Andrew Gregory
5647946e61 tmpfiles: return success from _f/_F on empty $arg
'[ -n "$arg" ] && _w' causes _f/_F to return the failure from the test when
$arg is empty.  Inverting the test causes the test and _f/_F to return success.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
2012-10-21 19:49:42 -05:00
William Hubbs
74c6b554bc tmpfiles: do not process systemd.conf
This file contains definitions specific to systemd, so we should not
process it.

Reported-by: <andrew.gregory.8@gmail.com>
2012-10-21 14:50:29 -05:00
William Hubbs
f886372749 functions.sh: do not hard code path in e* wrapper functions
We should use the "command" shell builtin to execute a binary from
within the wrapper with the same name. Hard coding the path to the
binary makes our test suite fail.
2012-10-17 17:55:02 -05:00
Robin H. Johnson
4ff71bd741 tmpfiles.d init.d scripts
Now that the tmpfiles.d code is more tested, actually call it from
init.d. It assumes that /run is already available when it runs.

Please note it runs TWICE.
- During sysinit, ideally just after /dev/shm is created, but before
  udev has started. After udev is also acceptable, but not ideal.
- During boot, ideally just after localmount has completed.

Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
2012-09-26 15:42:37 -07:00
Robin H. Johnson
5c736ad63e sh/tmpfiles.sh: Improve dry-run mode.
Dry-run with more detail is more useful this way.

Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
2012-09-26 15:14:04 -07:00
William Hubbs
5615fa78d6 Drop restart_pre/restart_post
By design, restart is hard coded to run stop followed by start along
with all of the pre/post functions associated with them. Restart doesn't
need its own pre/post functions since it is possible to make any
function in an init script behave differently for a restart command by
testing against the RC_CMD environment variable.
2012-09-25 10:22:47 -05:00
Christian Ruppert
0406c6085b Add restart_pre/restart_post support, also document RC_CMD 2012-09-22 16:57:46 +02:00
Robin H. Johnson
c8703354e3 sh/tmpfiles: fix quoting for optional arguments
Some optional arguments were missing quotes in the tests, so produced
spurious warnings.

Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
2012-08-16 18:45:23 +00:00
William Hubbs
a5b4fab732 fix handling of /run for vserver
Mount can't be used in vservers, but /run is still needed. So we create
the directory and clear it out instead of mounting a tmpfs in that
situation.

reported-by: <patrick@gentoo.org>
X-Gentoo-Bug: 423739
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=423739
2012-07-02 13:22:04 -05:00
Christian Ruppert
6cecc7b4a6 local is only allowed in functions 2012-05-17 00:00:22 +02:00
William Hubbs
82d3918d7a move rc_svcdir to /run/openrc on Linux systems
If you are not using linux, this should not affect you.

If you are using linux, from this point forward, openrc requires the
/run directory to be a mounted tmpfs. If it is, you can run
@LIBEXECDIR@/sh/migrate-to-run.sh as root to migrate your dependency
tree and state information to the new location. If it is not, you must
create the /run directory as root with permissions 755 then reboot your
system.

reported-by: Maxim Kammerer <mk@dee.su>
X-Gentoo-Bug: 401059
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=401059
2012-05-14 13:49:06 -05:00
William Hubbs
9e196a71ad clarify the message about /proc being already mounted
This message was being taken by some users as an error, so I have
removed the part about "skipping..." Hopefully this will make the
message less alarming.
2012-05-02 14:48:52 -05:00
William Hubbs
8c82637e76 fix references to functions.sh
There were a couple of places where we were sourcing functions.sh in
@SYSCONFDIR@/init.d. This is only a backward compatibility symlink, so
it should not be used for openrc. The correct place to source this from
is @LIBEXECDIR@/sh.
2012-04-26 12:56:44 -05:00
William Hubbs
8d63719418 Change the working directory for depend only
We already have a special case for depend processing, so we should
change the working directory there only. This prevents us from forcing
all init scripts to be run in the init directory.
2012-04-26 12:19:42 -05:00
William Hubbs
3967077da3 Revert "Revert "Let runscript enter the service dir before expand globs""
This reverts commit f971c4c0b5.
After further discussion, this is a good first step toward a fix, so I
am putting it back.
2012-04-26 12:11:58 -05:00
William Hubbs
f971c4c0b5 Revert "Let runscript enter the service dir before expand globs"
This reverts commit 9d0dce35c3.
This is being reverted due to the fix still being under discussion.
2012-04-26 11:28:02 -05:00
Christian Ruppert
9d0dce35c3 Let runscript enter the service dir before expand globs
Enter the service directory, like gendeps.sh does, to make sure globs are
expanded in it rather than in /. That makes sure that globbing like "need *"
will end up in all files of the init.d directory.

Signed-off-by: Christian Ruppert <idl0r@gentoo.org>

Reported-by: Guenther Brunthaler <gb_about_gnu@gmx.net>
X-Gentoo-Bug: 412677
X-Gentoo-Bug-URL: https://bugs.gentoo.org/412677
2012-04-26 15:18:56 +02:00
Robin H. Johnson
65be94a34a sh/tmpfiles: Upstream clarifications & quoting fixes.
Upstream has clarified via IRC:
- hardcoding /usr/lib/ is an explicit choice. It should NOT consider
  $libdir at all.
- The z/Z relabel types should call restorecon, not chcon.
- Whitespace is not allowed in tmpfiles.d/*.conf path entries,
  but is allowed in globs results. Fixed quoting of path arguments for
  this.

Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
2012-03-12 12:04:30 -07:00
Robin H. Johnson
c75352af3d sh/tmpfiles: tmpfiles.d support.
This is the baseline support for tmpfiles.d.

Still missing:
- SELinux relabel, pending upstream clarification
- LIBDIR vs multilib systems, pending upstream clarification
- Whitespace in paths?
- Clean support not implemented
- "x" exclude type not implemented

X-Gentoo-Bug: 396003
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=396003
Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
2012-03-12 01:37:31 -07:00
William Hubbs
9fa54a8e80 Runscript: allow extra_commands to be run in chroots
The commands defined in the extra_commands variable do not depend on
whether the service is stopped or started, so it is valid to run them in
chroot environments.

Also, add a note to the runscript man page about the commands in
extra_commands being able to run whether or not the service is started.

Reported-by: Robin Johnson <robbat2@gentoo.org>
X-Gentoo-Bug: 406713
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=406713
2012-03-03 09:22:44 -06:00
William Hubbs
9e3fc7f3f5 update ignore patterns 2012-02-20 17:07:43 -06:00
Robin H. Johnson
f5e7e76852 Fix early consolefont/termencoding usage vs rc_sys
During early boot, the keywords were not being checked for
consolefont/termencoding and they were running anyway when they should
not be.

X-Gentoo-Bug: 400549
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=400549
Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
2012-02-09 01:53:46 -08:00
William Hubbs
cea71369e9 cgroups: only create the cgroup when the service is being started 2012-01-29 09:47:43 -06:00
Christian Ruppert
fb4aa20d05 Use "checkpath -W" instead of dir_writable() 2012-01-28 19:32:05 +01:00
Christian Ruppert
5a8344a3d1 Check if /sys/fs/cgroup/openrc is writable 2012-01-28 19:26:00 +01:00
William Hubbs
ab9cf25197 cgroups: add all services to the openrc cgroup
This is a modified version of a patch originally submitted by
Patrick Lauer <patrick@gentoo.org>.
2012-01-26 22:09:07 -06:00
William Hubbs
6e2fbf6a0f Make checks for writable directory posix compliant
Reported-by: Maxim Kammerer <mk@de.su>
X-Gentoo-Bug: 398931
X-Gentoo-Bug-URL: http://bugs.gentoo.org/show_bug.cgi?id=398931
2012-01-22 11:56:24 -06:00
William Hubbs
c529a57650 drop the extra --pidfile option 2012-01-17 12:04:20 -06:00
Christian Ruppert
9c0edc5c52 Use the "--make-pidfile" when command_background is used
The start-stop-daemon "--make-pidfile" option is now used by default when using
command_background, this requires a pidfile to be specified.
Document command_background option.

Reported-by: Giampaolo Tomassoni <giampaolo@tomassoni.biz>
X-Gentoo-Bug: 399165
X-Gentoo-Bug-URL: https://bugs.gentoo.org/399165
2012-01-17 18:25:44 +01:00
Christian Ruppert
fb8db18d79 Add "retry" option for the stop() template 2011-12-31 02:41:59 +01:00
William Hubbs
ed4605bf9f cgroups: remove references to the "openrc" cgroup
Openrc will set up cgroups the way the kernel documentation recommends.
2011-12-19 21:54:53 -06:00
William Hubbs
5e01051c4e Allow init scripts to be executed with a relative path
This was a regression that was caused by the fix for
http://bugs.gentoo.org/show_bug.cgi?id=350910. I am reverting the commit
that we said fixed that bug and re-opening it.

Reported-By: Nathaniel <nathaniel@paust.us
X-Gentoo-Bug: 392457
X-Gentoo-Bug-URL: http://bugs.gentoo.org/show_bug.cgi?id=392457
2011-12-11 01:18:08 -06:00
William Hubbs
d8bbeb184f CGroups: create the openrc cgroup hierarchy
Openrc will create a cgroup hierarchy called openrc which will have all
services it starts and all subsystems attached to it. If you need other
groups/hierarchies, please use libcgroup.
2011-11-20 14:07:46 -06:00
Mike Frysinger
ef1ff1b4f2 make shell math operations style more succulent
Convert the style:
	var=$((${var} + 1))
to:
	: $(( var += 1 ))

The latter is easier to read imo.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2011-11-19 02:25:36 -05:00
William Hubbs
0510c473d4 CGroups: /sys/fs/cgroups should be a tmpfs
The kernel documentation states that a cgroup file system should not be
mounted here, but a tmpfs.

This also means that we should not create a group for each process, but
we should allow the user to specify which group a process should be
assigned to. The rc_cgroup variable will be used for this purpose.

For more information, see /usr/src/linux/Documentation/cgroups/cgroups.txt.
2011-11-18 17:58:37 -06:00
William Hubbs
a5ba2f3264 CGroups: fix group initialization
Make sure cpuset.cpus and cpuset.mems exist in the parent group before
attempting to copy them to the new group.
2011-11-18 08:32:06 -06:00
William Hubbs
62f4438376 CGroups: finish initializing the CGroup
When a CGroup is created, we need to copy cpuset.cpus and cpuset.mems
from the new group's parent into the new group before we can attach any
processes to it.
2011-11-17 23:55:32 -06:00
William Hubbs
0bbb764f70 Change RC_CGROUP to lower case 2011-11-17 16:42:03 -06:00
Patrick Lauer
20df56f0b2 Add CGroup support
X-Gentoo-Bug: 390297
X-Gentoo-Bug: http://bugs.gentoo.org/show_bug.cgi?id=390297
2011-11-17 16:22:59 -06:00
William Hubbs
5b1aaf8cc8 add support for extra_stopped_commands 2011-11-16 13:56:55 -06:00
William Hubbs
27713e3a41 Make sure we load external scripts before using eerror
Reported-by: Jochen Schlick <josch06@gmail.com>
X-Gentoo-Bug: 388715
X-Gentoo-Bug-URL: http://bugs.gentoo.org/show_bug.cgi?id=388715
2011-11-02 08:31:43 -05:00
William Hubbs
5066d40ac8 Use pattern rules instead of suffix rules
Rework the makefiles to use pattern rules instead of suffix rules.
This is the preferred way to write implicit rules according to the gnu
make manual.
2011-10-29 09:43:24 -05:00
Mike Frysinger
9a539ebbe1 further clean up OS differences in makefiles
No need for if() logic.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2011-10-20 14:32:37 -05:00
William Hubbs
9c77502f96 Make variable references in Makefiles consistent
Some variable references were written as $(foo), but the majority were
written as ${foo}. This commit changes all of the variable references
to using braces.
2011-10-19 12:22:23 -05:00
William Hubbs
ecf77254bb consolodate Makefiles
The tree contained many operating system specific Makefiles which were
being included in other Makefiles. This commit removes those and adds
the code to the makefiles which included them using make's conditional
processing.

X-Gentoo-Bug: 387441
X-Gentoo-Bug-URL: http://bugs.gentoo.org/show_bug.cgi?id=387441
2011-10-18 03:23:00 -05:00
Mike Frysinger
9f95878bbd fix random typos
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2011-10-16 19:02:21 -04:00
Mike Frysinger
95adeb85ba runscript: simplify livecd-functions.sh loading
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2011-09-18 15:25:51 -04:00
Christian Ruppert
e14e78db16 Revert "Mount /run as early as possible"
This reverts commit 5ed4d084d9.
/run needs to be mounted after /proc.
2011-09-12 22:15:24 -05:00
William Hubbs
b42ab3b2f4 Use checkpath to create /run/lock 2011-09-07 15:11:04 -05:00
William Hubbs
5ed4d084d9 Mount /run as early as possible
This commit moves the code that mounts /run to the earliest possible
position in openrc.
2011-09-06 21:00:08 -05:00
William Hubbs
0c8bea2152 Improve processing of service directories and conf.d files
symbolic links should not be followed in an attempt to work out the name
of the service we are running. Also, @sysconfdir@/conf.d should be tried
as a backup directory for configuration files.

I would like to thank Robin Johnson for his input on this change.

X-Gentoo-Bug: 350910
X-Gentoo-Bug-URL: http://bugs.gentoo.org/show_bug.cgi?id=350910
2011-07-31 10:00:48 -05:00
William Hubbs
df1f02ac84 Runscript: print deprecation warning for opts variable
Openrc uses the extra_commands and extra_started_commands variables to
list extra commands for services. Also, it supports the opts variable
which is used to assist migration from baselayout-1.

I am adding this warning to encourage switching from opts to
extra_commands/extra_started_commands.

I would like to remove support for opts eventually.
2011-07-26 12:19:59 -05:00
William Hubbs
9a068c2500 The is_net_fs function should use extra_net_fs_list
This was pointed out to me by Morse on #gentoo-base, so I would like to
thank him for the patch.
2011-07-06 09:53:05 -05:00
William Hubbs
e8e86b96dc fix issue with extra_net_fs_list
The extra_net_fs_list variable was not being included as it should have
been for the net file systems because it was being expanded before it
was set by the user.

X-Gentoo-Bug: 374133
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=374133
2011-07-05 18:41:33 -05:00
Mike Frysinger
49f1a8702b eat trailing whitespace
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2011-07-04 18:27:00 -04:00
William Hubbs
9076baa573 slight formatting change
Add a new line after "rc_runlevel()" for consistency.
2011-07-02 23:33:23 -05:00
Mike Frysinger
d0bc4f20ad drop useless "All rights reserved" notice
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2011-06-29 19:46:31 -04:00
William Hubbs
e8413733c1 Revert "remove functions.sh symbolic link in init.d"
This reverts commit f4407ac83d.
2011-06-27 12:11:01 -05:00