123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- #!/bin/sh
- set -e
- pathfind() {
- OLDIFS="$IFS"
- IFS=:
- for p in $PATH; do
- if [ -x "$p/$*" ]; then
- IFS="$OLDIFS"
- return 0
- fi
- done
- IFS="$OLDIFS"
- return 1
- }
- remove_gns() {
- # abort if /etc/nsswitch.conf does not exist
- if ! [ -e /etc/nsswitch.conf ]; then
- return
- fi
- perl -i -pe '
- my @remove=(
- "gns [NOTFOUND=return]",
- );
- sub remove {
- my $s=shift;
- foreach my $bit (@remove) {
- $s=~s/\s+\Q$bit\E//g;
- }
- return $s;
- }
- s/^(hosts:)(.*)/$1.remove($2)/e;
- ' /etc/nsswitch.conf
- }
- case "${1}" in
- purge)
- if [ -e /usr/share/debconf/confmodule ]
- then
- . /usr/share/debconf/confmodule
- db_version 2.0
- db_get gnunet-systempeer/username
- _USERNAME="${RET:-gnunet}"
- db_get gnunet-systempeer/groupname
- _GROUPNAME="${RET:-gnunet}"
- db_get gnunet-dns/libnsswitch
- _LIBNSSWITCH="${RET}"
- else
- _USERNAME="gnunet"
- _GROUPNAME="gnunet"
- fi
- GNUNETDNS_GROUP="gnunetdns"
- if $_LIBNSSWITCH
- then
- rm -rf /usr/lib/x86_64-linux-gnu/usr/libnss_gns.so.2
- rm -rf /usr/lib/x86_64-linux-gnu/usr/libnss_gns4.so.2
- rm -rf /usr/lib/x86_64-linux-gnu/usr/libnss_gns6.so.2
- remove_gns
- fi
- if pathfind deluser
- then
- deluser --quiet --system ${_USERNAME} || true
- fi
- if pathfind delgroup
- then
- delgroup --quiet --system --only-if-empty ${_GROUPNAME} || true
- delgroup --quiet --system --only-if-empty ${GNUNETDNS_GROUP} || true
- fi
- rm -rf /var/log/gnunet.log /var/lib/gnunet /etc/default/gnunet
- ;;
- remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
- if $_LIBNSSWITCH
- then
- rm -rf /usr/lib/x86_64-linux-gnu/usr/libnss_gns.so.2
- rm -rf /usr/lib/x86_64-linux-gnu/usr/libnss_gns4.so.2
- rm -rf /usr/lib/x86_64-linux-gnu/usr/libnss_gns6.so.2
- remove_gns
- fi
- ;;
- *)
- echo "postrm called with unknown argument \`${1}'" >&2
- exit 1
- ;;
- esac
- #DEBHELPER#
- exit 0
|