diff options
author | Andreas Müller <schnitzeltony@googlemail.com> | 2012-02-16 02:02:55 +0000 |
---|---|---|
committer | Koen Kooi <koen@dominion.thruhere.net> | 2012-02-23 16:46:30 +0100 |
commit | 9d72ff10c51963513f33ce8dbf42822abf42f6b7 (patch) | |
tree | abb60c1dcdd12b372161254bfc4b726b332889fc | |
parent | 2b402359f2c743cdf6b6c97a44202ffc043e672a (diff) | |
download | meta-openembedded-9d72ff10c51963513f33ce8dbf42822abf42f6b7.tar.gz |
systemd-systemctl-native: add multiple services support
Thanks to Otavio Salvador for helping hint [1]
[1] http://lists.linuxtogo.org/pipermail/openembedded-devel/2012-February/037856.html
Signed-off-by: Andreas Müller <schnitzeltony@googlemail.com>
Acked-by: Otavio Salvador <otavio@ossystems.com.br>
Signed-off-by: Koen Kooi <koen@dominion.thruhere.net>
-rwxr-xr-x | meta-oe/recipes-core/systemd/systemd-systemctl-native/systemctl | 75 |
1 files changed, 42 insertions, 33 deletions
diff --git a/meta-oe/recipes-core/systemd/systemd-systemctl-native/systemctl b/meta-oe/recipes-core/systemd/systemd-systemctl-native/systemctl index 54c1a18bf3..72b9da3b79 100755 --- a/meta-oe/recipes-core/systemd/systemd-systemctl-native/systemctl +++ b/meta-oe/recipes-core/systemd/systemd-systemctl-native/systemctl | |||
@@ -10,50 +10,59 @@ while [ $# != 0 ]; do | |||
10 | enable) | 10 | enable) |
11 | shift | 11 | shift |
12 | 12 | ||
13 | service="$1" | 13 | services="$1" |
14 | in_enable="1" | ||
14 | shift | 15 | shift |
15 | ;; | 16 | ;; |
16 | --root=*) | 17 | --root=*) |
17 | ROOT=${opt##--root=} | 18 | ROOT=${opt##--root=} |
19 | in_enable="0" | ||
18 | shift | 20 | shift |
19 | ;; | 21 | ;; |
20 | *) | 22 | *) |
21 | echo "'$opt' is an unkown option; exiting with error" | 23 | if [ "$in_enable" = "1" ]; then |
22 | exit 1 | 24 | services="$services $opt" |
25 | shift | ||
26 | else | ||
27 | echo "'$opt' is an unkown option; exiting with error" | ||
28 | exit 1 | ||
29 | fi | ||
23 | ;; | 30 | ;; |
24 | esac | 31 | esac |
25 | done | 32 | done |
26 | 33 | ||
27 | # find service file | 34 | for service in "$services"; do |
28 | for p in $ROOT/etc/systemd/system \ | 35 | # find service file |
29 | $ROOT/lib/systemd/system \ | 36 | for p in $ROOT/etc/systemd/system \ |
30 | $ROOT/usr/lib/systemd/system; do | 37 | $ROOT/lib/systemd/system \ |
31 | if [ -e $p/$service ]; then | 38 | $ROOT/usr/lib/systemd/system; do |
32 | service_file=$p/$service | 39 | if [ -e $p/$service ]; then |
33 | service_file=${service_file##$ROOT} | 40 | service_file=$p/$service |
41 | service_file=${service_file##$ROOT} | ||
42 | fi | ||
43 | done | ||
44 | if [ -z "$service_file" ]; then | ||
45 | echo "'$service' couldn't be found; exiting with error" | ||
46 | exit 1 | ||
34 | fi | 47 | fi |
35 | done | ||
36 | if [ -z "$service_file" ]; then | ||
37 | echo "'$service' couldn't be found; exiting with error" | ||
38 | exit 1 | ||
39 | fi | ||
40 | |||
41 | # create the required symbolic links | ||
42 | wanted_by=$(grep WantedBy $ROOT/$service_file \ | ||
43 | | sed 's,WantedBy=,,g' \ | ||
44 | | tr ',' '\n' \ | ||
45 | | grep '\.target$') | ||
46 | |||
47 | for r in $wanted_by; do | ||
48 | mkdir -p $ROOT/etc/systemd/system/$r.wants | ||
49 | ln -s $service_file $ROOT/etc/systemd/system/$r.wants | ||
50 | echo "Enabled $service for $wanted_by." | ||
51 | done | ||
52 | 48 | ||
53 | # call us for the other required scripts | 49 | # create the required symbolic links |
54 | also=$(grep Also $ROOT/$service_file \ | 50 | wanted_by=$(grep WantedBy $ROOT/$service_file \ |
55 | | sed 's,Also=,,g' \ | 51 | | sed 's,WantedBy=,,g' \ |
56 | | tr ',' '\n') | 52 | | tr ',' '\n' \ |
57 | for a in $also; do | 53 | | grep '\.target$') |
58 | $0 --root=$ROOT enable $a | 54 | |
55 | for r in $wanted_by; do | ||
56 | mkdir -p $ROOT/etc/systemd/system/$r.wants | ||
57 | ln -s $service_file $ROOT/etc/systemd/system/$r.wants | ||
58 | echo "Enabled $service for $wanted_by." | ||
59 | done | ||
60 | |||
61 | # call us for the other required scripts | ||
62 | also=$(grep Also $ROOT/$service_file \ | ||
63 | | sed 's,Also=,,g' \ | ||
64 | | tr ',' '\n') | ||
65 | for a in $also; do | ||
66 | $0 --root=$ROOT enable $a | ||
67 | done | ||
59 | done | 68 | done |