Convert rc_sys() calls to detect_container() and detect_vm()
This commit is contained in:
parent
8addd7913a
commit
9f6e05671d
@ -753,7 +753,7 @@ rc_deptree_update(void)
|
|||||||
char *depend, *depends, *service, *type, *nosys, *onosys;
|
char *depend, *depends, *service, *type, *nosys, *onosys;
|
||||||
size_t i, k, l;
|
size_t i, k, l;
|
||||||
bool retval = true;
|
bool retval = true;
|
||||||
const char *sys = rc_sys();
|
const char *sys = NULL;
|
||||||
struct utsname uts;
|
struct utsname uts;
|
||||||
|
|
||||||
/* Some init scripts need RC_LIBEXECDIR to source stuff
|
/* Some init scripts need RC_LIBEXECDIR to source stuff
|
||||||
@ -860,6 +860,9 @@ rc_deptree_update(void)
|
|||||||
|
|
||||||
/* Phase 2 - if we're a special system, remove services that don't
|
/* Phase 2 - if we're a special system, remove services that don't
|
||||||
* work for them. This doesn't stop them from being run directly. */
|
* work for them. This doesn't stop them from being run directly. */
|
||||||
|
sys = detect_container();
|
||||||
|
if (!sys)
|
||||||
|
sys = detect_vm();
|
||||||
if (sys) {
|
if (sys) {
|
||||||
len = strlen(sys);
|
len = strlen(sys);
|
||||||
nosys = xmalloc(len + 2);
|
nosys = xmalloc(len + 2);
|
||||||
|
@ -56,7 +56,10 @@ show_version(void)
|
|||||||
const char *systype = NULL;
|
const char *systype = NULL;
|
||||||
|
|
||||||
printf("%s (OpenRC", applet);
|
printf("%s (OpenRC", applet);
|
||||||
if ((systype = rc_sys()))
|
systype = detect_container();
|
||||||
|
if (!systype)
|
||||||
|
systype = detect_vm();
|
||||||
|
if (systype)
|
||||||
printf(" [%s]", systype);
|
printf(" [%s]", systype);
|
||||||
printf(") %s", VERSION);
|
printf(") %s", VERSION);
|
||||||
#ifdef BRANDING
|
#ifdef BRANDING
|
||||||
|
@ -139,7 +139,7 @@ env_config(void)
|
|||||||
char *np;
|
char *np;
|
||||||
char *npp;
|
char *npp;
|
||||||
char *tok;
|
char *tok;
|
||||||
const char *sys = rc_sys();
|
const char *sys = NULL;
|
||||||
char buffer[PATH_MAX];
|
char buffer[PATH_MAX];
|
||||||
|
|
||||||
/* Ensure our PATH is prefixed with the system locations first
|
/* Ensure our PATH is prefixed with the system locations first
|
||||||
@ -190,7 +190,9 @@ env_config(void)
|
|||||||
} else
|
} else
|
||||||
setenv("RC_DEFAULTLEVEL", RC_LEVEL_DEFAULT, 1);
|
setenv("RC_DEFAULTLEVEL", RC_LEVEL_DEFAULT, 1);
|
||||||
|
|
||||||
if (sys)
|
sys = detect_container();
|
||||||
|
if (!sys)
|
||||||
|
sys = detect_vm();
|
||||||
setenv("RC_SYS", sys, 1);
|
setenv("RC_SYS", sys, 1);
|
||||||
|
|
||||||
#ifdef PREFIX
|
#ifdef PREFIX
|
||||||
|
20
src/rc/rc.c
20
src/rc/rc.c
@ -274,7 +274,11 @@ open_shell(void)
|
|||||||
struct passwd *pw;
|
struct passwd *pw;
|
||||||
|
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
const char *sys = rc_sys();
|
const char *sys = NULL;
|
||||||
|
|
||||||
|
sys = detect_container();
|
||||||
|
if (!sys)
|
||||||
|
sys = detect_vm();
|
||||||
|
|
||||||
/* VSERVER and OPENVZ systems cannot really drop to shells */
|
/* VSERVER and OPENVZ systems cannot really drop to shells */
|
||||||
if (sys &&
|
if (sys &&
|
||||||
@ -480,7 +484,10 @@ do_sysinit()
|
|||||||
uts.machine);
|
uts.machine);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if ((sys = rc_sys()))
|
sys = detect_container();
|
||||||
|
if (!sys)
|
||||||
|
sys = detect_vm();
|
||||||
|
if (sys)
|
||||||
printf(" [%s]", sys);
|
printf(" [%s]", sys);
|
||||||
|
|
||||||
printf("%s\n\n", ecolor(ECOLOR_NORMAL));
|
printf("%s\n\n", ecolor(ECOLOR_NORMAL));
|
||||||
@ -495,7 +502,10 @@ do_sysinit()
|
|||||||
|
|
||||||
/* init may have mounted /proc so we can now detect or real
|
/* init may have mounted /proc so we can now detect or real
|
||||||
* sys */
|
* sys */
|
||||||
if ((sys = rc_sys()))
|
sys = detect_container();
|
||||||
|
if (!sys)
|
||||||
|
sys = detect_vm();
|
||||||
|
if (sys)
|
||||||
setenv("RC_SYS", sys, 1);
|
setenv("RC_SYS", sys, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -846,7 +856,9 @@ main(int argc, char **argv)
|
|||||||
eerrorx("%s: %s", applet, strerror(errno));
|
eerrorx("%s: %s", applet, strerror(errno));
|
||||||
/* NOTREACHED */
|
/* NOTREACHED */
|
||||||
case 'S':
|
case 'S':
|
||||||
systype = rc_sys();
|
systype = detect_container();
|
||||||
|
if (!systype)
|
||||||
|
systype = detect_vm();
|
||||||
if (systype)
|
if (systype)
|
||||||
printf("%s\n", systype);
|
printf("%s\n", systype);
|
||||||
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
||||||
|
Loading…
Reference in New Issue
Block a user