mirror of
https://github.com/openembedded/meta-openembedded.git
synced 2026-05-09 17:59:26 +00:00
2cba3b0244
Some services can reference others for installation thought the Also key; systemctl now handles it calling itself recursively for each service. Signed-off-by: Otavio Salvador <otavio@ossystems.com.br> Signed-off-by: Koen Kooi <koen@dominion.thruhere.net>
60 lines
1.2 KiB
Bash
Executable File
60 lines
1.2 KiB
Bash
Executable File
#!/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
|
|
|
|
# call us for the other required scripts
|
|
also=$(grep Also $ROOT/$service_file \
|
|
| sed 's,Also=,,g' \
|
|
| tr ',' '\n')
|
|
for a in $also; do
|
|
$0 --root=$ROOT enable $a
|
|
done
|