Commit Graph

314 Commits

Author SHA1 Message Date
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