chiark / gitweb /
unit: turn display-manager.target into a service
[elogind.git] / src / service.c
index 07b6e4e05a5dda9d3131b43e83050a1f029414e7..3fbc0acda14b66f0f40f37e5f42572000cef7424 100644 (file)
@@ -191,13 +191,19 @@ static char *sysv_translate_name(const char *name) {
 static int sysv_translate_facility(const char *name, char **_r) {
 
         static const char * const table[] = {
+                /* LSB defined facilities */
                 "$local_fs",  SPECIAL_LOCAL_FS_TARGET,
                 "$network",   SPECIAL_NETWORK_TARGET,
                 "$named",     SPECIAL_NSS_LOOKUP_TARGET,
                 "$portmap",   SPECIAL_RPCBIND_TARGET,
                 "$remote_fs", SPECIAL_REMOTE_FS_TARGET,
                 "$syslog",    SPECIAL_SYSLOG_TARGET,
-                "$time",      SPECIAL_RTC_SET_TARGET
+                "$time",      SPECIAL_RTC_SET_TARGET,
+
+                /* Debian extensions */
+                "$mail-transport-agent", SPECIAL_MAIL_TRANSFER_AGENT_TARGET,
+                "$mail-transfer-agent",  SPECIAL_MAIL_TRANSFER_AGENT_TARGET,
+                "$x-display-manager",    SPECIAL_DISPLAY_MANAGER_SERVICE
         };
 
         unsigned i;
@@ -379,7 +385,7 @@ static int service_load_sysv_path(Service *s, const char *path) {
 
                         /* Try to parse Red Hat style chkconfig headers */
 
-                        if (startswith(t, "chkconfig:")) {
+                        if (startswith_no_case(t, "chkconfig:")) {
                                 int start_priority;
                                 char runlevels[16], *k;
 
@@ -416,7 +422,7 @@ static int service_load_sysv_path(Service *s, const char *path) {
                                         s->sysv_runlevels = d;
                                 }
 
-                        } else if (startswith(t, "description:")) {
+                        } else if (startswith_no_case(t, "description:")) {
 
                                 size_t k = strlen(t);
                                 char *d;
@@ -434,7 +440,7 @@ static int service_load_sysv_path(Service *s, const char *path) {
                                 free(u->meta.description);
                                 u->meta.description = d;
 
-                        } else if (startswith(t, "pidfile:")) {
+                        } else if (startswith_no_case(t, "pidfile:")) {
 
                                 char *fn;
 
@@ -479,7 +485,7 @@ static int service_load_sysv_path(Service *s, const char *path) {
 
                 } else if (state == LSB || state == LSB_DESCRIPTION) {
 
-                        if (startswith(t, "Provides:")) {
+                        if (startswith_no_case(t, "Provides:")) {
                                 char *i, *w;
                                 size_t z;
 
@@ -515,8 +521,10 @@ static int service_load_sysv_path(Service *s, const char *path) {
                                                 goto finish;
                                 }
 
-                        } else if (startswith(t, "Required-Start:") ||
-                                   startswith(t, "Should-Start:")) {
+                        } else if (startswith_no_case(t, "Required-Start:") ||
+                                   startswith_no_case(t, "Should-Start:") ||
+                                   startswith_no_case(t, "X-Start-Before:") ||
+                                   startswith_no_case(t, "X-Start-After:")) {
                                 char *i, *w;
                                 size_t z;
 
@@ -539,13 +547,13 @@ static int service_load_sysv_path(Service *s, const char *path) {
                                         if (r == 0)
                                                 continue;
 
-                                        r = unit_add_dependency_by_name(u, UNIT_AFTER, m, NULL, true);
+                                        r = unit_add_dependency_by_name(u, startswith_no_case(t, "X-Start-Before:") ? UNIT_BEFORE : UNIT_AFTER, m, NULL, true);
                                         free(m);
 
                                         if (r < 0)
                                                 goto finish;
                                 }
-                        } else if (startswith(t, "Default-Start:")) {
+                        } else if (startswith_no_case(t, "Default-Start:")) {
                                 char *k, *d;
 
                                 state = LSB;
@@ -562,7 +570,7 @@ static int service_load_sysv_path(Service *s, const char *path) {
                                         s->sysv_runlevels = d;
                                 }
 
-                        } else if (startswith(t, "Description:")) {
+                        } else if (startswith_no_case(t, "Description:")) {
                                 char *d;
 
                                 state = LSB_DESCRIPTION;
@@ -575,7 +583,7 @@ static int service_load_sysv_path(Service *s, const char *path) {
                                 free(u->meta.description);
                                 u->meta.description = d;
 
-                        } else if (startswith(t, "Short-Description:") &&
+                        } else if (startswith_no_case(t, "Short-Description:") &&
                                    !u->meta.description) {
                                 char *d;
 
@@ -1708,7 +1716,6 @@ static int service_start(Unit *u) {
         /* Make sure we don't enter a busy loop of some kind. */
         if (!ratelimit_test(&s->ratelimit)) {
                 log_warning("%s start request repeated too quickly, refusing to start.", u->meta.id);
-                service_enter_dead(s, false, true);
                 return -ECANCELED;
         }