Commit Graph

483 Commits

Author SHA1 Message Date
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
William Hubbs
f4407ac83d remove functions.sh symbolic link in init.d 2011-06-27 11:56:12 -05:00
Mike Frysinger
7ca74d7636 fix underquoting of wrapped color stubs of exit status
X-Gentoo-Bug: 369911
X-Gentoo-Bug-URL: http://bugs.gentoo.org/369911
Reported-by: Steve Dibb <beandog@gentoo.org>
Reported-by: Christian Ruppert <idl0r@gentoo.org>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2011-06-03 20:41:43 -04:00
Mike Frysinger
3d56124ed1 only warn about /run if it exists
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2011-05-16 18:49:21 -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
William Hubbs
b712a9161f change udhcpc support to busybox udhcpc
This updates the udhcpc support to use busybox's udhcpc instead of the
stand alone version.

I would like to thank jackieku <kjackie@gmail.com> for assisting with
this update.

X-Gentoo-Bug: 205286
X-Gentoo-Bug-URL: http://bugs.gentoo.org/show_bug.cgi?id=205286
2011-04-26 15:25:08 -05:00
William Hubbs
b6409feaac fix permissions for /run/lock
If /run/lock is a directory, set the ownership and permissions for it,
whether or not we created the directory.
2011-04-19 10:56:14 -05:00
Amadeusz Żołnowski
64ef51ab09 Add support for /run directory
This is a new directory for storing volatile runtime data.
See https://lwn.net/Articles/436012

X-Gentoo-Bug: 363971
X-Gentoo-Bug-URL: http://bugs.gentoo.org/show_bug.cgi?id=363971
2011-04-18 15:26:13 -05:00
William Hubbs
1d63e85794 rework test for mounted /proc
The previous test assumed that we could always rely on the minor fault
counter to change between reads of /proc/self/stat, but we found that
this is not the case.

The new test compares two reads of /proc/self/environ for which we have
set the same environment variable to two different values.
If the comparison shows the two reads have the same contents, we know
that /proc is not working.

I would like to thank Robin Johnson and Mike Frysinger for their input
for this patch.

X-Gentoo-Bug: 348416
X-Gentoo-Bug-URL: http://bugs.gentoo.org/show_bug.cgi?id=348416
2011-03-24 19:14:16 -05:00
Robin H. Johnson
80853f5dbc sh/init: Detect a mounted /proc without sleeping
Previously we checked if /proc was alive by reading /proc/uptime twice
with a 1 second sleep between calls, so that it had time to update.
This got a complaint of an entire 1 second delay, so we improve the
check to be much faster without sleep. We cannot continue to use
/proc/uptime as it only has a 10ms resolution.

X-Gentoo-Bug: 348416
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=348416
Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
2011-01-18 01:29:09 +00: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
William Hubbs
84eda608c8 bug 328675: add error checking to runscript.sh
runscript.sh needs to abort if the . command used to load
conf.d files and the service script does not execute successfully.
I would like to thank Mike Frysinger for his input wrt style on this
patch.
2011-01-12 19:21:48 -06:00
Robin Johnson
80d5f7d27b fix selinux context for rc-svcdir (bug #347503) 2010-12-03 23:49:34 -06:00
Jory A. Pratt
060b19e3e3 correction for unmounting volumes with weird characters, thanks Brant
Gurganus <brant@gurganus.name>
2010-10-28 20:35:09 -05:00
William Hubbs
d8a76d1bf6 allow net_fs_list to be extended but not replaced
This fixes bug #342825.
2010-10-27 09:00:02 -05:00
Jory A. Pratt
be6c0716ee surpress output of loadkeys, fix setfont path check 2010-09-30 07:33:52 -05:00
Roy Marples
4b333eaf36 Send SIGKILL after 2 failed SIGTERM when unmounting. 2010-03-16 21:34:48 +00:00
Juan RP
59b08643f1 Mount xenfs early so OpenRC can detect it. 2010-02-26 09:34:43 +00:00
Roy Marples
5c52e5beb5 Fix rc_${rc_svcname}_need.
Display config depends in service depend function also.
2010-02-20 21:48:06 +00:00
Roy Marples
ec38bbbdda If mounting tmpfs fails, try ramfs.
This is because buggy kernels always report tmpfs even when not present.
2009-11-20 00:04:32 +00:00
Roy Marples
3dc712e222 Allow init scripts to show their dependencies easier 2009-09-04 16:00:08 +01:00
Roy Marples
5acf0e9464 We need to use eval so we can pass "*" as an argument. 2009-05-26 22:36:53 +01:00
Roy Marples
c0fd1b49e4 Move non compiled libraries from /lib/rc to /libexec/rc
OpenRC version is now stored as plaintext in /libexec/rc/version

Plugins (cursplash, splashutils) will have to be re-compiled to pickup
the new directories. State data needs to be moved from /lib/rc/init.d
to /libexec/rc/init.d as well.
2009-05-23 20:38:12 +01:00
Roy Marples
7c81f74b60 Fix compile on NetBSD 2009-05-05 16:39:59 +01:00
Roy Marples
d441bf1585 Ignore more foo for the BSDs 2009-05-05 10:29:52 +01:00
Roy Marples
658a220638 Add (c) to Copyright 2009-05-01 15:11:40 +01:00
Roy Marples
b70501ef45 Go back to git 2009-04-30 15:05:39 +01:00
Roy Marples
824bb3aee3 Allow templates to define a stop signal 2009-04-27 13:32:13 +00:00
Roy Marples
2b866f264f Stop using needless {} in vars 2009-04-26 21:13:26 +00:00
Roy Marples
1d48183646 Try and set a keymap as early as possible, #169 2009-04-26 11:19:22 +00:00
Roy Marples
e2942e34af Use a bashism for a minor speedup in gendepends.sh 2009-04-19 16:47:09 +00:00
Roy Marples
802fe9709e Allow user to provide custom status function and still hook into the system one 2009-04-18 10:39:53 +00:00
Roy Marples
c9e24a0494 Move status to runscript.sh so init scripts can override it, #159
Return 32 if crashed, #163
2009-04-18 00:09:03 +00:00
Roy Marples
ace0b9653b Avoid needless forking, #165
Thanks to Natanael Copa.
2009-04-16 23:23:21 +00:00
Roy Marples
6bb44be2a3 We should always mount $RC_SVCDIR unless in a vserver or it's already mounted. 2009-01-29 13:38:15 +00:00
Roy Marples
2c98c5326a Punt .gitignore files. 2008-12-04 12:12:09 +00:00
Roy Marples
c064393f08 Save screen space. 2008-11-28 10:46:58 +00:00
Roy Marples
1deaa0fae0 Fix lib. 2008-11-13 09:35:00 +00:00
Roy Marples
0cca768b82 Mark the addon code as deprecated. 2008-11-12 19:19:56 +00:00
Roy Marples
42e6a95b1d Move romount to mount-ro and use the umount -r option as it's more reliable for / --bind mounts, Gentoo #239922. Thanks to Duncan. 2008-11-04 11:30:15 +00:00
Roy Marples
0af7d5bc20 Add a new shutdown runlevel, Gentoo #224537.
Split halt.sh into halt, killprocs, romount and savecache services.
The reboot runlevel is removed but mapped to shutdown.
The halt script should be moved to the sysvinit package.
2008-11-03 15:31:01 +00:00
Roy Marples
d6da8e8c48 sysinit is now a real runlevel that handles things like udev, dmesg and
mounting various bits in /dev and /sys.
init.sh JUST mounts /lib/rc/init.d (and /proc for Linux systems)
To make development of this easier we now return an empty RC_STRINGLIST
instead of a NULL for empty things.

If you don't have a udev init script installed, don't reboot your box OR
roll back to an older OpenRC version.
2008-10-10 08:37:21 +00:00
Roy Marples
247766695c Fix umounting reporting exit status, Gentoo #239922. 2008-10-09 16:36:42 +00:00
Roy Marples
6748c0e04e Allow forcefsck instead of gentoo=forcefsck on the kernel command line. 2008-09-22 12:32:35 +00:00
Roy Marples
a3c8706618 Allow OpenVZ to mount /sys and device managers, #102 2008-08-19 15:27:15 +00:00
Roy Marples
11e4059b05 Set the default RC_SVCDIR higher up. 2008-06-21 15:31:04 +00:00
Roy Marples
5510451bac We need to replace @LIB@ here. 2008-06-21 14:10:59 +00:00
Roy Marples
d384502e57 There could be a space between #! and /sbin/runscript, Gentoo #218001. 2008-05-01 15:18:34 +00:00
Roy Marples
5ba6f0a628 We need to ensure that the init script started is correct, translating symlinks. This has a new rule - multiplexed services must exist in the same dir as the master sript. So we need to ensuret that net.lo(0) is the real script and not a symlink itself. This fixes Gentoo #219526. 2008-04-29 10:25:45 +00:00
Roy Marples
b08b6cd91b Always define template start/stop functions so that the real script name isn't hidden when errors are in the real start/stop functions, Gentoo #219179 2008-04-26 19:32:28 +00:00
Roy Marples
dbea63b76d Fix logic for templates. 2008-04-21 21:34:52 +00:00
Roy Marples
6a5287dbb5 Typo 2008-04-21 19:26:56 +00:00
Roy Marples
df8eeba2fb Punt is_function in favour of POSIX shell builtin command, thanks to Harald van Dijk for the idea. 2008-04-21 17:32:17 +00:00
Roy Marples
e96347523f We should check type output to ensure that we're really calling a shell function and not some badly named binary like stop from boinc, Gentoo #218063. 2008-04-18 23:00:43 +00:00
Roy Marples
809ac86c69 We should only check dependencies in files. 2008-04-16 15:01:52 +00:00
Roy Marples
034b9b7a12 Add a silly rc_runlevel function to appease SpanKY :) 2008-04-08 16:01:40 +00:00
Roy Marples
594d98eddc Tests now work on NetBSD. 2008-04-07 09:37:14 +00:00
Roy Marples
dcdfdb442f Some systems are only detectable after /proc is mounted, so re-test if unknown. 2008-04-06 20:06:07 +00:00
Roy Marples
742310744d We would sanitize $RC_LIBDIR/sbin as well. If it's really needed then rc-functions.sh will add it back. 2008-03-27 18:34:12 +00:00
Roy Marples
4e9b58b07d Sanitize the write rc dir. 2008-03-27 17:09:18 +00:00
Roy Marples
c564043f86 No need for the extra rc. 2008-03-27 16:59:33 +00:00
Roy Marples
b3d1182a2f Fix mulitlib issues. 2008-03-27 16:53:22 +00:00
Roy Marples
864e17fabc Ignore more files. 2008-03-26 17:34:23 +00:00
Roy Marples
ac834ddc56 Fix linux compile. 2008-03-26 14:39:13 +00:00
Roy Marples
833903fc78 use $CP and $SED instead of cp and sed 2008-03-26 14:27:46 +00:00
Roy Marples
55858eca2e .sh.BSD.in is a better extension. 2008-03-26 14:02:59 +00:00
Roy Marples
6af2b20297 Split sysctl into Linux and BSD specific files. 2008-03-26 09:36:34 +00:00
Roy Marples
5866d829bb Try and fix more prefix stuff. 2008-03-25 18:33:45 +00:00
Roy Marples
c807b3a815 INITDIR should already be prefixed. 2008-03-25 17:19:41 +00:00
Roy Marples
4d6b84290a These now need to be prefixed. 2008-03-25 17:17:15 +00:00
Roy Marples
08791ec4a2 INITDIR should already be prefixed. 2008-03-25 17:11:44 +00:00
Roy Marples
55eb3794fb Rework our folder structure so that we don't have OS specific dirs, making it easier to share init and conf files per OS. 2008-03-25 14:06:05 +00:00
Mike Frysinger
486d517674 setup a bit of a test framework 2008-03-24 07:17:05 +00:00
Mike Frysinger
02e7e1b988 dont leak the _e var 2008-03-24 05:54:18 +00:00
Roy Marples
4079b4d65d Clean up error display. 2008-03-21 11:20:03 +00:00
Roy Marples
eca292e5d9 Some OS's block on umount -f, so don't use it. 2008-03-21 11:02:02 +00:00
Roy Marples
e47661449a More pathing fixes. 2008-03-21 00:30:22 +00:00
Roy Marples
04b0acb010 Fix pathing again. 2008-03-20 19:57:31 +00:00
Roy Marples
6159a32f39 SVCNAME -> RC_SVCNAME, but export SVCNAME still for compat. 2008-03-19 19:57:24 +00:00
Roy Marples
6d2e1f7add Fix building on Linux. 2008-03-19 19:43:08 +00:00
Roy Marples
d9ec62b22a Add rc-service and update all softlevel refs to runlevel. 2008-03-19 17:11:50 +00:00
Roy Marples
0e6eb0f764 Ensure that our path includes packages and local 2008-03-19 15:21:42 +00:00
Roy Marples
40e12f6ba0 RC_SERVICE now points to the service file, so daemons can recall us directly. 2008-03-11 15:00:16 +00:00
Roy Marples
f20099bc33 Fix the old RC_USE names. 2008-03-10 11:33:39 +00:00
Roy Marples
c4a54605e0 Support baselayout-2 uppercase RC_NEED vars, #38. 2008-03-08 15:22:29 +00:00
Roy Marples
a689b66023 Add tunable SYSCONFDIR 2008-03-05 12:27:11 +00:00
Roy Marples
ff162b39ac Don't rely on fuser being present 2008-03-04 22:03:41 +00:00
Roy Marples
15cf41e713 Split VPS into VSERVER and OPENVZ 2008-03-03 17:19:56 +00:00
Roy Marples
7a8e9d4ddb Add a gitignore make target. 2008-03-03 13:04:08 +00:00
Roy Marples
61c476e72d Use exlicit make targets, not directory contents. 2008-03-03 12:34:51 +00:00
Roy Marples
0aedc02860 Introduce LOCAL_PREFIX for a user maintained script location. 2008-03-03 10:33:42 +00:00
Roy Marples
dca4034bd5 Fix prefixed net.sh 2008-03-03 08:47:37 +00:00
Roy Marples
67c5fd6bb8 Ensure that our scripts call prefixed runscript. 2008-03-02 21:14:01 +00:00
Roy Marples
a135d0d93b Fix installing into PREFIX. 2008-03-01 22:12:33 +00:00
Roy Marples
0a0961f3f4 ignore more stuff 2008-02-28 21:49:52 +00:00
Roy Marples
988289d98d Typo 2008-02-28 21:04:28 +00:00