features/services: Add SYSTEMD_SERVICES_{ENABLE,DISABLE}

Support systemd-spicific services, e.g. *.socket amd .service units.
This commit is contained in:
Mikhail Efremov 2019-12-12 17:44:18 +03:00 committed by Anton Midyukov
parent a9acdd2327
commit 183d85fa9f
3 changed files with 24 additions and 4 deletions

View File

@ -4,6 +4,8 @@ use/services: sub/rootfs
@$(call xport,DEFAULT_SERVICES_DISABLE)
@$(call xport,SERVICES_ENABLE)
@$(call xport,SERVICES_DISABLE)
@$(call xport,SYSTEMD_SERVICES_ENABLE)
@$(call xport,SYSTEMD_SERVICES_DISABLE)
use/services/lvm2-disable: use/services
@$(call add,DEFAULT_SERVICES_DISABLE,lvm2-lvmetad)

View File

@ -13,10 +13,18 @@ CHECK_FILES=
. shell-config
switch() {
local sname="$1"
sname="${sname%.service}"
sname="${sname%.socket}"
[ -n "$CHECK_FILES" ] && \
egrep -qs "^[[:blank:]]*$1(.service|.socket)?[[:blank:]]*$" \
egrep -qs "^[[:blank:]]*$sname(.service|.socket)?[[:blank:]]*$" \
$CHECK_FILES && return ||:
# avoid service duplication: drop sevice without unit type
[ "$sname" = "$1" ] || shell_config_del "$STATUS" "$sname"
case "$2" in
on|off)
shell_config_set "$STATUS" "$1" "$2";;
@ -36,8 +44,13 @@ for i in $GLOBAL_DEFAULT_SERVICES_DISABLE; do switch $i off; done
for i in $GLOBAL_SERVICES_ENABLE; do switch $i on; done
for i in $GLOBAL_SERVICES_DISABLE; do switch $i off; done
# systemd services
for i in $GLOBAL_SYSTEMD_SERVICES_ENABLE; do switch $i on; done
for i in $GLOBAL_SYSTEMD_SERVICES_DISABLE; do switch $i off; done
SERVICES="$GLOBAL_DEFAULT_SERVICES_ENABLE $GLOBAL_DEFAULT_SERVICES_DISABLE"
SERVICES="$SERVICES $GLOBAL_SERVICES_ENABLE $GLOBAL_SERVICES_DISABLE"
SERVICES="$SERVICES $GLOBAL_SYSTEMD_SERVICES_ENABLE $GLOBAL_SYSTEMD_SERVICES_DISABLE"
SERVICES="$(echo $SERVICES | sort -u)"
for i in $SERVICES; do
@ -47,7 +60,7 @@ for i in $SERVICES; do
done
if [ -s "$CONFDIR"/services-on ]; then
if [ -s "$CONFDIR"/systemd-enabled ]; then
if [ -s "$CONFDIR"/systemd-enabled ] || [ -n "$GLOBAL_SYSTEMD_SERVICES_ENABLE" ]; then
cat "$CONFDIR"/services-on >>"$CONFDIR"/systemd-enabled
rm "$CONFDIR"/services-on
else
@ -56,7 +69,7 @@ if [ -s "$CONFDIR"/services-on ]; then
fi
if [ -s "$CONFDIR"/services-off ]; then
if [ -s "$CONFDIR"/systemd-disabled ]; then
if [ -s "$CONFDIR"/systemd-disabled ] || [ -n "$GLOBAL_SYSTEMD_SERVICES_DISABLE" ]; then
cat "$CONFDIR"/services-off >>"$CONFDIR"/systemd-disabled
rm "$CONFDIR"/services-off
else

View File

@ -19,7 +19,7 @@ switch() {
esac
{
[ -z "$SYSTEMCTL" ] || /bin/systemctl --no-reload $sc $1.service
[ -z "$SYSTEMCTL" ] || /bin/systemctl --no-reload $sc $1
[ -z "$CHKCONFIG" ] || /sbin/chkconfig $1 $cc
} # 2>/dev/null
}
@ -32,4 +32,9 @@ for i in $GLOBAL_DEFAULT_SERVICES_DISABLE; do switch $i off; done
for i in $GLOBAL_SERVICES_ENABLE; do switch $i on; done
for i in $GLOBAL_SERVICES_DISABLE; do switch $i off; done
# systemd services
CHKCONFIG=
for i in $GLOBAL_SYSTEMD_SERVICES_ENABLE; do switch $i on; done
for i in $GLOBAL_SYSTEMD_SERVICES_DISABLE; do switch $i off; done
: