summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xmeta-oe/recipes-core/systemd/systemd-systemctl-native/systemctl75
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
25done 32done
26 33
27# find service file 34for service in "$services"; do
28for 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
35done
36if [ -z "$service_file" ]; then
37 echo "'$service' couldn't be found; exiting with error"
38 exit 1
39fi
40
41# create the required symbolic links
42wanted_by=$(grep WantedBy $ROOT/$service_file \
43 | sed 's,WantedBy=,,g' \
44 | tr ',' '\n' \
45 | grep '\.target$')
46
47for 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."
51done
52 48
53# call us for the other required scripts 49 # create the required symbolic links
54also=$(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' \
57for 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
59done 68done