#! /bin/bash # # Written by sbrabec@suse.com # declare -a PRESET_FILES declare -A PRESETS declare -A PRESETS_OLD declare -A PRESETS_OLD_WILDCARD declare -A PRESETS_WILDCARD save_preset_states () { PRESET_FILES=(*.preset) for ((i=${#PRESET_FILES[@]}-1 ; i>= 0 ; i-- )) ; do FILE=${PRESET_FILES[i]} exec 3<"$FILE" while read -u3 ENABLE SERVICE PAD ; do if test -z "$SERVICE" ; then continue; fi case "$ENABLE" in enable|disable) PRESETS[$SERVICE]=$ENABLE;; esac done exec 3<&- done exec 3>systemd_preset-old.rpm-tmp for PRESET in "${!PRESETS[@]}" ; do echo >&3 "${PRESETS[$PRESET]} $PRESET" done exec 3>&- } apply_preset_state_changes () { if ! test -f systemd_preset-old.rpm-tmp ; then return fi exec 3= 0 ; i-- )) ; do FILE=${PRESET_FILES[i]} exec 3<"$FILE" while read -u3 ENABLE SERVICE PAD ; do if test -z "$SERVICE" ; then continue fi case "$ENABLE" in enable|disable) case $SERVICE in *"*"*|*"?"*) PRESETS_WILDCARD[$SERVICE]=$ENABLE;; *) PRESETS[$SERVICE]=$ENABLE;; esac esac done exec 3<&- done if test -x /usr/bin/systemctl ; then /usr/bin/systemctl list-unit-files $GLOBAL fi >systemd_preset-states.rpm-tmp exec 3&2 "Unkown command '$1'" exit 1 esac