mkimage-profiles/features.in/services/install2/image-scripts.d/10-services
Aleksey Avdeev 47f8d6ef1c services: Add systemd-specific hooks
Signed-off-by: Aleksey Avdeev <avdeev@pkcc-tb.ru>
2015-09-24 20:41:39 +03:00

52 lines
1.2 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)"
for i in $SERVICES; do
onoff="$(shell_config_get "$STATUS" "$i")"
[ -n "$onoff" ] || continue
echo "$i" >> /usr/share/install2/services-"$onoff"
# create systemd-specific hooks
case "$onoff" in
on)
action=enabled;;
off)
action=disabled;;
*)
continue;;
esac
echo "$i" >> /usr/share/install2/systemd-"$action"
done
rm "$STATUS"
: