postinst is in libnss-mdns 0.10-7.
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 | #!/bin/sh
set -e
log() {
echo "$*"
}
# try to insert mdns entries to the "hosts" line in /etc/nsswitch.conf to
# automatically enable nss-mdns support; do not change the configuration if the
# "hosts" line already references some mdns lookups
insert_mdns() {
log "Checking NSS setup..."
# abort if /etc/nsswitch.conf does not exist
if ! [ -e /etc/nsswitch.conf ]; then
log "Could not find /etc/nsswitch.conf."
return
fi
perl -i -pe '
sub insert {
# this also splits on tab
my @bits=split(" ", shift);
# do not break configuration if the "hosts" line already references
# mdns
if (grep { $_ eq "mdns4_minimal" || $_ eq "mdns4"
|| $_ eq "mdns" || $_ eq "mdns_minimal"
|| $_ eq "mdns6" || $_ eq "mdns6_minimal"} @bits) {
return join " ", @bits;
}
# change "dns" into "mdns4_minimal [NOTFOUND=return] dns"
return join " ", map {
$_ eq "dns" ? ("mdns4_minimal","[NOTFOUND=return]",$_) : $_
} @bits;
}
s/^(hosts:\s+)(.*)/$1.insert($2)/e;
' /etc/nsswitch.conf
}
action="$1"
if [ configure = "$action" ]; then
if [ -z "$2" ]; then
log "First installation detected..."
# first install: setup the recommended configuration (unless
# nsswitch.conf already contains mdns entries)
insert_mdns
else
# upgrade
version="$2"
if dpkg --compare-versions "$version" lt 0.8-4.2; then
log "Upgrade from unconfigured version detected."
# versions prior to 0.8-4.2 did not setup nss-mdns automatically,
# do it now
insert_mdns
elif dpkg --compare-versions "$version" lt 0.8-6; then
log "Already configured version detected, skipping NSS setup."
# versions 0.8-4.2 and 0.8-5 installed the same configuration as
# this postinst, so nothing needs to be done
:
elif dpkg --compare-versions "$version" lt 0.8-6.1; then
log "Upgrade from possibly broken version detected."
if [ -e /etc/nsswitch.conf ]; then
# version 0.8-6 broke the configuration in multiple ways: 1)
# for systems which were upgraded from 0.8-4.2 or 0.8-5 to
# 0.8-6, the hosts line will look like:
# hosts: files dns
# cleanup from this specially formatted line into the default
# one:
sed -i \
's/^hosts: files dns $/hosts: files dns/' \
/etc/nsswitch.conf
# 2) for systems which re-installed 0.8-6 or installed 0.8-6 as the
# first version, the hosts line will look like:
# hosts: files mdns_minimal dns mdns
# cleanup from this specially formatted line into the default one:
sed -i -r \
'/^hosts:/s/\<mdns_minimal dns mdns\>/dns/' \
/etc/nsswitch.conf
fi
insert_mdns
fi
fi
fi
|