mirror of
https://github.com/openembedded/meta-openembedded.git
synced 2026-07-16 16:27:27 +00:00
systemd-systemctl-native: add multiple services support
Thanks to Otavio Salvador for helping hint [1] [1] http://lists.linuxtogo.org/pipermail/openembedded-devel/2012-February/037856.html Signed-off-by: Andreas Müller <schnitzeltony@googlemail.com> Acked-by: Otavio Salvador <otavio@ossystems.com.br> Signed-off-by: Koen Kooi <koen@dominion.thruhere.net>
This commit is contained in:
committed by
Koen Kooi
parent
2b402359f2
commit
9d72ff10c5
@@ -10,50 +10,59 @@ while [ $# != 0 ]; do
|
|||||||
enable)
|
enable)
|
||||||
shift
|
shift
|
||||||
|
|
||||||
service="$1"
|
services="$1"
|
||||||
|
in_enable="1"
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
--root=*)
|
--root=*)
|
||||||
ROOT=${opt##--root=}
|
ROOT=${opt##--root=}
|
||||||
|
in_enable="0"
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "'$opt' is an unkown option; exiting with error"
|
if [ "$in_enable" = "1" ]; then
|
||||||
exit 1
|
services="$services $opt"
|
||||||
|
shift
|
||||||
|
else
|
||||||
|
echo "'$opt' is an unkown option; exiting with error"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
# find service file
|
for service in "$services"; do
|
||||||
for p in $ROOT/etc/systemd/system \
|
# find service file
|
||||||
$ROOT/lib/systemd/system \
|
for p in $ROOT/etc/systemd/system \
|
||||||
$ROOT/usr/lib/systemd/system; do
|
$ROOT/lib/systemd/system \
|
||||||
if [ -e $p/$service ]; then
|
$ROOT/usr/lib/systemd/system; do
|
||||||
service_file=$p/$service
|
if [ -e $p/$service ]; then
|
||||||
service_file=${service_file##$ROOT}
|
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
|
fi
|
||||||
done
|
|
||||||
if [ -z "$service_file" ]; then
|
|
||||||
echo "'$service' couldn't be found; exiting with error"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# create the required symbolic links
|
# create the required symbolic links
|
||||||
wanted_by=$(grep WantedBy $ROOT/$service_file \
|
wanted_by=$(grep WantedBy $ROOT/$service_file \
|
||||||
| sed 's,WantedBy=,,g' \
|
| sed 's,WantedBy=,,g' \
|
||||||
| tr ',' '\n' \
|
| tr ',' '\n' \
|
||||||
| grep '\.target$')
|
| grep '\.target$')
|
||||||
|
|
||||||
for r in $wanted_by; do
|
for r in $wanted_by; do
|
||||||
mkdir -p $ROOT/etc/systemd/system/$r.wants
|
mkdir -p $ROOT/etc/systemd/system/$r.wants
|
||||||
ln -s $service_file $ROOT/etc/systemd/system/$r.wants
|
ln -s $service_file $ROOT/etc/systemd/system/$r.wants
|
||||||
echo "Enabled $service for $wanted_by."
|
echo "Enabled $service for $wanted_by."
|
||||||
done
|
done
|
||||||
|
|
||||||
# call us for the other required scripts
|
# call us for the other required scripts
|
||||||
also=$(grep Also $ROOT/$service_file \
|
also=$(grep Also $ROOT/$service_file \
|
||||||
| sed 's,Also=,,g' \
|
| sed 's,Also=,,g' \
|
||||||
| tr ',' '\n')
|
| tr ',' '\n')
|
||||||
for a in $also; do
|
for a in $also; do
|
||||||
$0 --root=$ROOT enable $a
|
$0 --root=$ROOT enable $a
|
||||||
|
done
|
||||||
done
|
done
|
||||||
|
|||||||
Reference in New Issue
Block a user