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 ...@@ -4,6 +4,8 @@ use/services: sub/rootfs
@$(call xport,DEFAULT_SERVICES_DISABLE) @$(call xport,DEFAULT_SERVICES_DISABLE)
@$(call xport,SERVICES_ENABLE) @$(call xport,SERVICES_ENABLE)
@$(call xport,SERVICES_DISABLE) @$(call xport,SERVICES_DISABLE)
@$(call xport,SYSTEMD_SERVICES_ENABLE)
@$(call xport,SYSTEMD_SERVICES_DISABLE)
use/services/lvm2-disable: use/services use/services/lvm2-disable: use/services
@$(call add,DEFAULT_SERVICES_DISABLE,lvm2-lvmetad) @$(call add,DEFAULT_SERVICES_DISABLE,lvm2-lvmetad)
......
...@@ -13,10 +13,18 @@ CHECK_FILES= ...@@ -13,10 +13,18 @@ CHECK_FILES=
. shell-config . shell-config
switch() { switch() {
local sname="$1"
sname="${sname%.service}"
sname="${sname%.socket}"
[ -n "$CHECK_FILES" ] && \ [ -n "$CHECK_FILES" ] && \
egrep -qs "^[[:blank:]]*$1(.service|.socket)?[[:blank:]]*$" \ egrep -qs "^[[:blank:]]*$sname(.service|.socket)?[[:blank:]]*$" \
$CHECK_FILES && return ||: $CHECK_FILES && return ||:
# avoid service duplication: drop sevice without unit type
[ "$sname" = "$1" ] || shell_config_del "$STATUS" "$sname"
case "$2" in case "$2" in
on|off) on|off)
shell_config_set "$STATUS" "$1" "$2";; shell_config_set "$STATUS" "$1" "$2";;
...@@ -36,8 +44,13 @@ for i in $GLOBAL_DEFAULT_SERVICES_DISABLE; do switch $i off; done ...@@ -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_ENABLE; do switch $i on; done
for i in $GLOBAL_SERVICES_DISABLE; do switch $i off; 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="$GLOBAL_DEFAULT_SERVICES_ENABLE $GLOBAL_DEFAULT_SERVICES_DISABLE"
SERVICES="$SERVICES $GLOBAL_SERVICES_ENABLE $GLOBAL_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)" SERVICES="$(echo $SERVICES | sort -u)"
for i in $SERVICES; do for i in $SERVICES; do
...@@ -47,7 +60,7 @@ for i in $SERVICES; do ...@@ -47,7 +60,7 @@ for i in $SERVICES; do
done done
if [ -s "$CONFDIR"/services-on ]; then 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 cat "$CONFDIR"/services-on >>"$CONFDIR"/systemd-enabled
rm "$CONFDIR"/services-on rm "$CONFDIR"/services-on
else else
...@@ -56,7 +69,7 @@ if [ -s "$CONFDIR"/services-on ]; then ...@@ -56,7 +69,7 @@ if [ -s "$CONFDIR"/services-on ]; then
fi fi
if [ -s "$CONFDIR"/services-off ]; then 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 cat "$CONFDIR"/services-off >>"$CONFDIR"/systemd-disabled
rm "$CONFDIR"/services-off rm "$CONFDIR"/services-off
else else
......
...@@ -19,7 +19,7 @@ switch() { ...@@ -19,7 +19,7 @@ switch() {
esac esac
{ {
[ -z "$SYSTEMCTL" ] || /bin/systemctl --no-reload $sc $1.service [ -z "$SYSTEMCTL" ] || /bin/systemctl --no-reload $sc $1
[ -z "$CHKCONFIG" ] || /sbin/chkconfig $1 $cc [ -z "$CHKCONFIG" ] || /sbin/chkconfig $1 $cc
} # 2>/dev/null } # 2>/dev/null
} }
...@@ -32,4 +32,9 @@ for i in $GLOBAL_DEFAULT_SERVICES_DISABLE; do switch $i off; done ...@@ -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_ENABLE; do switch $i on; done
for i in $GLOBAL_SERVICES_DISABLE; do switch $i off; 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