postinst is in cfengine2 2.2.10-5build1.
This file is a maintainer script. It is executed when installing (*inst) or removing (*rm) the package.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 | #! /bin/sh
# summary of how this script can be called:
# * <postinst> `configure' <most-recently-configured-version>
# * <old-postinst> `abort-upgrade' <new version>
# * <conflictor's-postinst> `abort-remove' `in-favour' <package>
# <new-version>
# * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
# <failed-install-package> <version> `removing'
# <conflicting-package> <version>
# for details, see /usr/doc/packaging-manual/
#
# quoting from the policy:
# Any necessary prompting should almost always be confined to the
# post-installation script, and should be protected with a conditional
# so that unnecessary prompting doesn't happen if a package's
# installation fails and the `postinst' is called with `abort-upgrade',
# `abort-remove' or `abort-deconfigure'.
set -e
INPUTS=/var/lib/cfengine2/inputs
. /usr/share/debconf/confmodule
db_version 2.0
make_key () {
if [ ! -f /var/lib/cfengine2/ppkeys/localhost.priv ]; then
cfkey
fi
}
sed_script_config_daemons () {
# Spits out sed commands to re-configure /etc/default/cfengine2
ALL_DAEMONS="CFSERVD CFEXECD CFENVD"
for DAEMON in $ALL_DAEMONS; do
LC_DAEMON=$(echo $DAEMON | tr 'A-Z' 'a-z')
db_get "cfengine2/run_${LC_DAEMON}"
case "$RET" in
true|1)
echo -n "s/^RUN_$DAEMON=[01]/RUN_$DAEMON=1/;"
;;
false|0)
echo -n "s/^RUN_$DAEMON=[01]/RUN_$DAEMON=0/;"
;;
*) echo "Wacky debconf answer: '$RET'" >&2 ; return 1;;
esac
done
}
config_daemons() {
CUR=/etc/default/cfengine2
test ! -f "$CUR" && cp -p /usr/share/cfengine2/default "$CUR"
SEDCMD=$(sed_script_config_daemons)
if [ ! "x$SEDCMD" = "x" ]; then
NEW=$(mktemp "${CUR}.XXXXXXXXX")
cp -a -f "$CUR" "$NEW"
sed $SEDCMD < "$CUR" > "$NEW"
mv -f "$NEW" "$CUR"
fi
}
no_files_in_common() {
# returns 0 if no files in $1 exist in $2;
# 1 if they intersect; 2 if symlink
for d in "$@"; do
test -L "$d" && return 2
test -d "$d" || return 0
done
(cd "$1" && find . -mindepth 1 -print0 2>/dev/null) |\
(cd "$2" && perl -ne \
'BEGIN {$/="\0"}; chomp; if (-e) {exit 1;}')
return $?
}
move_inputs_to_etc() {
test -d "$INPUTS" && return
if no_files_in_common "$INPUTS" /etc/cfengine; then
(cd "$INPUTS" && tar cf - .) | (cd /etc/cfengine && tar xpf -) && \
{ rm -rf "$INPUTS" && ln -s /etc/cfengine "$INPUTS"; }
else
cat <<-EOF
WARNING: Could not move files from $INPUTS to /etc/cfengine
Please do this manually and then run:
\$ ln -s /etc/cfengine $INPUTS
EOF
fi
}
case "$1" in
configure|reconfigure)
make_key
config_daemons
rm -f /var/lib/cfengine2/av.db
test -L "$INPUTS" || move_inputs_to_etc
;;
abort-upgrade|abort-remove|abort-deconfigure)
;;
*)
echo "postinst called with unknown argument \`$1'" >&2
exit 0
;;
esac
# Automatically added by dh_installinit
if [ -x "/etc/init.d/cfengine2" ] || [ -e "/etc/init/cfengine2.conf" ]; then
if [ ! -e "/etc/init/cfengine2.conf" ]; then
update-rc.d cfengine2 defaults >/dev/null
fi
invoke-rc.d cfengine2 start || exit $?
fi
# End automatically added section
|