mirror of
https://git.yoctoproject.org/poky
synced 2026-05-30 12:29:55 +00:00
systemd-systemctl: Add preset capability
systemd has presets as described here http://lists.freedesktop.org/archives/systemd-devel/2011-July/002830.html This patch will let distros define presets file which will override the enable/disable specified by recipes. systemctl preset without any argument will run presents on all services systemctl preset service1 service2 will run presets on specified pervice. something like enable * or disable * would mean that all services will be either enabled or disabled by default. If no user-presets are specified then 'enable' is default systemd allows basic globs but we do not implement them except '*' (From OE-Core rev: 1254416901a0c70814296a86784f4934f27c7d4a) Signed-off-by: Khem Raj <raj.khem@gmail.com> Signed-off-by: Saul Wold <sgw@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
@@ -28,6 +28,14 @@ while [ $# != 0 ]; do
|
|||||||
mask)
|
mask)
|
||||||
shift
|
shift
|
||||||
|
|
||||||
|
action="$opt"
|
||||||
|
services="$1"
|
||||||
|
cmd_args="1"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
preset)
|
||||||
|
shift
|
||||||
|
|
||||||
action="$opt"
|
action="$opt"
|
||||||
services="$1"
|
services="$1"
|
||||||
cmd_args="1"
|
cmd_args="1"
|
||||||
@@ -49,8 +57,16 @@ while [ $# != 0 ]; do
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
if [ "$action" = "preset" -a "$service_file" = "" ]; then
|
||||||
|
services=$(for f in `find $ROOT/etc/systemd/system $ROOT/lib/systemd/system $ROOT/usr/lib/systemd/system -type f 2>1`; do basename $f; done)
|
||||||
|
services="$services $opt"
|
||||||
|
presetall=1
|
||||||
|
fi
|
||||||
|
|
||||||
for service in $services; do
|
for service in $services; do
|
||||||
|
if [ "$presetall" = "1" ]; then
|
||||||
|
action="preset"
|
||||||
|
fi
|
||||||
if [ "$action" = "mask" ]; then
|
if [ "$action" = "mask" ]; then
|
||||||
if [ ! -d $ROOT/etc/systemd/system/ ]; then
|
if [ ! -d $ROOT/etc/systemd/system/ ]; then
|
||||||
mkdir -p $ROOT/etc/systemd/system/
|
mkdir -p $ROOT/etc/systemd/system/
|
||||||
@@ -80,7 +96,17 @@ for service in $services; do
|
|||||||
# If any new unit types are added to systemd they should be added
|
# If any new unit types are added to systemd they should be added
|
||||||
# to this regular expression.
|
# to this regular expression.
|
||||||
unit_types_re='\.\(service\|socket\|device\|mount\|automount\|swap\|target\|path\|timer\|snapshot\)$'
|
unit_types_re='\.\(service\|socket\|device\|mount\|automount\|swap\|target\|path\|timer\|snapshot\)$'
|
||||||
|
if [ "$action" = "preset" ]; then
|
||||||
|
action=`egrep -sh $service $ROOT/etc/systemd/user-preset/*.preset | cut -f1 -d' '`
|
||||||
|
if [ -z "$action" ]; then
|
||||||
|
globalpreset=`egrep -sh '\*' $ROOT/etc/systemd/user-preset/*.preset | cut -f1 -d' '`
|
||||||
|
if [ -n "$globalpreset" ]; then
|
||||||
|
action="$globalpreset"
|
||||||
|
else
|
||||||
|
action="enable"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
# create the required symbolic links
|
# create the required symbolic links
|
||||||
wanted_by=$(sed '/^WantedBy[[:space:]]*=/s,[^=]*=,,p;d' "$ROOT/$service_file" \
|
wanted_by=$(sed '/^WantedBy[[:space:]]*=/s,[^=]*=,,p;d' "$ROOT/$service_file" \
|
||||||
| tr ',' '\n' \
|
| tr ',' '\n' \
|
||||||
|
|||||||
Reference in New Issue
Block a user