Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 414155 - [patch] sys-apps/openrc local service enhancement
Summary: [patch] sys-apps/openrc local service enhancement
Alias: None
Product: Gentoo Hosted Projects
Classification: Unclassified
Component: OpenRC (show other bugs)
Hardware: All Linux
: Normal enhancement (vote)
Assignee: OpenRC Team
Depends on:
Reported: 2012-04-30 16:35 UTC by Duncan
Modified: 2014-05-05 06:35 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---

/etc/init.d/local patchfile (local.patch,554 bytes, text/plain)
2012-04-30 16:35 UTC, Duncan

Note You need to log in before you can comment on or make changes to this bug.
Description Duncan 2012-04-30 16:35:03 UTC
Created attachment 310511 [details]
/etc/init.d/local patchfile

This patch allows the local service to be multiplexed via symlinks (like net.eth0 symlinking to net.lo), with each symlinked service allowed its own dependencies and /etc/local.d/* start/stop files.

Use-case details (skip this paragraph if you want): My stimulus for the patch came from wanting to do some read-only bind-mounts of parts of a read/write mounted source filesystem.  As documented in the mount manpage, however, initial bind-mounts inherit the same ro/rw permissions as the original mount, and must be remounted after the initial bind-mount in ordered to change that.  So I needed a script to do that remounting after localmount (which did the original bind-mounts and exists in the boot runlevel) but before the service that used those bind-mounts (a chrooted named, in the default runlevel).

What I came up with was a few simple code changes to /etc/init.d/local that allowed it to be multiplexed under additinal names as needed, with each one simply symlinked to the local service file, so updates to it would update them all.  The new service(s) can be named local* (localboot was the one I created for my use case) and their start/stop files dropped in /etc/local.d as normal, but with start*/stop* suffixes matching that of the local* service.  (So in my case, localboot looks for *.startboot/*.stopboot scriptlets in /etc/local.d/.)  I've not tested it as I didn't need it for my use-case, but the existing /etc/conf.d/ dependency altering mechansim (rc-after=, etc) should allow dependency changes for individual local* services as necessary.  (In my case, the existing after* dependency was fine, with the existing local service started after everything else in the default runlevel, and the symlinked localboot service started after everything else in the boot runlevel.)

Summarizing:  After patching /etc/init.d/local with the attached patch:

1) /etc/init.d/local can be symlinked as /etc/init.d/local*, with each of those local* symlinks working as its own multiplexed service.

2) Dependencies for each multiplexed service can be changed using parallel files in /etc/conf.d/local* as usual, with rc_after=, etc.

3) Start and stop scriptlets for multiplexed services go in /etc/local.d/*.start* and *.stop* , as normal local service scriptlets would, but don't interfere as they use the same postfix as the local* service does. (Example: localboot as the multiplexed service, bindremount.startboot as a scriptlet run by it when the service starts.)

The patch is all of three lines changed.  Here it is both inline and attached in in case it's munged inline:

--- local       2012-04-25 22:06:17.000000000 -0700
+++ /etc/init.d/local   2012-04-30 09:14:56.000000000 -0700
@@ -12,10 +12,10 @@ depend()
-       einfo "Starting local"
+       einfo "Starting $RC_SVCNAME"
        local file
-       for file in /etc/local.d/*.start ; do
+       for file in /etc/local.d/*.start${RC_SVCNAME#local} ; do
                [ -x "$file" ] && "$file"
@@ -35,7 +35,7 @@ stop()
        einfo "Stopping local"
        local file
-       for file in /etc/local.d/*.stop; do
+       for file in /etc/local.d/*.stop${RC_SVCNAME#local} ; do
                [ -x "$file" ] && "$file"
Comment 1 William Hubbs gentoo-dev 2012-05-03 15:44:00 UTC
(In reply to comment #0)
> The patch is all of three lines changed.  Here it is both inline and
> attached in in case it's munged inline:

Please do not post patches inline; they are always munged.

Also, /etc/local.d/README should be updated since this is where the local service is documented.


Comment 2 Duncan 2014-05-05 06:35:21 UTC
Cleaning out my open bug list.

I'm on systemd now and not really tracking openrc bugs any longer so closing this.  The question is with what resolution.   I guess UPSTREAM is most appropriate, since that's where any further action will need to be.

Of course upstream is gentoo.  Welcome to reopen if desired.  I'd still be interested in knowing if the multiplexed openrc local service idea ever goes anywhere.