summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOtavio Salvador <otavio@ossystems.com.br>2011-11-04 17:25:58 +0000
committerKoen Kooi <koen@dominion.thruhere.net>2011-11-04 19:41:19 +0100
commit79f35231a351a7df30db8b2037f274a41e8d9e58 (patch)
tree972e818381586d9604e40223091afe9a53e42ebe
parent7f5ca6706aa51dd7f1512e41757b0345aba59a47 (diff)
downloadmeta-openembedded-79f35231a351a7df30db8b2037f274a41e8d9e58.tar.gz
systemd-systemctl-native: add a systemctl wrapper
The wrapper allows for enabling services at rootfs generation thus allowing systemd to be used in ready-only filesystems. Signed-off-by: Otavio Salvador <otavio@ossystems.com.br> Signed-off-by: Koen Kooi <koen@dominion.thruhere.net>
-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 000000000..3ee757e15
--- /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 000000000..1fc77fd92
--- /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