forked from ungleich-public/cdist
support absent/present in __package_apt
Signed-off-by: Nico Schottelius <nico@brief.schottelius.org>
This commit is contained in:
parent
2aed047f75
commit
602e57455d
2 changed files with 16 additions and 10 deletions
|
@ -1,6 +1,6 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
#
|
#
|
||||||
# 2011 Nico Schottelius (nico-cdist at schottelius.org)
|
# 2011-2012 Nico Schottelius (nico-cdist at schottelius.org)
|
||||||
#
|
#
|
||||||
# This file is part of cdist.
|
# This file is part of cdist.
|
||||||
#
|
#
|
||||||
|
@ -31,8 +31,8 @@ fi
|
||||||
packages="$(apt-cache showpkg "$name" | sed -e "1,/Reverse Provides:/d" | cut -d ' ' -f 1) $name"
|
packages="$(apt-cache showpkg "$name" | sed -e "1,/Reverse Provides:/d" | cut -d ' ' -f 1) $name"
|
||||||
for p in $packages; do
|
for p in $packages; do
|
||||||
if [ -n "$(dpkg -s "$p" 2>/dev/null | grep "^Status: install ok installed$")" ]; then
|
if [ -n "$(dpkg -s "$p" 2>/dev/null | grep "^Status: install ok installed$")" ]; then
|
||||||
echo "installed $p"
|
echo "present $p"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
echo "removed"
|
echo absent
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
#
|
#
|
||||||
# 2011 Nico Schottelius (nico-cdist at schottelius.org)
|
# 2011-2012 Nico Schottelius (nico-cdist at schottelius.org)
|
||||||
#
|
#
|
||||||
# This file is part of cdist.
|
# This file is part of cdist.
|
||||||
#
|
#
|
||||||
|
@ -28,11 +28,18 @@ else
|
||||||
fi
|
fi
|
||||||
|
|
||||||
state_should="$(cat "$__object/parameter/state")"
|
state_should="$(cat "$__object/parameter/state")"
|
||||||
|
|
||||||
|
# Correct pre 2.1 naming - FIXME in 2.1
|
||||||
|
case "$state_should" in
|
||||||
|
installed) state_should="present" ;;
|
||||||
|
removed) state_should="absent" ;;
|
||||||
|
esac
|
||||||
|
|
||||||
state_is="$(cat "$__object/explorer/pkg_status")"
|
state_is="$(cat "$__object/explorer/pkg_status")"
|
||||||
case "$state_is" in
|
case "$state_is" in
|
||||||
installed*)
|
present*)
|
||||||
name="$(echo "$state_is" | cut -d ' ' -f 2)"
|
name="$(echo "$state_is" | cut -d ' ' -f 2)"
|
||||||
state_is="installed"
|
state_is="present"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
@ -40,10 +47,10 @@ aptget="DEBIAN_FRONTEND=noninteractive apt-get --quiet --yes"
|
||||||
|
|
||||||
if [ "$state_is" != "$state_should" ]; then
|
if [ "$state_is" != "$state_should" ]; then
|
||||||
case "$state_should" in
|
case "$state_should" in
|
||||||
installed)
|
present)
|
||||||
echo $aptget install \"$name\"
|
echo $aptget install \"$name\"
|
||||||
;;
|
;;
|
||||||
removed)
|
absent)
|
||||||
echo $aptget remove \"$name\"
|
echo $aptget remove \"$name\"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
|
@ -52,4 +59,3 @@ if [ "$state_is" != "$state_should" ]; then
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue