systemd-systemctl-native: add support to disable services

This adds support to disable services making possible to it to be done
during rootfs generation.

Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
Signed-off-by: Koen Kooi <koen@dominion.thruhere.net>
This commit is contained in:
Otavio Salvador
2012-04-04 12:32:54 +00:00
committed by Koen Kooi
parent 294a0b5cee
commit 3f79074a70
2 changed files with 26 additions and 8 deletions
@@ -3,7 +3,7 @@ DESCRIPTION = "Wrapper to enable of systemd services"
LICENSE = "MIT" LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COREBASE}/LICENSE;md5=3f40d7994397109285ec7b81fdeb3b58" LIC_FILES_CHKSUM = "file://${COREBASE}/LICENSE;md5=3f40d7994397109285ec7b81fdeb3b58"
PR = "r1" PR = "r2"
inherit native inherit native
@@ -3,6 +3,7 @@
ROOT= ROOT=
# parse command line params # parse command line params
action=
while [ $# != 0 ]; do while [ $# != 0 ]; do
opt="$1" opt="$1"
@@ -10,17 +11,26 @@ while [ $# != 0 ]; do
enable) enable)
shift shift
action="$opt"
services="$1" services="$1"
in_enable="1" cmd_args="1"
shift
;;
disable)
shift
action="$opt"
services="$1"
cmd_args="1"
shift shift
;; ;;
--root=*) --root=*)
ROOT=${opt##--root=} ROOT=${opt##--root=}
in_enable="0" cmd_args="0"
shift shift
;; ;;
*) *)
if [ "$in_enable" = "1" ]; then if [ "$cmd_args" = "1" ]; then
services="$services $opt" services="$services $opt"
shift shift
else else
@@ -53,9 +63,15 @@ for service in $services; do
| grep '\.target$') | grep '\.target$')
for r in $wanted_by; do for r in $wanted_by; do
mkdir -p $ROOT/etc/systemd/system/$r.wants if [ "$action" = "enable" ]; then
ln -s $service_file $ROOT/etc/systemd/system/$r.wants mkdir -p $ROOT/etc/systemd/system/$r.wants
echo "Enabled $service for $wanted_by." ln -s $service_file $ROOT/etc/systemd/system/$r.wants
echo "Enabled $service for $wanted_by."
else
rm -f $ROOT/etc/systemd/system/$r.wants/$service_file
rmdirs -p $ROOT/etc/systemd/system/$r.wants
echo "Disabled $service for $wanted_by."
fi
done done
# call us for the other required scripts # call us for the other required scripts
@@ -63,6 +79,8 @@ for service in $services; do
| 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 if [ "$action" = "enable" ]; then
$0 --root=$ROOT enable $a
fi
done done
done done