systemd/debian/libnss-resolve.postrm
Martin Pitt 4dcee43697 Revert "libnss-resolve: Don't duplicate "dns" query"
This reverts commit 792434de9e.

This will break on a multi-arch system where e. g. libnss-resolve:amd64 is
installed, but not :i386, and an i386 package tries to resolve a name.
Thanks to Felipe Sateler for spotting that!

Just keep the regexp cleanup from the above commit.
2016-05-04 21:34:57 -05:00

37 lines
929 B
Bash

#!/bin/sh
set -e
# This code was taken from libnss-myhostname
remove_nss_entry() {
refcount=$(dpkg-query -f '${db:Status-Abbrev} ${binary:Package}\n' \
-W libnss-resolve | grep '^i' | wc -l)
if [ "$refcount" -gt 0 ] ; then
# there are other instances, do nothing
return
fi
echo "Checking NSS setup..."
# abort if /etc/nsswitch.conf does not exist
if ! [ -e /etc/nsswitch.conf ]; then
echo "Could not find /etc/nsswitch.conf."
return
fi
perl -i -pe '
sub remove {
my $s=shift;
$s=~s/\s+resolve\b//g;
return $s;
}
s/^(hosts:)(.*)/$1.remove($2)/e;
' /etc/nsswitch.conf
}
if [ "$1" = remove ]; then
remove_nss_entry
systemctl disable systemd-resolved.service
if [ -d /run/systemd/system ]; then
deb-systemd-invoke stop systemd-resolved.service || true
fi
fi
#DEBHELPER#