diff options
author | Radu Moisan <radu.moisan@intel.com> | 2013-01-19 22:47:07 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2013-01-20 12:58:55 +0000 |
commit | b8744d5376a9df4ec30120fdc8f39579d34d0545 (patch) | |
tree | 9503d5816da66544969292ddb5ff999e50c1b9a8 /meta/recipes-core/systemd/systemd-systemctl | |
parent | b18886d9b7c913cd463a98d0ef1b3a8a240f5791 (diff) | |
download | poky-b8744d5376a9df4ec30120fdc8f39579d34d0545.tar.gz |
systemd: add systemd recipes
Add systemd recipes and associated support recipes.
Mostly based on meta-oe/meta-systemd, so almost all credit should go to:
Andreas Müller <schnitzeltony@googlemail.com>
Denis 'GNUtoo' Carikli <GNUtoo@no-log.org>
Holger Hans Peter Freyther <holger@moiji-mobile.com>
Khem Raj <raj.khem@gmail.com>
Koen Kooi <koen@dominion.thruhere.net>
Martin Jansa <Martin.Jansa@gmail.com>
(From OE-Core rev: 6a8a48b4d0d0b9b8d8af46cae11245bcb870bbc3)
Signed-off-by: Radu Moisan <radu.moisan@intel.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-core/systemd/systemd-systemctl')
-rwxr-xr-x | meta/recipes-core/systemd/systemd-systemctl/systemctl | 126 |
1 files changed, 126 insertions, 0 deletions
diff --git a/meta/recipes-core/systemd/systemd-systemctl/systemctl b/meta/recipes-core/systemd/systemd-systemctl/systemctl new file mode 100755 index 0000000000..d71c7eda8b --- /dev/null +++ b/meta/recipes-core/systemd/systemd-systemctl/systemctl | |||
@@ -0,0 +1,126 @@ | |||
1 | #!/bin/sh | ||
2 | echo "Started $0 $*" | ||
3 | |||
4 | ROOT= | ||
5 | |||
6 | # parse command line params | ||
7 | action= | ||
8 | while [ $# != 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 | mask) | ||
29 | shift | ||
30 | |||
31 | action="$opt" | ||
32 | services="$1" | ||
33 | cmd_args="1" | ||
34 | shift | ||
35 | ;; | ||
36 | --root=*) | ||
37 | ROOT=${opt##--root=} | ||
38 | cmd_args="0" | ||
39 | shift | ||
40 | ;; | ||
41 | *) | ||
42 | if [ "$cmd_args" = "1" ]; then | ||
43 | services="$services $opt" | ||
44 | shift | ||
45 | else | ||
46 | echo "'$opt' is an unkown option; exiting with error" | ||
47 | exit 1 | ||
48 | fi | ||
49 | ;; | ||
50 | esac | ||
51 | done | ||
52 | |||
53 | for service in $services; do | ||
54 | if [ "$action" = "mask" ]; then | ||
55 | if [ ! -d $ROOT/etc/systemd/system/ ]; then | ||
56 | mkdir -p $ROOT/etc/systemd/system/ | ||
57 | fi | ||
58 | cmd="ln -s /dev/null $ROOT/etc/systemd/system/$service" | ||
59 | echo "$cmd" | ||
60 | $cmd | ||
61 | exit 0 | ||
62 | fi | ||
63 | |||
64 | echo "Try to find location of $service..." | ||
65 | # find service file | ||
66 | for p in $ROOT/etc/systemd/system \ | ||
67 | $ROOT/lib/systemd/system \ | ||
68 | $ROOT/usr/lib/systemd/system; do | ||
69 | if [ -e $p/$service ]; then | ||
70 | service_file=$p/$service | ||
71 | service_file=${service_file##$ROOT} | ||
72 | fi | ||
73 | done | ||
74 | if [ -z "$service_file" ]; then | ||
75 | echo "'$service' couldn't be found; exiting with error" | ||
76 | exit 1 | ||
77 | fi | ||
78 | echo "Found $service in $service_file" | ||
79 | |||
80 | # create the required symbolic links | ||
81 | wanted_by=$(grep WantedBy $ROOT/$service_file \ | ||
82 | | sed 's,WantedBy=,,g' \ | ||
83 | | tr ',' '\n' \ | ||
84 | | grep '\(\.target$\)\|\(\.service$\)') | ||
85 | |||
86 | for r in $wanted_by; do | ||
87 | echo "WantedBy=$r found in $service" | ||
88 | if [ "$action" = "enable" ]; then | ||
89 | mkdir -p $ROOT/etc/systemd/system/$r.wants | ||
90 | ln -s $service_file $ROOT/etc/systemd/system/$r.wants | ||
91 | echo "Enabled $service for $wanted_by." | ||
92 | else | ||
93 | rm -f $ROOT/etc/systemd/system/$r.wants/$service | ||
94 | rmdir --ignore-fail-on-non-empty -p $ROOT/etc/systemd/system/$r.wants | ||
95 | echo "Disabled $service for $wanted_by." | ||
96 | fi | ||
97 | done | ||
98 | |||
99 | # create the required symbolic 'Alias' links | ||
100 | alias=$(grep Alias $ROOT/$service_file \ | ||
101 | | sed 's,Alias=,,g' \ | ||
102 | | tr ',' '\n' \ | ||
103 | | grep '\.service$') | ||
104 | |||
105 | for r in $alias; do | ||
106 | if [ "$action" = "enable" ]; then | ||
107 | mkdir -p $ROOT/etc/systemd/system | ||
108 | ln -s $service_file $ROOT/etc/systemd/system/$r | ||
109 | echo "Enabled $service for $alias." | ||
110 | else | ||
111 | rm -f $ROOT/etc/systemd/system/$r | ||
112 | echo "Disabled $service for $alias." | ||
113 | fi | ||
114 | done | ||
115 | |||
116 | # call us for the other required scripts | ||
117 | also=$(grep Also $ROOT/$service_file \ | ||
118 | | sed 's,Also=,,g' \ | ||
119 | | tr ',' '\n') | ||
120 | for a in $also; do | ||
121 | echo "Also=$a found in $service" | ||
122 | if [ "$action" = "enable" ]; then | ||
123 | $0 --root=$ROOT enable $a | ||
124 | fi | ||
125 | done | ||
126 | done | ||