2011-04-02 00:00:20 +00:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# 2011 Nico Schottelius (nico-cdist at schottelius.org)
|
|
|
|
#
|
|
|
|
# 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/>.
|
|
|
|
#
|
|
|
|
#
|
2011-04-02 00:19:30 +00:00
|
|
|
# Manage packages with yum (mostly Fedora)
|
2011-04-02 00:00:20 +00:00
|
|
|
#
|
|
|
|
|
|
|
|
if [ -f "$__object/parameter/name" ]; then
|
2012-04-03 03:59:24 +00:00
|
|
|
name="$(cat "$__object/parameter/name")"
|
2011-04-02 00:00:20 +00:00
|
|
|
else
|
|
|
|
name="$__object_id"
|
|
|
|
fi
|
|
|
|
|
2014-02-03 20:43:39 +00:00
|
|
|
state_should="$(cat "$__object/parameter/state")"
|
2011-04-02 00:00:20 +00:00
|
|
|
|
2012-01-26 04:11:59 +00:00
|
|
|
if grep -q -E "(centos|redhat|amazon)" "$__global/explorer/os"; then
|
2011-04-26 10:01:14 +00:00
|
|
|
opts="-y --quiet"
|
|
|
|
else
|
|
|
|
opts="--assumeyes --quiet"
|
|
|
|
fi
|
2011-04-02 00:53:07 +00:00
|
|
|
|
|
|
|
not_installed="^no package provides"
|
|
|
|
|
2012-02-16 22:26:23 +00:00
|
|
|
if grep -q "$not_installed" "$__object/explorer/pkg_version"; then
|
|
|
|
state_is="absent"
|
|
|
|
else
|
|
|
|
state_is="present"
|
|
|
|
fi
|
|
|
|
|
2012-02-17 10:24:29 +00:00
|
|
|
[ "$state_is" = "$state_should" ] && exit 0
|
2012-02-16 22:26:23 +00:00
|
|
|
|
|
|
|
case "$state_should" in
|
|
|
|
present)
|
|
|
|
echo yum $opts install \"$name\"
|
|
|
|
;;
|
|
|
|
absent)
|
|
|
|
echo yum $opts remove \"$name\"
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "Unknown state: $state_should" >&2
|
|
|
|
exit 1
|
|
|
|
;;
|
2011-04-02 00:00:20 +00:00
|
|
|
esac
|