diff options
| -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 | ||
