Newer
Older
Digital_Repository / OARiNZ / DIY / deb_package / eprints-3.0 / debian / eprints.postrm
nstanger on 7 Jun 2007 2 KB - Added debian package source.
  1. #!/bin/sh
  2. # postrm script for eprints
  3. #
  4. # see: dh_installdeb(1)
  5.  
  6. set -e
  7.  
  8. # summary of how this script can be called:
  9. # * <postrm> `remove'
  10. # * <postrm> `purge'
  11. # * <old-postrm> `upgrade' <new-version>
  12. # * <new-postrm> `failed-upgrade' <old-version>
  13. # * <new-postrm> `abort-install'
  14. # * <new-postrm> `abort-install' <old-version>
  15. # * <new-postrm> `abort-upgrade' <old-version>
  16. # * <disappearer's-postrm> `disappear' <r>overwrit>r> <new-version>
  17. # for details, see http://www.debian.org/doc/debian-policy/ or
  18. # the debian-policy package
  19.  
  20.  
  21. case "$1" in
  22. purge)
  23. # Remove the eprints user and group.
  24. deluser --system --quiet eprints || true
  25. delgroup --system --quiet eprints || true
  26.  
  27. # Remove the Apache config files.
  28. rm -f /etc/apache2/sites-available/eprints3
  29.  
  30. # Remove the EPrints databases and MySQL users.
  31. if [ -d /opt/eprints3/archives ]; then
  32. # Note that databases created directly using epadmin will (should) have names
  33. # of the form "archivename", whereas those created using the webmin tool will
  34. # have names like "eprints_archivename". We just try to drop both and allow
  35. # things to continue regardless of what happens. Note that we drop each one
  36. # separately so that if the first one fails, the other still runs. We'll get
  37. # a slew of errors regardless, so redirect stderr to reduce the noise.
  38. ( find /opt/eprints3/archives -mindepth 1 -maxdepth 1 -type d \
  39. -printf "%f\neprints_%f\n" \
  40. | xargs --max-args=1 --no-run-if-empty mysqladmin -u root -f drop \
  41. ) 2> /dev/null || true
  42.  
  43. # We need to do the same sort of thing with the users as well.
  44. ( find /opt/eprints3/archives -mindepth 1 -maxdepth 1 -type d \
  45. -printf "\"drop user '%f'@'localhost';\"\n" \
  46. -printf "\"drop user 'eprints_%f'@'localhost';\"\n" \
  47. | xargs --max-args=1 --no-run-if-empty mysql -u root -D mysql -f -e \
  48. ) 2> /dev/null || true
  49. fi
  50.  
  51. # Remove the /opt/eprints3 directory and all content.
  52. rm -rf /opt/eprints3
  53. ;;
  54. remove|failed-upgrade|abort-install|abort-upgrade|disappear)
  55. # Disable EPrints Apache config.
  56. /usr/sbin/a2dissite eprints3
  57.  
  58. # Restart Apache to expunge the EPrints archives and ensure that
  59. # nothing is left cached.
  60. if [ -x "/etc/init.d/apache2" ]; then
  61. invoke-rc.d apache2 restart
  62. fi
  63. ;;
  64. upgrade)
  65. # Disable EPrints Apache config.
  66. /usr/sbin/a2dissite eprints3
  67.  
  68. # No need to restart Apache as the new version of the package will
  69. # (should!) do it anyway.
  70. ;;
  71.  
  72. *)
  73. echo "postrm called with unknown argument \`$1'" >&2
  74. exit 1
  75.  
  76. esac
  77.  
  78. # dh_installdeb will replace this with shell code automatically
  79. # generated by other debhelper scripts.
  80.  
  81. #DEBHELPER#
  82.  
  83. exit 0