Commit 3cdebc21 authored by Lennart Poettering's avatar Lennart Poettering

service: drop support for SysV scripts for the early boot

This remove distro-specific support for early-boot SysV init scripts.
(And leaves support for normal SysV scripts untouched).

If distributions wish to continue to allow early-boot SysV scripts in
their distribution-specific way they should either maintain this patch
downstream manually, or write a generator for them, or simply ship all
those scripts with a .service wrapper.
parent 93bd1577
...@@ -49,8 +49,7 @@ ...@@ -49,8 +49,7 @@
typedef enum RunlevelType { typedef enum RunlevelType {
RUNLEVEL_UP, RUNLEVEL_UP,
RUNLEVEL_DOWN, RUNLEVEL_DOWN
RUNLEVEL_SYSINIT
} RunlevelType; } RunlevelType;
static const struct { static const struct {
...@@ -65,16 +64,6 @@ static const struct { ...@@ -65,16 +64,6 @@ static const struct {
{ "rc4.d", SPECIAL_RUNLEVEL4_TARGET, RUNLEVEL_UP }, { "rc4.d", SPECIAL_RUNLEVEL4_TARGET, RUNLEVEL_UP },
{ "rc5.d", SPECIAL_RUNLEVEL5_TARGET, RUNLEVEL_UP }, { "rc5.d", SPECIAL_RUNLEVEL5_TARGET, RUNLEVEL_UP },
#ifdef TARGET_SUSE
/* SUSE style boot.d */
{ "boot.d", SPECIAL_SYSINIT_TARGET, RUNLEVEL_SYSINIT },
#endif
#if defined(TARGET_DEBIAN) || defined(TARGET_UBUNTU) || defined(TARGET_ANGSTROM)
/* Debian style rcS.d */
{ "rcS.d", SPECIAL_SYSINIT_TARGET, RUNLEVEL_SYSINIT },
#endif
/* Standard SysV runlevels for shutdown */ /* Standard SysV runlevels for shutdown */
{ "rc0.d", SPECIAL_POWEROFF_TARGET, RUNLEVEL_DOWN }, { "rc0.d", SPECIAL_POWEROFF_TARGET, RUNLEVEL_DOWN },
{ "rc6.d", SPECIAL_REBOOT_TARGET, RUNLEVEL_DOWN } { "rc6.d", SPECIAL_REBOOT_TARGET, RUNLEVEL_DOWN }
...@@ -83,12 +72,10 @@ static const struct { ...@@ -83,12 +72,10 @@ static const struct {
directories in this order, and we want to make sure that directories in this order, and we want to make sure that
sysv_start_priority is known when we first load the sysv_start_priority is known when we first load the
unit. And that value we only know from S links. Hence unit. And that value we only know from S links. Hence
UP/SYSINIT must be read before DOWN */ UP must be read before DOWN */
}; };
#define RUNLEVELS_UP "12345" #define RUNLEVELS_UP "12345"
/* #define RUNLEVELS_DOWN "06" */
#define RUNLEVELS_BOOT "bBsS"
#endif #endif
static const UnitActiveState state_translation_table[_SERVICE_STATE_MAX] = { static const UnitActiveState state_translation_table[_SERVICE_STATE_MAX] = {
...@@ -339,11 +326,6 @@ static char *sysv_translate_name(const char *name) { ...@@ -339,11 +326,6 @@ static char *sysv_translate_name(const char *name) {
/* Drop Debian-style .sh suffix */ /* Drop Debian-style .sh suffix */
strcpy(stpcpy(r, name) - 3, ".service"); strcpy(stpcpy(r, name) - 3, ".service");
#endif #endif
#ifdef TARGET_SUSE
if (startswith(name, "boot."))
/* Drop SuSE-style boot. prefix */
strcpy(stpcpy(r, name + 5), ".service");
#endif
#ifdef TARGET_FRUGALWARE #ifdef TARGET_FRUGALWARE
if (startswith(name, "rc.")) if (startswith(name, "rc."))
/* Drop Frugalware-style rc. prefix */ /* Drop Frugalware-style rc. prefix */
...@@ -930,13 +912,6 @@ static int service_load_sysv_path(Service *s, const char *path) { ...@@ -930,13 +912,6 @@ static int service_load_sysv_path(Service *s, const char *path) {
if ((r = sysv_exec_commands(s, supports_reload)) < 0) if ((r = sysv_exec_commands(s, supports_reload)) < 0)
goto finish; goto finish;
if (s->sysv_runlevels &&
chars_intersect(RUNLEVELS_BOOT, s->sysv_runlevels) &&
chars_intersect(RUNLEVELS_UP, s->sysv_runlevels)) {
/* Service has both boot and "up" runlevels
configured. Kill the "up" ones. */
delete_chars(s->sysv_runlevels, RUNLEVELS_UP);
}
if (s->sysv_runlevels && !chars_intersect(RUNLEVELS_UP, s->sysv_runlevels)) { if (s->sysv_runlevels && !chars_intersect(RUNLEVELS_UP, s->sysv_runlevels)) {
/* If there a runlevels configured for this service /* If there a runlevels configured for this service
...@@ -1013,18 +988,13 @@ static int service_load_sysv_name(Service *s, const char *name) { ...@@ -1013,18 +988,13 @@ static int service_load_sysv_name(Service *s, const char *name) {
assert(s); assert(s);
assert(name); assert(name);
/* For SysV services we strip the boot.*, rc.* and *.sh /* For SysV services we strip the rc.* and *.sh
* prefixes/suffixes. */ * prefixes/suffixes. */
#if defined(TARGET_DEBIAN) || defined(TARGET_UBUNTU) || defined(TARGET_ANGSTROM) #if defined(TARGET_DEBIAN) || defined(TARGET_UBUNTU) || defined(TARGET_ANGSTROM)
if (endswith(name, ".sh.service")) if (endswith(name, ".sh.service"))
return -ENOENT; return -ENOENT;
#endif #endif
#ifdef TARGET_SUSE
if (startswith(name, "boot."))
return -ENOENT;
#endif
#ifdef TARGET_FRUGALWARE #ifdef TARGET_FRUGALWARE
if (startswith(name, "rc.")) if (startswith(name, "rc."))
return -ENOENT; return -ENOENT;
...@@ -1052,21 +1022,6 @@ static int service_load_sysv_name(Service *s, const char *name) { ...@@ -1052,21 +1022,6 @@ static int service_load_sysv_name(Service *s, const char *name) {
#endif #endif
free(path); free(path);
#ifdef TARGET_SUSE
if (r >= 0 && UNIT(s)->load_state == UNIT_STUB) {
/* Try SUSE style boot.* init scripts */
path = strjoin(*p, "/boot.", name, NULL);
if (!path)
return -ENOMEM;
/* Drop .service suffix */
path[strlen(path)-8] = 0;
r = service_load_sysv_path(s, path);
free(path);
}
#endif
#ifdef TARGET_FRUGALWARE #ifdef TARGET_FRUGALWARE
if (r >= 0 && UNIT(s)->load_state == UNIT_STUB) { if (r >= 0 && UNIT(s)->load_state == UNIT_STUB) {
/* Try Frugalware style rc.* init scripts */ /* Try Frugalware style rc.* init scripts */
...@@ -3535,7 +3490,7 @@ static int service_enumerate(Manager *m) { ...@@ -3535,7 +3490,7 @@ static int service_enumerate(Manager *m) {
if (de->d_name[0] == 'S') { if (de->d_name[0] == 'S') {
if (rcnd_table[i].type == RUNLEVEL_UP || rcnd_table[i].type == RUNLEVEL_SYSINIT) { if (rcnd_table[i].type == RUNLEVEL_UP) {
SERVICE(service)->sysv_start_priority_from_rcnd = SERVICE(service)->sysv_start_priority_from_rcnd =
MAX(a*10 + b, SERVICE(service)->sysv_start_priority_from_rcnd); MAX(a*10 + b, SERVICE(service)->sysv_start_priority_from_rcnd);
...@@ -3549,8 +3504,7 @@ static int service_enumerate(Manager *m) { ...@@ -3549,8 +3504,7 @@ static int service_enumerate(Manager *m) {
goto finish; goto finish;
} else if (de->d_name[0] == 'K' && } else if (de->d_name[0] == 'K' &&
(rcnd_table[i].type == RUNLEVEL_DOWN || (rcnd_table[i].type == RUNLEVEL_DOWN)) {
rcnd_table[i].type == RUNLEVEL_SYSINIT)) {
if ((r = set_ensure_allocated(&shutdown_services, trivial_hash_func, trivial_compare_func)) < 0) if ((r = set_ensure_allocated(&shutdown_services, trivial_hash_func, trivial_compare_func)) < 0)
goto finish; goto finish;
...@@ -3584,9 +3538,7 @@ static int service_enumerate(Manager *m) { ...@@ -3584,9 +3538,7 @@ static int service_enumerate(Manager *m) {
* runlevels we assume the stop jobs will be implicitly added * runlevels we assume the stop jobs will be implicitly added
* by the core logic. Also, we don't really distinguish here * by the core logic. Also, we don't really distinguish here
* between the runlevels 0 and 6 and just add them to the * between the runlevels 0 and 6 and just add them to the
* special shutdown target. On SUSE the boot.d/ runlevel is * special shutdown target. */
* also used for shutdown, so we add links for that too to the
* shutdown target.*/
SET_FOREACH(service, shutdown_services, j) { SET_FOREACH(service, shutdown_services, j) {
service = unit_follow_merge(service); service = unit_follow_merge(service);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment