mkimage-profiles/features.in/services/install2/image-scripts.d/10-services
Michael Shigorin f5fd77640a services: pass service status to installer
This is long overdue: services feature influences live
and rescue but doesn't do anything to the installed system
as that's behind the installation barrier; some piggybacking
required to do that has been merged into installer back in
2012 apparently (thanks to boyarsh@ for both doing that and
bringing my attention to this fact; it's 65-setup-services.sh
as of today).

So the only thing missing has been the bridge to prepare
those files -- still some more tweakery is required given the
two-stage process arranged so that reusable configuration could
include some sane defaults but the release manager is ultimately
able to override anything without extra kludges; thank legion@
for his wonderful libshell either.

NB: install2 script is a partial clone of rootfs one since
processing the variables is identical; still rootfs script
has to change service state directly while install2 one
has to deposit the information for installer to handle.
2014-02-09 02:38:16 +04:00

42 lines
1.1 KiB
Bash
Executable File

#!/bin/sh
# this script piggybacks service status information
# into the system to be installed (instead of applying
# it to rootfs being formed immediately)
# NB:install2 is not a rootfs, handling differs either
STATUS=`mktemp`
. shell-config
switch() {
case "$2" in
on|off)
shell_config_set "$STATUS" "$1" "$2";;
esac
}
# 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
SERVICES="$GLOBAL_DEFAULT_SERVICES_ENABLE $GLOBAL_DEFAULT_SERVICES_DISABLE"
SERVICES="$SERVICES $GLOBAL_SERVICES_ENABLE $GLOBAL_SERVICES_DISABLE"
SERVICES="$(echo $SERVICES | sort -u)"
# TODO: provide systemd-specific hooks too?
for i in $SERVICES; do
onoff="$(shell_config_get "$STATUS" "$i")"
[ -n "$onoff" ] || continue
echo "$i" >> /usr/share/install2/services-"$onoff"
done
rm "$STATUS"
: