POSTIN
/bin/sh
if [ $1 = 1 ]; then
# ipv4 by default, as explained on the webpage
[ -f /etc/sysconfig/network ] && source /etc/sysconfig/network
unset hosts
eval $(grep ^hosts: /etc/nsswitch.conf|sed -e 's/hosts:\(.*\)$/hosts=\"\1\"/')
if [ "${NETWORKING_IPV6}" = "yes" ]; then
# for both ipv6 and ipv4
minimal_nss=mdns_minimal
dns_nss=mdns
else
minimal_nss=mdns4_minimal
dns_nss=mdns4
fi
new_hosts=$minimal_nss
for i in $hosts; do
if [ $i != mdns4_minimal ] && [ $i != mdns_minimal ] && [ $i != mdns4 ] && [ $i != mdns ]; then
if [ -n "$new_hosts" ]; then
new_hosts="$new_hosts $i"
else
new_hosts="$i"
fi
if [ $i = dns ] && [ -n "$dns_nss" ]; then
new_hosts="$new_hosts $dns_nss"
fi
fi
done
sed -i -e "s/^hosts:.*$/hosts:\t\t$new_hosts/" /etc/nsswitch.conf
fi
POSTUN
/bin/sh
if [ $1 = 0 ]; then
unset hosts
eval $(grep ^hosts: /etc/nsswitch.conf|sed -e 's/hosts:\(.*\)$/hosts=\"\1\"/')
for i in $hosts; do
if [ $i != mdns4_minimal ] && [ $i != mdns_minimal ] && [ $i != mdns4 ] && [ $i != mdns ]; then
if [ -n "$new_hosts" ]; then
new_hosts="$new_hosts $i"
else
new_hosts="$i"
fi
if [ $i = dns ] && [ -n "$dns_nss" ]; then
new_hosts="$new_hosts $dns_nss"
fi
fi
done
sed -i -e "s/^hosts:.*$/hosts:\t\t$new_hosts/" /etc/nsswitch.conf
fi