diff options
author | Brad Bishop <bradleyb@fuzziesquirrel.com> | 2018-11-05 19:23:07 -0500 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2018-11-14 11:14:39 +0000 |
commit | 17726d083408ad0740ef914d2cfee589d7f6b800 (patch) | |
tree | 035ebe75b20b2793910cfa9e5dccd55fd0088b28 /meta | |
parent | e39fec613d52324a4ae415a0c544612a8da4af3b (diff) | |
download | poky-17726d083408ad0740ef914d2cfee589d7f6b800.tar.gz |
systemd-systemctl-native: handle Install wildcards
Handle the %i wildcard appearing in a dependency in the Install section
of a template unit, e.g.
$ cat foo@.service
[Install]
WantedBy=bar@%i.target
Using the real systemctl something like:
$ systemctl enable foo@baz.service
will create a symlink in /etc/systemd/system/bar@baz.target.wants.
Detect wildcards in templates and make the appropriate substitution.
(From OE-Core rev: 22ed19292d160461042d4a2294fe2ec0b953873e)
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
-rwxr-xr-x | meta/recipes-core/systemd/systemd-systemctl/systemctl | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/meta/recipes-core/systemd/systemd-systemctl/systemctl b/meta/recipes-core/systemd/systemd-systemctl/systemctl index 6e5a1b7181..2bc6489617 100755 --- a/meta/recipes-core/systemd/systemd-systemctl/systemctl +++ b/meta/recipes-core/systemd/systemd-systemctl/systemctl | |||
@@ -84,11 +84,7 @@ for service in $services; do | |||
84 | else | 84 | else |
85 | echo "Try to find location of template $service_base_file of instance $service..." | 85 | echo "Try to find location of template $service_base_file of instance $service..." |
86 | service_template=true | 86 | service_template=true |
87 | if [ -z `echo $service | sed 's/^.\+@\(.*\)\.[^.]\+/\1/'` ]; then | 87 | instance_specified=`echo $service | sed 's/^.\+@\(.*\)\.[^.]\+/\1/'` |
88 | instance_specified=false | ||
89 | else | ||
90 | instance_specified=true | ||
91 | fi | ||
92 | fi | 88 | fi |
93 | 89 | ||
94 | # find service file | 90 | # find service file |
@@ -139,9 +135,14 @@ for service in $services; do | |||
139 | fi | 135 | fi |
140 | for r in $dependency_list; do | 136 | for r in $dependency_list; do |
141 | echo "$dependency=$r found in $service" | 137 | echo "$dependency=$r found in $service" |
138 | if [ -n "$instance_specified" ]; then | ||
139 | # substitute wildcards in the dependency | ||
140 | r=`echo $r | sed "s/%i/$instance_specified/g"` | ||
141 | fi | ||
142 | |||
142 | if [ "$action" = "enable" ]; then | 143 | if [ "$action" = "enable" ]; then |
143 | enable_service=$service | 144 | enable_service=$service |
144 | if [ "$service_template" = true -a "$instance_specified" = false ]; then | 145 | if [ "$service_template" = true -a -z "$instance_specified" ]; then |
145 | default_instance=$(sed '/^DefaultInstance[[:space:]]*=/s,[^=]*=,,p;d' "$ROOT/$service_file") | 146 | default_instance=$(sed '/^DefaultInstance[[:space:]]*=/s,[^=]*=,,p;d' "$ROOT/$service_file") |
146 | if [ -z $default_instance ]; then | 147 | if [ -z $default_instance ]; then |
147 | echo "Template unit without instance or DefaultInstance directive, nothing to enable" | 148 | echo "Template unit without instance or DefaultInstance directive, nothing to enable" |
@@ -155,7 +156,7 @@ for service in $services; do | |||
155 | ln -s $service_file $ROOT/etc/systemd/system/$r.$suffix/$enable_service | 156 | ln -s $service_file $ROOT/etc/systemd/system/$r.$suffix/$enable_service |
156 | echo "Enabled $enable_service for $r." | 157 | echo "Enabled $enable_service for $r." |
157 | else | 158 | else |
158 | if [ "$service_template" = true -a "$instance_specified" = false ]; then | 159 | if [ "$service_template" = true -a -z "$instance_specified" ]; then |
159 | disable_service="$ROOT/etc/systemd/system/$r.$suffix/`echo $service | sed 's/@/@*/'`" | 160 | disable_service="$ROOT/etc/systemd/system/$r.$suffix/`echo $service | sed 's/@/@*/'`" |
160 | else | 161 | else |
161 | disable_service="$ROOT/etc/systemd/system/$r.$suffix/$service" | 162 | disable_service="$ROOT/etc/systemd/system/$r.$suffix/$service" |