|
|
|
@ -21,28 +21,39 @@ |
|
|
|
|
# Manage Rubygem packages |
|
|
|
|
# |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if [ -f "$__object/parameter/name" ]; then |
|
|
|
|
name="$(cat "$__object/parameter/name")" |
|
|
|
|
else |
|
|
|
|
name="$__object_id" |
|
|
|
|
fi |
|
|
|
|
|
|
|
|
|
state="$(cat "$__object/parameter/state")" |
|
|
|
|
is_installed="$(grep "true" "$__object/explorer/pkg_status" || true)" |
|
|
|
|
|
|
|
|
|
case "$state" in |
|
|
|
|
state_should="$(cat "$__object/parameter/state")" |
|
|
|
|
# Correct pre 2.1 naming - FIXME in 2.1 |
|
|
|
|
case "$state_should" in |
|
|
|
|
installed) |
|
|
|
|
# Install only if non-existent |
|
|
|
|
if [ -z "$is_installed" ]; then |
|
|
|
|
echo gem install \"$name\" --no-ri --no-rdoc |
|
|
|
|
fi |
|
|
|
|
echo "WARNING: $state_should is deprecated and will be removed in cdist 2.1. Please change to present/absent." >&2 |
|
|
|
|
state_should="present" |
|
|
|
|
;; |
|
|
|
|
removed) |
|
|
|
|
# Remove only if existent |
|
|
|
|
if [ -n "$is_installed" ]; then |
|
|
|
|
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 true "$__object/explorer/pkg_status"; then |
|
|
|
|
state_is="present" |
|
|
|
|
else |
|
|
|
|
state_is="absent" |
|
|
|
|
fi |
|
|
|
|
|
|
|
|
|
[ "$state_is" = "$state_should ] && exit 0 |
|
|
|
|
|
|
|
|
|
case "$state_should" in |
|
|
|
|
present) |
|
|
|
|
echo gem install \"$name\" --no-ri --no-rdoc |
|
|
|
|
;; |
|
|
|
|
absent) |
|
|
|
|
echo gem uninstall \"$name\" |
|
|
|
|
fi |
|
|
|
|
;; |
|
|
|
|
*) |
|
|
|
|
echo "Unknown state: $state" >&2 |
|
|
|
|