mkimage-profiles/features.in/services/rootfs/image-scripts.d/10-services
Mikhail Efremov 183d85fa9f features/services: Add SYSTEMD_SERVICES_{ENABLE,DISABLE}
Support systemd-spicific services, e.g. *.socket amd .service units.
2020-05-22 13:34:36 +07:00

41 lines
982 B
Bash
Executable File

#!/bin/sh
# this script implements the services regulation
# according to what has been decided in the profile
CHKCONFIG=
SYSTEMCTL=
[ ! -x /sbin/chkconfig ] || CHKCONFIG=1
[ ! -x /bin/systemctl ] || SYSTEMCTL=1
[ -n "$CHKCONFIG$SYSTEMCTL" ] || exit 0
switch() {
case "$2" in
on)
cc=on; sc=enable;;
off)
cc=off; sc=disable;;
esac
{
[ -z "$SYSTEMCTL" ] || /bin/systemctl --no-reload $sc $1
[ -z "$CHKCONFIG" ] || /sbin/chkconfig $1 $cc
} # 2>/dev/null
}
# defaults (most likely features.in ones)
for i in $GLOBAL_DEFAULT_SERVICES_ENABLE; do switch $i on; done
for i in $GLOBAL_DEFAULT_SERVICES_DISABLE; do switch $i off; done
# explicitly specified behaviour (e.g. via conf.d)
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
: