summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--meta-oe/recipes-core/systemd/systemd-systemctl-native.bb13
-rwxr-xr-xmeta-oe/recipes-core/systemd/systemd-systemctl-native/systemctl51
2 files changed, 64 insertions, 0 deletions
diff --git a/meta-oe/recipes-core/systemd/systemd-systemctl-native.bb b/meta-oe/recipes-core/systemd/systemd-systemctl-native.bb
new file mode 100644
index 0000000000..3ee757e153
--- /dev/null
+++ b/meta-oe/recipes-core/systemd/systemd-systemctl-native.bb
@@ -0,0 +1,13 @@
1DESCRIPTION = "Wrapper to enable of systemd services"
2
3LICENSE = "MIT"
4LIC_FILES_CHKSUM = "file://${COREBASE}/LICENSE;md5=3f40d7994397109285ec7b81fdeb3b58"
5
6inherit native
7
8SRC_URI = "file://systemctl"
9
10do_install() {
11 install -d ${D}${bindir}
12 install -m 0755 ${WORKDIR}/systemctl ${D}${bindir}
13}
diff --git a/meta-oe/recipes-core/systemd/systemd-systemctl-native/systemctl b/meta-oe/recipes-core/systemd/systemd-systemctl-native/systemctl
new file mode 100755
index 0000000000..1fc77fd92b
--- /dev/null
+++ b/meta-oe/recipes-core/systemd/systemd-systemctl-native/systemctl
@@ -0,0 +1,51 @@
1#!/bin/sh
2
3ROOT=
4
5# parse command line params
6while [ $# != 0 ]; do
7 opt="$1"
8
9 case "$opt" in
10 enable)
11 shift
12
13 service="$1"
14 shift
15 ;;
16 --root=*)
17 ROOT=${opt##--root=}
18 shift
19 ;;
20 *)
21 echo "'$opt' is an unkown option; exiting with error"
22 exit 1
23 ;;
24 esac
25done
26
27# find service file
28for p in $ROOT/etc/systemd/system \
29 $ROOT/lib/systemd/system \
30 $ROOT/usr/lib/systemd/system; do
31 if [ -e $p/$service ]; then
32 service_file=$p/$service
33 service_file=${service_file##$ROOT}
34 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