2
0

gnunet.postrm 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. #!/bin/sh
  2. set -e
  3. pathfind() {
  4. OLDIFS="$IFS"
  5. IFS=:
  6. for p in $PATH; do
  7. if [ -x "$p/$*" ]; then
  8. IFS="$OLDIFS"
  9. return 0
  10. fi
  11. done
  12. IFS="$OLDIFS"
  13. return 1
  14. }
  15. remove_gns() {
  16. # abort if /etc/nsswitch.conf does not exist
  17. if ! [ -e /etc/nsswitch.conf ]; then
  18. return
  19. fi
  20. perl -i -pe '
  21. my @remove=(
  22. "gns [NOTFOUND=return]",
  23. );
  24. sub remove {
  25. my $s=shift;
  26. foreach my $bit (@remove) {
  27. $s=~s/\s+\Q$bit\E//g;
  28. }
  29. return $s;
  30. }
  31. s/^(hosts:)(.*)/$1.remove($2)/e;
  32. ' /etc/nsswitch.conf
  33. }
  34. case "${1}" in
  35. purge)
  36. if [ -e /usr/share/debconf/confmodule ]
  37. then
  38. . /usr/share/debconf/confmodule
  39. db_version 2.0
  40. db_get gnunet-systempeer/username
  41. _USERNAME="${RET:-gnunet}"
  42. db_get gnunet-systempeer/groupname
  43. _GROUPNAME="${RET:-gnunet}"
  44. db_get gnunet-dns/libnsswitch
  45. _LIBNSSWITCH="${RET}"
  46. else
  47. _USERNAME="gnunet"
  48. _GROUPNAME="gnunet"
  49. fi
  50. GNUNETDNS_GROUP="gnunetdns"
  51. if $_LIBNSSWITCH
  52. then
  53. rm -rf /usr/lib/x86_64-linux-gnu/usr/libnss_gns.so.2
  54. rm -rf /usr/lib/x86_64-linux-gnu/usr/libnss_gns4.so.2
  55. rm -rf /usr/lib/x86_64-linux-gnu/usr/libnss_gns6.so.2
  56. remove_gns
  57. fi
  58. if pathfind deluser
  59. then
  60. deluser --quiet --system ${_USERNAME} || true
  61. fi
  62. if pathfind delgroup
  63. then
  64. delgroup --quiet --system --only-if-empty ${_GROUPNAME} || true
  65. delgroup --quiet --system --only-if-empty ${GNUNETDNS_GROUP} || true
  66. fi
  67. rm -rf /var/log/gnunet.log /var/lib/gnunet /etc/default/gnunet
  68. ;;
  69. remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
  70. if $_LIBNSSWITCH
  71. then
  72. rm -rf /usr/lib/x86_64-linux-gnu/usr/libnss_gns.so.2
  73. rm -rf /usr/lib/x86_64-linux-gnu/usr/libnss_gns4.so.2
  74. rm -rf /usr/lib/x86_64-linux-gnu/usr/libnss_gns6.so.2
  75. remove_gns
  76. fi
  77. ;;
  78. *)
  79. echo "postrm called with unknown argument \`${1}'" >&2
  80. exit 1
  81. ;;
  82. esac
  83. #DEBHELPER#
  84. exit 0