support absent/present in __package_yum
Signed-off-by: Nico Schottelius <nico@brief.schottelius.org>
This commit is contained in:
parent
e4aafe0af9
commit
2f01fd6ce0
1 changed files with 30 additions and 16 deletions
|
@ -27,7 +27,17 @@ else
|
||||||
name="$__object_id"
|
name="$__object_id"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
state="$(cat "$__object/parameter/state")"
|
state_should="$(cat "$__object/parameter/state")"
|
||||||
|
case "$state_should" in
|
||||||
|
installed)
|
||||||
|
echo "WARNING: $state_should is deprecated and will be removed in cdist 2.1. Please change to present/absent." >&2
|
||||||
|
state_should="present"
|
||||||
|
;;
|
||||||
|
removed)
|
||||||
|
echo "WARNING: $state_should is deprecated and will be removed in cdist 2.1. Please change to present/absent." >&2
|
||||||
|
state_should="absent"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
if grep -q -E "(centos|redhat|amazon)" "$__global/explorer/os"; then
|
if grep -q -E "(centos|redhat|amazon)" "$__global/explorer/os"; then
|
||||||
opts="-y --quiet"
|
opts="-y --quiet"
|
||||||
|
@ -37,19 +47,23 @@ fi
|
||||||
|
|
||||||
not_installed="^no package provides"
|
not_installed="^no package provides"
|
||||||
|
|
||||||
case "$state" in
|
if grep -q "$not_installed" "$__object/explorer/pkg_version"; then
|
||||||
installed)
|
state_is="absent"
|
||||||
if grep -q "$not_installed" "$__object/explorer/pkg_version"; then
|
else
|
||||||
echo yum $opts install \"$name\"
|
state_is="present"
|
||||||
fi
|
fi
|
||||||
;;
|
|
||||||
removed)
|
[ "$state_is" = "$state_should ] && exit 0
|
||||||
if ! grep -q "$not_installed" "$__object/explorer/pkg_version"; then
|
|
||||||
echo yum $opts remove \"$name\"
|
case "$state_should" in
|
||||||
fi
|
present)
|
||||||
;;
|
echo yum $opts install \"$name\"
|
||||||
*)
|
;;
|
||||||
echo "Unknown state: $state" >&2
|
absent)
|
||||||
exit 1
|
echo yum $opts remove \"$name\"
|
||||||
;;
|
;;
|
||||||
|
*)
|
||||||
|
echo "Unknown state: $state_should" >&2
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
Loading…
Reference in a new issue