summaryrefslogtreecommitdiffstats
path: root/meta-systemd/recipes-core/systemd/systemd-systemctl-native/systemctl
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/systemctl
parent5ed19733f5193b752da650841a1383adb532fffd (diff)
downloadmeta-openembedded-a5b2aea321b2851ed82828e6204c075a2329059c.tar.gz
move systemd recipes to meta-systemd
Diffstat (limited to 'meta-systemd/recipes-core/systemd/systemd-systemctl-native/systemctl')
-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 @@
1#!/bin/sh
2echo "Started $0 $*"
3
4ROOT=
5
6# parse command line params
7action=
8while [ $# != 0 ]; do
9 opt="$1"
10
11 case "$opt" in
12 enable)
13 shift
14
15 action="$opt"
16 services="$1"
17 cmd_args="1"
18 shift
19 ;;
20 disable)
21 shift
22
23 action="$opt"
24 services="$1"
25 cmd_args="1"
26 shift
27 ;;
28 --root=*)
29 ROOT=${opt##--root=}
30 cmd_args="0"
31 shift
32 ;;
33 *)
34 if [ "$cmd_args" = "1" ]; then
35 services="$services $opt"
36 shift
37 else
38 echo "'$opt' is an unkown option; exiting with error"
39 exit 1
40 fi
41 ;;
42 esac
43done
44
45for service in $services; do
46 echo "Try to find location of $service..."
47 # find service file
48 for p in $ROOT/etc/systemd/system \
49 $ROOT/lib/systemd/system \
50 $ROOT/usr/lib/systemd/system; do
51 if [ -e $p/$service ]; then
52 service_file=$p/$service
53 service_file=${service_file##$ROOT}
54 fi
55 done
56 if [ -z "$service_file" ]; then
57 echo "'$service' couldn't be found; exiting with error"
58 exit 1
59 fi
60 echo "Found $service in $service_file"
61
62 # create the required symbolic links
63 wanted_by=$(grep WantedBy $ROOT/$service_file \
64 | sed 's,WantedBy=,,g' \
65 | tr ',' '\n' \
66 | grep '\.target$')
67
68 for r in $wanted_by; do
69 echo "WantedBy=$r found in $service"
70 if [ "$action" = "enable" ]; then
71 mkdir -p $ROOT/etc/systemd/system/$r.wants
72 ln -s $service_file $ROOT/etc/systemd/system/$r.wants
73 echo "Enabled $service for $wanted_by."
74 else
75 rm -f $ROOT/etc/systemd/system/$r.wants/$service
76 rmdir --ignore-fail-on-non-empty -p $ROOT/etc/systemd/system/$r.wants
77 echo "Disabled $service for $wanted_by."
78 fi
79 done
80
81 # call us for the other required scripts
82 also=$(grep Also $ROOT/$service_file \
83 | sed 's,Also=,,g' \
84 | tr ',' '\n')
85 for a in $also; do
86 echo "Also=$a found in $service"
87 if [ "$action" = "enable" ]; then
88 $0 --root=$ROOT enable $a
89 fi
90 done
91done