Commit 183d85fa authored by Mikhail Efremov's avatar Mikhail Efremov Committed by Anton Midyukov

features/services: Add SYSTEMD_SERVICES_{ENABLE,DISABLE}

Support systemd-spicific services, e.g. *.socket amd .service units.
parent a9acdd23
......@@ -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)
......
......@@ -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
......
......@@ -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
:
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment