Commit Graph

72 Commits

Author SHA1 Message Date
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
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
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
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
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
William Hubbs
e451d173fa runscript.sh: run cgroup_cleanup automatically after stop 2013-05-25 21:04:10 -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
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
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
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
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
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
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
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
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
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
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
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
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
40341fcd7e do not run services if openrc did not boot the system
X-Gentoo-Bug: 364159
X-Gentoo-Bug-URL: http://bugs.gentoo.org/show_bug.cgi?id=364159
2011-05-11 14:54:41 -05:00
Mike Frysinger
faa2df1159 more whitespace cleanup
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2011-01-17 04:49:12 -05:00
Eray Aslan
66abbefd6c bug 351160: make openrc exit codes LSB compliant
* status on a stopped service now has a return code of 3 (was 1)
* starting an already started service now has a return code of 0 (was 1)
* stopping an already stopped service now has a return code of 0 (was 1)
2011-01-12 19:46:11 -06:00