diff options
author | Otavio Salvador <otavio@ossystems.com.br> | 2011-11-04 17:25:58 +0000 |
---|---|---|
committer | Koen Kooi <koen@dominion.thruhere.net> | 2011-11-04 19:41:19 +0100 |
commit | 79f35231a351a7df30db8b2037f274a41e8d9e58 (patch) | |
tree | 972e818381586d9604e40223091afe9a53e42ebe | |
parent | 7f5ca6706aa51dd7f1512e41757b0345aba59a47 (diff) | |
download | meta-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.bb | 13 | ||||
-rwxr-xr-x | meta-oe/recipes-core/systemd/systemd-systemctl-native/systemctl | 51 |
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 @@ | |||
1 | DESCRIPTION = "Wrapper to enable of systemd services" | ||
2 | |||
3 | LICENSE = "MIT" | ||
4 | LIC_FILES_CHKSUM = "file://${COREBASE}/LICENSE;md5=3f40d7994397109285ec7b81fdeb3b58" | ||
5 | |||
6 | inherit native | ||
7 | |||
8 | SRC_URI = "file://systemctl" | ||
9 | |||
10 | do_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 | |||
3 | ROOT= | ||
4 | |||
5 | # parse command line params | ||
6 | while [ $# != 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 | ||
25 | done | ||
26 | |||
27 | # find service file | ||
28 | for 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 | ||
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 | ||