services: Fix generation of on/off services lists

If we already have systemd-{enabled,disabled} lists, then
don't overwrite them, just add lists to them.
Services presented in the lists should be filtered out
from services-{on,off} lists already.
This fixes commit 2b50111650
"services: Don't touch services already listed in the config".
This commit is contained in:
Mikhail Efremov 2019-06-14 15:43:37 +03:00 committed by Anton Midyukov
parent 368e3ce40a
commit c84aa6be32

View File

@ -46,8 +46,23 @@ for i in $SERVICES; do
echo "$i" >> "$CONFDIR"/services-"$onoff"
done
cp -a "$CONFDIR"/{services-on,systemd-enabled}
cp -a "$CONFDIR"/{services-off,systemd-disabled}
if [ -s "$CONFDIR"/services-on ]; then
if [ -s "$CONFDIR"/systemd-enabled ]; 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 ]; then
cat "$CONFDIR"/services-off >>"$CONFDIR"/systemd-disabled
rm "$CONFDIR"/services-off
else
cp -a "$CONFDIR"/{services-off,systemd-disabled}
fi
fi
rm "$STATUS"