document, cleanup and theoretically finish __debconf_set_selections

Signed-off-by: Nico Schottelius <nico@kr.ethz.ch>
This commit is contained in:
Nico Schottelius 2011-04-01 12:47:48 +02:00
parent 48a96591d1
commit 0db21eb308
5 changed files with 15 additions and 92 deletions

View File

@ -1,31 +0,0 @@
#!/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/>.
#
#
# Retrieve the status of a package - parsed dpkg output
#
if [ -f "$__object/parameter/name" ]; then
name="$(cat "$__object/parameter/name")"
else
name="$__object_id"
fi
# Except dpkg failing, if package is not known / installed
dpkg -s "$name" 2>/dev/null || exit 0

View File

@ -18,36 +18,9 @@
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
#
#
# Manage packages on Debian and co.
# Setup selections
#
if [ -f "$__object/parameter/name" ]; then
name="$(cat "$__object/parameter/name")"
else
name="$__object_id"
fi
# Check for preseeding and add preseed as here document
if [ -f "$__object/parameter/preseed" ]; then
echo "debconf-set-selections << __file-eof"
cat "$(cat "$__object/parameter/preseed")"
echo "__file-eof"
fi
state="$(cat "$__object/parameter/state")"
is_installed="$(grep "^Status: install ok installed" "$__object/explorer/pkg_status" || true)"
case "$state" in
installed)
# Install only if non-existent
if [ -z "$is_installed" ]; then
echo apt-get --quiet --yes install \"$name\"
fi
;;
uninstalled)
# Remove only if existent
if [ -n "$is_installed" ]; then
echo apt-get --quiet --yes remove \"$name\"
fi
;;
esac
echo "debconf-set-selections << __file-eof"
cat "$__object/parameter/file"
echo "__file-eof"

View File

@ -1,31 +1,22 @@
cdist-type__package_apt(7)
==========================
cdist-type__debconf_set_selections(7)
=====================================
Nico Schottelius <nico-cdist--@--schottelius.org>
NAME
----
cdist-type__package_apt - Manage packages with apt-get
cdist-type__debconf_set_selections - Setup debconf selections
DESCRIPTION
-----------
apt-get is usually used on Debian and variants (like Ubuntu) to
manage packages.
On Debian and alike systems debconf-set-selections(1) can be used
to setup configuration parameters.
REQUIRED PARAMETERS
-------------------
state::
Either "installed" or "deinstalled".
OPTIONAL PARAMETERS
-------------------
name::
If supplied, use the name and not the object id as the package name.
preseed::
file::
If supplied, use the given filename as input for debconf-set-selections(1)
@ -33,24 +24,17 @@ EXAMPLES
--------
--------------------------------------------------------------------------------
# Ensure zsh in installed
__package_apt zsh --state installed
# Setup configuration for nslcd
__debconf_set_selections nslcd --file /path/to/file
# In case you only want *a* webserver, but don't care which one
__package_apt webserver --state installed --name nginx
# Install package with defaults (from a type)
__package_apt postfix --state installed --preseed "$__type/files/postfix-seed"
# Remove obsolete package
__package_apt puppet --state deinstalled
# Setup configuration for nslcd from another type
__debconf_set_selections nslcd --file "$__type/files/preseed/nslcd"
--------------------------------------------------------------------------------
SEE ALSO
--------
- cdist-type(7)
- cdist-type__package(7)
COPYING

View File

@ -1,3 +0,0 @@
name
preseed
version

View File

@ -1 +1 @@
state
file