1 |
commit: 627e925463068e754ffd869f99a43634d6d9631e |
2 |
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com> |
3 |
AuthorDate: Thu Dec 3 20:09:38 2015 +0000 |
4 |
Commit: William Hubbs <williamh <AT> gentoo <DOT> org> |
5 |
CommitDate: Thu Dec 3 22:52:15 2015 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=627e9254 |
7 |
|
8 |
add support for -containers keyword |
9 |
|
10 |
man/openrc-run.8 | 3 +++ |
11 |
sh/gendepends.sh.in | 13 ++++++++++++- |
12 |
sh/openrc-run.sh.in | 13 ++++++++++++- |
13 |
sh/rc-functions.sh.in | 21 +++++++++++++++++++++ |
14 |
4 files changed, 48 insertions(+), 2 deletions(-) |
15 |
|
16 |
diff --git a/man/openrc-run.8 b/man/openrc-run.8 |
17 |
index 6aab067..5d18fe5 100644 |
18 |
--- a/man/openrc-run.8 |
19 |
+++ b/man/openrc-run.8 |
20 |
@@ -227,6 +227,9 @@ Same as -jail, but for Xen DOM0 systems. |
21 |
Same as -jail, but for Xen DOMU systems. |
22 |
.It Dv -docker |
23 |
Same as -jail, but for docker systems. |
24 |
+.It Dv -containers |
25 |
+Same as -jail, but for all relevant container types on the operating |
26 |
+system. |
27 |
.El |
28 |
.El |
29 |
.Pp |
30 |
|
31 |
diff --git a/sh/gendepends.sh.in b/sh/gendepends.sh.in |
32 |
index 36caeb7..2ab798d 100644 |
33 |
--- a/sh/gendepends.sh.in |
34 |
+++ b/sh/gendepends.sh.in |
35 |
@@ -29,7 +29,18 @@ provide() { |
36 |
[ -n "$*" ] && echo "$RC_SVCNAME iprovide $*" >&3 |
37 |
} |
38 |
keyword() { |
39 |
- [ -n "$*" ] && echo "$RC_SVCNAME keyword $*" >&3 |
40 |
+ local c x |
41 |
+ set -- $* |
42 |
+ while [ -n "$*" ]; do |
43 |
+ case "$1" in |
44 |
+ -containers) x="$(_get_containers)" ;; |
45 |
+ !-containers) x="$(_get_containers_remove)" ;; |
46 |
+ *) x=$1 ;; |
47 |
+ esac |
48 |
+ c="${c}${x} " |
49 |
+ shift |
50 |
+ done |
51 |
+ [ -n "$c" ] && echo "$RC_SVCNAME keyword $c" >&3 |
52 |
} |
53 |
depend() { |
54 |
: |
55 |
|
56 |
diff --git a/sh/openrc-run.sh.in b/sh/openrc-run.sh.in |
57 |
index c169204..5018cee 100644 |
58 |
--- a/sh/openrc-run.sh.in |
59 |
+++ b/sh/openrc-run.sh.in |
60 |
@@ -79,7 +79,18 @@ provide() { |
61 |
[ -n "$*" ] && echo "provide $*" |
62 |
} |
63 |
keyword() { |
64 |
- [ -n "$*" ] && echo "keyword $*" |
65 |
+ local c x |
66 |
+ set -- $* |
67 |
+ while [ -n "$*" ]; do |
68 |
+ case "$1" in |
69 |
+ -containers) x="$(_get_containers)" ;; |
70 |
+ !-containers) x="$(_get_containers_remove)" ;; |
71 |
+ *) x=$1 ;; |
72 |
+ esac |
73 |
+ c="${c}${x} " |
74 |
+ shift |
75 |
+ done |
76 |
+ [ -n "$c" ] && echo "keyword $c" |
77 |
} |
78 |
|
79 |
# Describe the init script to the user |
80 |
|
81 |
diff --git a/sh/rc-functions.sh.in b/sh/rc-functions.sh.in |
82 |
index c854876..12eb4e2 100644 |
83 |
--- a/sh/rc-functions.sh.in |
84 |
+++ b/sh/rc-functions.sh.in |
85 |
@@ -86,6 +86,27 @@ get_bootparam() |
86 |
} |
87 |
|
88 |
# Called from openrc-run.sh or gendepends.sh |
89 |
+_get_containers() { |
90 |
+ local c |
91 |
+ case "${RC_UNAME}" in |
92 |
+ FreeBSD) |
93 |
+ c="-jail" |
94 |
+ ;; |
95 |
+ Linux) |
96 |
+ c="-docker -lxc -openvz -rkt -systemd-nspawn -uml -vserver" |
97 |
+ ;; |
98 |
+ esac |
99 |
+ echo $c |
100 |
+} |
101 |
+ |
102 |
+_get_containers_remove() { |
103 |
+ local c |
104 |
+ for x in $(_get_containers); do |
105 |
+ c="${c}!${x} " |
106 |
+ done |
107 |
+ echo $c |
108 |
+} |
109 |
+ |
110 |
_depend() { |
111 |
depend |
112 |
local _rc_svcname=$(shell_var "$RC_SVCNAME") _deptype= _depends= |