aboutsummaryrefslogtreecommitdiffstats
path: root/meta-systemd/recipes-core/systemd/systemd-systemctl-native
diff options
context:
space:
mode:
authorAndreas Müller <schnitzeltony@googlemail.com>2012-07-11 13:24:32 +0200
committerKoen Kooi <koen@dominion.thruhere.net>2012-07-16 09:39:05 +0200
commita5b2aea321b2851ed82828e6204c075a2329059c (patch)
tree06c57ad79e5cdcb0b8b62bb6e910c29c379fac8c /meta-systemd/recipes-core/systemd/systemd-systemctl-native
parent5ed19733f5193b752da650841a1383adb532fffd (diff)
downloadmeta-openembedded-contrib-a5b2aea321b2851ed82828e6204c075a2329059c.tar.gz
move systemd recipes to meta-systemd
Diffstat (limited to 'meta-systemd/recipes-core/systemd/systemd-systemctl-native')
-rwxr-xr-xmeta-systemd/recipes-core/systemd/systemd-systemctl-native/systemctl91
1 files changed, 91 insertions, 0 deletions
diff --git a/meta-systemd/recipes-core/systemd/systemd-systemctl-native/systemctl b/meta-systemd/recipes-core/systemd/systemd-systemctl-native/systemctl
new file mode 100755
index 0000000000..ff9e6a7512
--- /dev/null
+++ b/meta-systemd/recipes-core/systemd/systemd-systemctl-native/systemctl
@@ -0,0 +1,91 @@
+#!/bin/sh
+echo "Started $0 $*"
+
+ROOT=
+
+# parse command line params
+action=
+while [ $# != 0 ]; do
+ opt="$1"
+
+ case "$opt" in
+ enable)
+ shift
+
+ action="$opt"
+ services="$1"
+ cmd_args="1"
+ shift
+ ;;
+ disable)
+ shift
+
+ action="$opt"
+ services="$1"
+ cmd_args="1"
+ shift
+ ;;
+ --root=*)
+ ROOT=${opt##--root=}
+ cmd_args="0"
+ shift
+ ;;
+ *)
+ if [ "$cmd_args" = "1" ]; then
+ services="$services $opt"
+ shift
+ else
+ echo "'$opt' is an unkown option; exiting with error"
+ exit 1
+ fi
+ ;;
+ esac
+done
+
+for service in $services; do
+ echo "Try to find location of $service..."
+ # find service file
+ for p in $ROOT/etc/systemd/system \
+ $ROOT/lib/systemd/system \
+ $ROOT/usr/lib/systemd/system; do
+ if [ -e $p/$service ]; then
+ service_file=$p/$service
+ service_file=${service_file##$ROOT}
+ fi
+ done
+ if [ -z "$service_file" ]; then
+ echo "'$service' couldn't be found; exiting with error"
+ exit 1
+ fi
+ echo "Found $service in $service_file"
+
+ # create the required symbolic links
+ wanted_by=$(grep WantedBy $ROOT/$service_file \
+ | sed 's,WantedBy=,,g' \
+ | tr ',' '\n' \
+ | grep '\.target$')
+
+ for r in $wanted_by; do
+ echo "WantedBy=$r found in $service"
+ if [ "$action" = "enable" ]; then
+ mkdir -p $ROOT/etc/systemd/system/$r.wants
+ ln -s $service_file $ROOT/etc/systemd/system/$r.wants
+ echo "Enabled $service for $wanted_by."
+ else
+ rm -f $ROOT/etc/systemd/system/$r.wants/$service
+ rmdir --ignore-fail-on-non-empty -p $ROOT/etc/systemd/system/$r.wants
+ echo "Disabled $service for $wanted_by."
+ fi
+ done
+
+ # call us for the other required scripts
+ also=$(grep Also $ROOT/$service_file \
+ | sed 's,Also=,,g' \
+ | tr ',' '\n')
+ for a in $also; do
+ echo "Also=$a found in $service"
+ if [ "$action" = "enable" ]; then
+ $0 --root=$ROOT enable $a
+ fi
+ done
+done