2017-06-28 11:19:32 +00:00
|
|
|
#!/bin/sh -e
|
2011-08-17 13:21:00 +00:00
|
|
|
#
|
2011-08-17 13:27:36 +00:00
|
|
|
# 2011 Chase Allen James <nx-cdist@nu-ex.com>
|
2011-08-17 13:21:00 +00:00
|
|
|
#
|
|
|
|
# This file is part of cdist.
|
|
|
|
#
|
|
|
|
# cdist is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# cdist is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
#
|
|
|
|
#
|
|
|
|
# Manage Rubygem packages
|
|
|
|
#
|
|
|
|
|
|
|
|
if [ -f "$__object/parameter/name" ]; then
|
2012-02-16 22:23:19 +00:00
|
|
|
name="$(cat "$__object/parameter/name")"
|
|
|
|
else
|
|
|
|
name="$__object_id"
|
|
|
|
fi
|
|
|
|
|
2014-12-28 03:48:42 +00:00
|
|
|
state_should="$(cat "$__object/parameter/state")"
|
2012-02-16 22:23:19 +00:00
|
|
|
|
|
|
|
if grep -q true "$__object/explorer/pkg_status"; then
|
|
|
|
state_is="present"
|
2011-08-17 13:21:00 +00:00
|
|
|
else
|
2012-02-16 22:23:19 +00:00
|
|
|
state_is="absent"
|
2011-08-17 13:21:00 +00:00
|
|
|
fi
|
|
|
|
|
2012-02-17 10:24:29 +00:00
|
|
|
[ "$state_is" = "$state_should" ] && exit 0
|
2011-08-17 13:21:00 +00:00
|
|
|
|
2012-02-16 22:23:19 +00:00
|
|
|
case "$state_should" in
|
|
|
|
present)
|
2018-10-03 17:38:47 +00:00
|
|
|
echo "gem install '$name' --no-ri --no-rdoc"
|
2018-12-07 15:53:21 +00:00
|
|
|
echo "installed" >> "$__messages_out"
|
2012-02-16 22:23:19 +00:00
|
|
|
;;
|
|
|
|
absent)
|
2018-10-03 17:38:47 +00:00
|
|
|
echo "gem uninstall '$name'"
|
2018-12-07 15:53:21 +00:00
|
|
|
echo "removed" >> "$__messages_out"
|
2012-02-16 22:23:19 +00:00
|
|
|
;;
|
|
|
|
*)
|
2012-02-16 22:29:51 +00:00
|
|
|
echo "Unknown state: $state_should" >&2
|
2012-02-16 22:23:19 +00:00
|
|
|
exit 1
|
|
|
|
;;
|
2011-08-17 13:21:00 +00:00
|
|
|
esac
|