You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
82 lines
2.3 KiB
82 lines
2.3 KiB
#!/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`
|
|
CONFDIR=/usr/share/install2
|
|
CHECK_FILES=
|
|
|
|
. shell-config
|
|
|
|
switch() {
|
|
local sname="$1"
|
|
|
|
sname="${sname%.service}"
|
|
sname="${sname%.socket}"
|
|
|
|
[ -n "$CHECK_FILES" ] && \
|
|
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";;
|
|
esac
|
|
}
|
|
|
|
for f in services-on services-off systemd-enabled systemd-disabled; do
|
|
[ -s "$CONFDIR/$f" ] || continue
|
|
CHECK_FILES="$CHECK_FILES $CONFDIR/$f"
|
|
done
|
|
|
|
# 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
|
|
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
|
|
onoff="$(shell_config_get "$STATUS" "$i")"
|
|
[ -n "$onoff" ] || continue
|
|
echo "$i" >> "$CONFDIR"/services-"$onoff"
|
|
done
|
|
|
|
if [ -s "$CONFDIR"/services-on ]; then
|
|
if [ -s "$CONFDIR"/systemd-enabled ] || [ -n "$GLOBAL_SYSTEMD_SERVICES_ENABLE" ]; then
|
|
cat "$CONFDIR"/services-on >>"$CONFDIR"/systemd-enabled
|
|
rm "$CONFDIR"/services-on
|
|
else
|
|
cp -a "$CONFDIR"/{services-on,systemd-enabled}
|
|
fi
|
|
fi
|
|
|
|
if [ -s "$CONFDIR"/services-off ]; then
|
|
if [ -s "$CONFDIR"/systemd-disabled ] || [ -n "$GLOBAL_SYSTEMD_SERVICES_DISABLE" ]; then
|
|
cat "$CONFDIR"/services-off >>"$CONFDIR"/systemd-disabled
|
|
rm "$CONFDIR"/services-off
|
|
else
|
|
cp -a "$CONFDIR"/{services-off,systemd-disabled}
|
|
fi
|
|
fi
|
|
|
|
rm "$STATUS"
|
|
|
|
:
|
|
|