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.
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.
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
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.
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
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
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).
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
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
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>
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.
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
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
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.
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
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
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.
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.
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.
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.
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>
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
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
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>
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.
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>
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>
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
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
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
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
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}.
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>
'[ -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>
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.
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>
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.
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
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
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.
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.
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.
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
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>
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>
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
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>
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
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.
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.
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.
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.
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
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
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.
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
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
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
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>
* 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)