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
|
#! /bin/sh
set -e
action=$1
version=$2
CONFFILE=/etc/default/portmap
create_config() {
cat <<EOF > $CONFFILE
# Portmap configuration file
#
# Note: if you manually edit this configuration file,
# portmap configuration scripts will avoid modifying it
# (for example, by running 'dpkg-reconfigure portmap').
# If you want portmap to listen only to the loopback
# interface, uncomment the following line (it will be
# uncommented automatically if you configure this
# through debconf).
#OPTIONS="-i 127.0.0.1"
EOF
chmod 0644 $CONFFILE
}
# TBD: should be based on a given version
if [ "$action" = "upgrade" ] && [ -e /etc/portmap.conf ] \
&& dpkg --compare-versions "$version" gt 5-10 \
&& dpkg --compare-versions "$version" lt 5-13 ; then
# get rid of /etc/portmap.conf if it did not change from the default?
# Move to the "new" conffile location, let the user handle
# the change (if needed)
[ -e $CONFFILE ] && mv $CONFFILE $CONFFILE.dpkg-old
mv /etc/portmap.conf $CONFFILE
fi
# On install only, create the config file if it does not exist
#
if [ ! -e $CONFFILE ] ; then
if [ -z "$version" ] ; then
create_config
elif [ -n "$version" ] && [ "$action" = "upgrade" ] && \
dpkg --compare-versions "$version" lt 5-6; then
# or if upgrading from version older than 5-6 (which provided the file)
create_config
fi
fi
#DEBHELPER#
exit 0
|