chiark / gitweb /
systemctl: warn if user enables unit with no installation instructions
authorLennart Poettering <lennart@poettering.net>
Wed, 13 Oct 2010 01:13:23 +0000 (03:13 +0200)
committerLennart Poettering <lennart@poettering.net>
Wed, 13 Oct 2010 01:13:23 +0000 (03:13 +0200)
TODO
src/systemctl.c

diff --git a/TODO b/TODO
index e09d4d3e5e2ed34e730b150528f46d4e90f2310c..bda29da5835250e7caccea7f4642a6dbc5999e0e 100644 (file)
--- a/TODO
+++ b/TODO
@@ -36,8 +36,6 @@
 
 * if a service fails too often, make the service enter failed mode, and the socket, too.
 
-* systemctl enable - warn about empty [Install] section
-
 * bash completion a la gdbus
 
 * systemctl list-jobs - show dependencies
index a4a76558bdca92e1f3fb6daf96ad5e71e233ce47..671745b7d001500ac5bfcf45d126960b88cdbee2 100644 (file)
@@ -3227,6 +3227,7 @@ typedef struct {
 
 static Hashmap *will_install = NULL, *have_installed = NULL;
 static Set *remove_symlinks_to = NULL;
+static unsigned n_symlinks = 0;
 
 static void install_info_free(InstallInfo *i) {
         assert(i);
@@ -3759,6 +3760,9 @@ static int install_info_apply(const char *verb, LookupPaths *paths, InstallInfo
                 return r;
         }
 
+        n_symlinks += strv_length(i->aliases);
+        n_symlinks += strv_length(i->wanted_by);
+
         fclose(f);
 
         if ((r = install_info_symlink_alias(verb, i, config_path)) != 0)
@@ -3859,19 +3863,24 @@ static int enable_unit(DBusConnection *bus, char **args, unsigned n) {
 
         if (streq(verb, "is-enabled"))
                 r = r > 0 ? 0 : -ENOENT;
-        else if (bus &&
-                 /* Don't try to reload anything if the user asked us to not do this */
-                 !arg_no_reload &&
-                 /* Don't try to reload anything when updating a unit globally */
-                 !arg_global &&
-                 /* Don't try to reload anything if we are called for system changes but the system wasn't booted with systemd */
-                 (arg_session || sd_booted() > 0) &&
-                 /* Don't try to reload anything if we are running in a chroot environment */
-                 (arg_session || running_in_chroot() <= 0) ) {
-                int q;
+        else {
+                if (n_symlinks <= 0)
+                        log_warning("Unit files contain no applicable installation information. Ignoring.");
+
+                if (bus &&
+                    /* Don't try to reload anything if the user asked us to not do this */
+                    !arg_no_reload &&
+                    /* Don't try to reload anything when updating a unit globally */
+                    !arg_global &&
+                    /* Don't try to reload anything if we are called for system changes but the system wasn't booted with systemd */
+                    (arg_session || sd_booted() > 0) &&
+                    /* Don't try to reload anything if we are running in a chroot environment */
+                    (arg_session || running_in_chroot() <= 0) ) {
+                        int q;
 
-                if ((q = daemon_reload(bus, args, n)) < 0)
-                        r = q;
+                        if ((q = daemon_reload(bus, args, n)) < 0)
+                                r = q;
+                }
         }
 
 finish: