if (r == 0)
continue;
- r = unit_add_name(u, m);
+ if (unit_name_to_type(m) == UNIT_SERVICE)
+ r = unit_add_name(u, m);
+ else {
+ if ((r = unit_add_dependency_by_name_inverse(u, UNIT_REQUIRES, m)) >= 0)
+ r = unit_add_dependency_by_name(u, UNIT_BEFORE, m);
+ }
+
free(m);
if (r < 0)
return r;
}
- /* Load a classic init script as a fallback, if we couldn*t find anything */
+ /* Load a classic init script as a fallback, if we couldn't find anything */
if (r == 0)
if ((r = service_load_sysv(s)) <= 0) {
service_done(u);
return 0;
}
+int unit_add_dependency_by_name_inverse(Unit *u, UnitDependency d, const char *name) {
+ Unit *other;
+ int r;
+
+ if ((r = manager_load_unit(u->meta.manager, name, &other)) < 0)
+ return r;
+
+ if ((r = unit_add_dependency(other, d, u)) < 0)
+ return r;
+
+ return 0;
+}
+
int set_unit_path(const char *p) {
char *cwd, *c;
int r;
int unit_add_name(Unit *u, const char *name);
int unit_add_dependency(Unit *u, UnitDependency d, Unit *other);
int unit_add_dependency_by_name(Unit *u, UnitDependency d, const char *name);
+int unit_add_dependency_by_name_inverse(Unit *u, UnitDependency d, const char *name);
int unit_add_cgroup(Unit *u, CGroupBonding *b);
int unit_add_cgroup_from_text(Unit *u, const char *name);