blob: 1fc77fd92bab917711c40531132ee8d94db56700 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
#!/bin/sh
ROOT=
# parse command line params
while [ $# != 0 ]; do
opt="$1"
case "$opt" in
enable)
shift
service="$1"
shift
;;
--root=*)
ROOT=${opt##--root=}
shift
;;
*)
echo "'$opt' is an unkown option; exiting with error"
exit 1
;;
esac
done
# 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
# 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
mkdir -p $ROOT/etc/systemd/system/$r.wants
ln -s $service_file $ROOT/etc/systemd/system/$r.wants
echo "Enabled $service for $wanted_by."
done
|