2011-03-02 17:37:15 +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/>.
|
|
|
|
#
|
|
|
|
#
|
|
|
|
# Manage packages on Debian and co.
|
|
|
|
#
|
|
|
|
|
2011-03-02 17:54:31 +00:00
|
|
|
if [ -f "$__object/parameter/name" ]; then
|
2011-03-03 07:28:24 +00:00
|
|
|
name="$(cat "$__object/parameter/name")"
|
2011-03-02 17:54:31 +00:00
|
|
|
else
|
|
|
|
name="$__object_id"
|
|
|
|
fi
|
|
|
|
|
2011-03-02 18:21:15 +00:00
|
|
|
state="$(cat "$__object/parameter/state")"
|
2011-03-02 17:54:31 +00:00
|
|
|
|
2011-03-10 12:36:58 +00:00
|
|
|
is_installed="$(grep "^Status: install ok installed" "$__object/explorer/pkg_status" || true)"
|
2011-03-03 08:12:55 +00:00
|
|
|
|
2011-03-02 17:54:31 +00:00
|
|
|
case "$state" in
|
|
|
|
installed)
|
2011-03-03 08:12:55 +00:00
|
|
|
# Install only if non-existent
|
|
|
|
if [ -z "$is_installed" ]; then
|
2011-03-02 18:21:15 +00:00
|
|
|
echo apt-get --quiet --yes install \"$name\"
|
|
|
|
fi
|
2011-03-02 17:54:31 +00:00
|
|
|
;;
|
|
|
|
deinstalled)
|
2011-03-03 08:12:55 +00:00
|
|
|
# Remove only if existent
|
|
|
|
if [ -n "$is_installed" ]; then
|
2011-03-02 18:21:15 +00:00
|
|
|
echo apt-get --quiet --yes remove \"$name\"
|
|
|
|
fi
|
2011-03-02 17:54:31 +00:00
|
|
|
;;
|
|
|
|
esac
|