aboutsummaryrefslogtreecommitdiff
path: root/src/rc/rc.c
diff options
context:
space:
mode:
authorIan Stakenvicius <axs@gentoo.org>2015-10-26 15:20:58 -0400
committerWilliam Hubbs <w.d.hubbs@gmail.com>2015-11-12 12:32:45 -0600
commit33d3f33b3ca7dd2ce616b8182d588d0743c2f124 (patch)
tree9cd258ecf6a4787390f4c366bda04adf721bdabe /src/rc/rc.c
parentddb895b355e02c9c07b00bfaf00d1bf8a7abbc03 (diff)
Implement "want" dependency
The want dependency is similar to the use dependency. If a service script, for example called service1, adds "want service2" to its depend function, OpenRC will attempt to start service2, if it exists on the system, when service1 is started. However, service1 will start regardless of the status of service2. X-Gentoo-Bug: 406021 X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=406021
Diffstat (limited to 'src/rc/rc.c')
-rw-r--r--src/rc/rc.c34
1 files changed, 18 insertions, 16 deletions
diff --git a/src/rc/rc.c b/src/rc/rc.c
index dd35482f..d96aa45f 100644
--- a/src/rc/rc.c
+++ b/src/rc/rc.c
@@ -155,8 +155,8 @@ cleanup(void)
rc_stringlist_free(hotplugged_services);
rc_stringlist_free(stop_services);
rc_stringlist_free(start_services);
- rc_stringlist_free(types_n);
- rc_stringlist_free(types_nua);
+ rc_stringlist_free(types_nw);
+ rc_stringlist_free(types_nwua);
rc_deptree_free(deptree);
free(runlevel);
#endif
@@ -519,7 +519,7 @@ runlevel_config(const char *service, const char *level)
}
static void
-do_stop_services(RC_STRINGLIST *types_n, RC_STRINGLIST *start_services,
+do_stop_services(RC_STRINGLIST *types_nw, RC_STRINGLIST *start_services,
const RC_STRINGLIST *stop_services, const RC_DEPTREE *deptree,
const char *newlevel, bool parallel, bool going_down)
{
@@ -530,9 +530,10 @@ do_stop_services(RC_STRINGLIST *types_n, RC_STRINGLIST *start_services,
RC_STRINGLIST *nostop;
bool crashed, nstop;
- if (!types_n) {
- types_n = rc_stringlist_new();
- rc_stringlist_add(types_n, "needsme");
+ if (!types_nw) {
+ types_nw = rc_stringlist_new();
+ rc_stringlist_add(types_nw, "needsme");
+ rc_stringlist_add(types_nw, "wantsme");
}
crashed = rc_conf_yesno("rc_crashed_stop");
@@ -591,7 +592,7 @@ do_stop_services(RC_STRINGLIST *types_n, RC_STRINGLIST *start_services,
if (!svc1) {
tmplist = rc_stringlist_new();
rc_stringlist_add(tmplist, service->value);
- deporder = rc_deptree_depends(deptree, types_n,
+ deporder = rc_deptree_depends(deptree, types_nw,
tmplist, newlevel ? newlevel : runlevel,
RC_DEP_STRICT | RC_DEP_TRACE);
rc_stringlist_free(tmplist);
@@ -754,8 +755,8 @@ main(int argc, char **argv)
static RC_STRINGLIST *hotplugged_services;
static RC_STRINGLIST *stop_services;
static RC_STRINGLIST *start_services;
- static RC_STRINGLIST *types_n;
- static RC_STRINGLIST *types_nua;
+ static RC_STRINGLIST *types_nw;
+ static RC_STRINGLIST *types_nwua;
static RC_DEPTREE *deptree;
RC_STRINGLIST *deporder = NULL;
RC_STRINGLIST *tmplist;
@@ -996,13 +997,14 @@ main(int argc, char **argv)
if (stop_services)
rc_stringlist_sort(&stop_services);
- types_nua = rc_stringlist_new();
- rc_stringlist_add(types_nua, "ineed");
- rc_stringlist_add(types_nua, "iuse");
- rc_stringlist_add(types_nua, "iafter");
+ types_nwua = rc_stringlist_new();
+ rc_stringlist_add(types_nwua, "ineed");
+ rc_stringlist_add(types_nwua, "iwant");
+ rc_stringlist_add(types_nwua, "iuse");
+ rc_stringlist_add(types_nwua, "iafter");
if (stop_services) {
- tmplist = rc_deptree_depends(deptree, types_nua, stop_services,
+ tmplist = rc_deptree_depends(deptree, types_nwua, stop_services,
runlevel, depoptions | RC_DEP_STOP);
rc_stringlist_free(stop_services);
stop_services = tmplist;
@@ -1047,7 +1049,7 @@ main(int argc, char **argv)
/* Now stop the services that shouldn't be running */
if (stop_services && !nostop)
- do_stop_services(types_n, start_services, stop_services, deptree, newlevel, parallel, going_down);
+ do_stop_services(types_nw, start_services, stop_services, deptree, newlevel, parallel, going_down);
/* Wait for our services to finish */
wait_for_services();
@@ -1109,7 +1111,7 @@ main(int argc, char **argv)
/* Start those services. */
rc_stringlist_sort(&run_services);
- deporder = rc_deptree_depends(deptree, types_nua, run_services, rlevel->value, depoptions | RC_DEP_START);
+ deporder = rc_deptree_depends(deptree, types_nwua, run_services, rlevel->value, depoptions | RC_DEP_START);
rc_stringlist_free(run_services);
run_services = deporder;
do_start_services(run_services, parallel);