Commit a8441d31 authored by Jon Severinsson's avatar Jon Severinsson Committed by Sjoerd Simons
Browse files

Add support for rcS.d init scripts to the sysv-generator.

parent bb8785d8
......@@ -18,6 +18,7 @@ systemd (214-1) UNRELEASED; urgency=medium
* Add new system group "input" used by udev rules in udev postinst.
* Try-restart networkd, resolved, and timesyncd after an upgrade.
* Do not force-enable default-on services on every upgrade.
* Add support for rcS.d init scripts to the sysv-generator.
[ Sjoerd Simons ]
* debian/patches/shared-include-stdbool.h-in-mkdir.h.patch
......
From: Jon Severinsson <jon@severinsson.net>
Date: Sun, 20 Jul 2014 20:00:00 +0200
Subject: Add support for rcS.d init scripts to the sysv-generator
---
src/sysv-generator/sysv-generator.c | 24 ++++++++++++++++++++++--
1 file changed, 22 insertions(+), 2 deletions(-)
diff --git a/src/sysv-generator/sysv-generator.c b/src/sysv-generator/sysv-generator.c
index 5206279..78f8730 100644
--- a/src/sysv-generator/sysv-generator.c
+++ b/src/sysv-generator/sysv-generator.c
@@ -42,6 +42,7 @@
#include "hashmap.h"
typedef enum RunlevelType {
+ RUNLEVEL_SYSINIT,
RUNLEVEL_UP,
RUNLEVEL_DOWN
} RunlevelType;
@@ -51,6 +52,9 @@ static const struct {
const char *target;
const RunlevelType type;
} rcnd_table[] = {
+ /* Debian SysV runlevel for early boot */
+ { "rcS.d", SPECIAL_SYSINIT_TARGET, RUNLEVEL_SYSINIT },
+
/* Standard SysV runlevels for start-up */
{ "rc1.d", SPECIAL_RESCUE_TARGET, RUNLEVEL_UP },
{ "rc2.d", SPECIAL_RUNLEVEL2_TARGET, RUNLEVEL_UP },
@@ -69,10 +73,14 @@ static const struct {
UP must be read before DOWN */
};
+/* Sysinit services uses DefaultDependencies=no, so explicitly order after a safe subset. */
+#define SYSINIT_AFTER "local-fs.target"
+
typedef struct SysvStub {
char *name;
char *path;
char *description;
+ bool sysinit;
int sysv_start_priority;
char *pid_file;
char **before;
@@ -156,6 +164,8 @@ static int generate_unit_file(SysvStub *s) {
"Description=%s\n",
s->path, s->description);
+ if (s->sysinit)
+ fprintf(f, "DefaultDependencies=no\nAfter=" SYSINIT_AFTER "\n");
if (!isempty(before))
fprintf(f, "Before=%s\n", before);
if (!isempty(after))
@@ -169,11 +179,12 @@ static int generate_unit_file(SysvStub *s) {
"\n[Service]\n"
"Type=forking\n"
"Restart=no\n"
- "TimeoutSec=5min\n"
+ "TimeoutSec=%s\n"
"IgnoreSIGPIPE=no\n"
"KillMode=process\n"
"GuessMainPID=no\n"
"RemainAfterExit=%s\n",
+ s->sysinit ? "0" : "5min",
yes_no(!s->pid_file));
if (s->sysv_start_priority > 0)
@@ -656,6 +667,11 @@ static int fix_order(SysvStub *s, Hashmap *all_services) {
if (s->has_lsb && other->has_lsb)
continue;
+ /* Don't order units between sysinit and regular sysv services,
+ * they are ordered before and after basic.target anyway. */
+ if (other->sysinit != s->sysinit)
+ continue;
+
if (other->sysv_start_priority < s->sysv_start_priority) {
r = strv_extend(&s->after, other->name);
if (r < 0)
@@ -804,8 +820,12 @@ static int set_dependencies_from_rcnd(LookupPaths lp, Hashmap *all_services) {
}
if (de->d_name[0] == 'S') {
+ if (rcnd_table[i].type == RUNLEVEL_SYSINIT) {
+ service->sysinit = true;
+ service->sysv_start_priority = a*10 + b;
+ }
- if (rcnd_table[i].type == RUNLEVEL_UP) {
+ if (rcnd_table[i].type == RUNLEVEL_UP && !service->sysinit) {
service->sysv_start_priority =
MAX(a*10 + b, service->sysv_start_priority);
}
From: Jon Severinsson <jon@severinsson.net>
Date: Wed, 2 Jul 2014 22:00:00 +0200
Subject: Do not generate systemd units from sysv init scripts if a native
service file already exists.
---
src/sysv-generator/sysv-generator.c | 28 +++++++++++++++++++++++++++-
1 file changed, 27 insertions(+), 1 deletion(-)
diff --git a/src/sysv-generator/sysv-generator.c b/src/sysv-generator/sysv-generator.c
index 78f8730..22d9cc2 100644
--- a/src/sysv-generator/sysv-generator.c
+++ b/src/sysv-generator/sysv-generator.c
@@ -691,6 +691,25 @@ static int fix_order(SysvStub *s, Hashmap *all_services) {
return 0;
}
+static int native_unit_exists(LookupPaths lp, char *name) {
+ char **p;
+
+ STRV_FOREACH(p, lp.unit_path) {
+ struct stat st;
+ _cleanup_free_ char *path = NULL;
+
+ path = strjoin(*p, "/", name, NULL);
+ if (!path)
+ return -ENOMEM;
+
+ if (lstat(path, &st) < 0)
+ continue;
+
+ return 1;
+ }
+ return 0;
+}
+
static int enumerate_sysv(LookupPaths lp, Hashmap *all_services) {
char **path;
@@ -731,6 +750,12 @@ static int enumerate_sysv(LookupPaths lp, Hashmap *all_services) {
if (hashmap_contains(all_services, name))
continue;
+ r = native_unit_exists(lp, name);
+ if (r < 0)
+ return log_oom();
+ if (r > 0)
+ continue;
+
service = new0(SysvStub, 1);
if (!service)
return log_oom();
@@ -815,7 +840,8 @@ static int set_dependencies_from_rcnd(LookupPaths lp, Hashmap *all_services) {
if (hashmap_contains(all_services, name))
service = hashmap_get(all_services, name);
else {
- log_warning("Could not find init script for %s", name);
+ log_debug("Ignoring %s symlink in %s, not generating %s.",
+ de->d_name, rcnd_table[i].path, name);
continue;
}
......@@ -98,3 +98,5 @@ more-cd-aliases.patch
Adjust-systemd-user-pam-config-file-for-Debian.patch
Add-run-initctl-support-to-SysV-compat-tools.patch
Add-support-for-TuxOnIce-hibernation.patch
Add-support-for-rcS.d-init-scripts-to-the-sysv-gener.patch
Do-not-generate-systemd-units-from-sysv-init-scripts.patch
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