mirror of
https://git.FreeBSD.org/src.git
synced 2026-06-02 11:24:32 +00:00
init: allow to specify a custom path for rc(8)
This is useful for testing alternative service managers without modifying /etc/rc MFC After: 1 weeks Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D56828
This commit is contained in:
+9
-1
@@ -28,7 +28,7 @@
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.Dd July 22, 2021
|
||||
.Dd May 5, 2026
|
||||
.Dt INIT 8
|
||||
.Os
|
||||
.Sh NAME
|
||||
@@ -396,6 +396,14 @@ back to the default, so that the
|
||||
.Pa /etc/rc
|
||||
script is executed with the standard shell
|
||||
.Pa /bin/sh .
|
||||
.It Va init_rc
|
||||
If set to a valid file name in the root file system,
|
||||
overrides the default path to
|
||||
.Xr rc 8
|
||||
.Pq Pa /etc/rc .
|
||||
This is useful for testing alternative service managers
|
||||
without modifying the default
|
||||
.Pa /etc/rc .
|
||||
.It Va init_path
|
||||
Specifies the path used to search for the init binary.
|
||||
More than one binary can be listed in the string,
|
||||
|
||||
+15
-3
@@ -1025,11 +1025,23 @@ static state_func_t
|
||||
runcom(void)
|
||||
{
|
||||
state_func_t next_transition;
|
||||
char runcom_path[PATH_MAX];
|
||||
const char *rc_script;
|
||||
|
||||
BOOTTRACE("/etc/rc starting...");
|
||||
if ((next_transition = run_script(_PATH_RUNCOM)) != NULL)
|
||||
/*
|
||||
* Allow overriding /etc/rc via the init_rc kenv variable.
|
||||
* This is useful for testing alternative service managers
|
||||
* without modifying /etc/rc.
|
||||
*/
|
||||
if (kenv(KENV_GET, "init_rc", runcom_path, sizeof(runcom_path)) > 0)
|
||||
rc_script = runcom_path;
|
||||
else
|
||||
rc_script = _PATH_RUNCOM;
|
||||
|
||||
BOOTTRACE("%s starting...", rc_script);
|
||||
if ((next_transition = run_script(rc_script)) != NULL)
|
||||
return next_transition;
|
||||
BOOTTRACE("/etc/rc finished");
|
||||
BOOTTRACE("%s finished", rc_script);
|
||||
|
||||
runcom_mode = AUTOBOOT; /* the default */
|
||||
return (state_func_t) read_ttys;
|
||||
|
||||
Reference in New Issue
Block a user