forked from ungleich-public/cdist
[type/__uci] Only generate __uci_commit if changes are required
This commit is contained in:
parent
e30ecdda53
commit
55e7b32449
1 changed files with 24 additions and 2 deletions
|
@ -18,9 +18,12 @@
|
|||
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
in_list() { printf '%s\n' "$@" | { grep -qxF "$(read -r ndl; echo "${ndl}")"; } }
|
||||
|
||||
os=$(cat "${__global:?}/explorer/os")
|
||||
|
||||
state_is=$(cat "${__object:?}/explorer/state")
|
||||
state_should=$(cat "${__object:?}/parameter/state")
|
||||
transaction_name=$(cat "${__object:?}/parameter/transaction")
|
||||
|
||||
case ${os}
|
||||
|
@ -35,6 +38,25 @@ in
|
|||
;;
|
||||
esac
|
||||
|
||||
changes_required=false
|
||||
|
||||
# Make sure the changes are being commited
|
||||
case ${state_should}
|
||||
in
|
||||
(present)
|
||||
# NOTE: order is ignored so rearranged is also fine.
|
||||
in_list "${state_is}" 'present' 'rearranged' || changes_required=true
|
||||
;;
|
||||
(absent)
|
||||
in_list "${state_is}" 'absent' || changes_required=true
|
||||
;;
|
||||
(*)
|
||||
printf 'Invalid --state: %s\n' "${state_should}" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
if ${changes_required}
|
||||
then
|
||||
# Make sure the changes are being committed
|
||||
require=${__object_name:?} __uci_commit "${transaction_name}"
|
||||
fi
|
||||
|
|
Loading…
Reference in a new issue