You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

uninstall.sh 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. #!/bin/sh
  2. # Check the which command exists, and if so make sure it behaves how we want
  3. # it to...
  4. WHICH=`which which 2>/dev/null`
  5. if [ "" = "${WHICH}" ]; then
  6. echo "which command not found. Aborting.";
  7. exit 0;
  8. else
  9. # Solaris sucks
  10. BADWHICH=`which /`
  11. if [ "${BADWHICH}" != "" ]; then
  12. echo "Replacing bad which command.";
  13. # "Which" on solaris gives non-empty results for commands that don't exist
  14. which() {
  15. OUT=`${WHICH} ${1}`
  16. if [ $? -eq 0 ]; then
  17. echo ${OUT}
  18. else
  19. echo ""
  20. fi;
  21. }
  22. fi;
  23. fi
  24. # Find out where we are
  25. BASEDIR=$(cd "${0%/*}" 2>/dev/null; echo $PWD)
  26. if [ ! -e ${BASEDIR}/.uninstall.conf ]; then
  27. echo "No .uninstall.conf found, unable to continue."
  28. exit 1;
  29. else
  30. INSTALLED_AS_ROOT=""
  31. INSTALL_LOCATION=""
  32. . ${BASEDIR}/.uninstall.conf
  33. if [ "${INSTALL_LOCATION}" = "" ]; then
  34. echo "Unable to read .uninstall.conf, unable to continue."
  35. exit 1;
  36. fi;
  37. fi;
  38. PIDOF=`which pidof`
  39. if [ -z "${PIDOF}" ]; then
  40. # For some reason some distros hide pidof...
  41. if [ -e /sbin/pidof ]; then
  42. PIDOF=/sbin/pidof
  43. elif [ -e /usr/sbin/pidof ]; then
  44. PIDOF=/usr/sbin/pidof
  45. fi;
  46. fi;
  47. JAVA=`which java`
  48. if [ -e "${BASEDIR}/functions.sh" ]; then
  49. . ${BASEDIR}/functions.sh
  50. else
  51. echo "Unable to find functions.sh, unable to continue."
  52. exit 1;
  53. fi;
  54. if [ "${INSTALLED_AS_ROOT}" -eq 1 ]; then
  55. USER=`whoami`
  56. if [ "${USER}" != "root" ]; then
  57. errordialog "Uninstaller" "Uninstall Aborted. Only root can use this script"
  58. exit 1;
  59. fi
  60. fi
  61. questiondialog "Uninstaller" "Are you sure you want to uninstall DMDirc?"
  62. if [ $? -ne 0 ]; then
  63. messagedialog "Uninstaller" "Uninstall Aborted."
  64. echo "Uninstall Aborted"
  65. exit 1;
  66. fi
  67. ${JAVA} -jar ${INSTALL_LOCATION}/DMDirc.jar -k
  68. if [ $? -eq 0 ]; then
  69. errordialog "Uninstaller" "Uninstall Aborted - DMDirc is still running. Please close DMDirc before continuing"
  70. echo "Uninstall Aborted - DMDirc already running."
  71. exit 1;
  72. fi
  73. echo "Uninstalling DMDirc"
  74. echo "Removing Shortcuts.."
  75. TOOL=`which gconftool-2`
  76. COMMAND=""
  77. FILENAME=""
  78. if [ "${INSTALLED_AS_ROOT}" -eq 1 ]; then
  79. COMMAND="${TOOL} --config-source=`${TOOL} --get-default-source`"
  80. FILENAME="/usr/share/services/irc.protocol"
  81. rm -Rfv /usr/share/applications/DMDirc.desktop
  82. else
  83. COMMAND="${TOOL}"
  84. FILENAME="${HOME}/.kde/share/services/irc.protocol"
  85. rm -Rfv ${HOME}/.local/share/applications/DMDirc.desktop
  86. rm -Rfv ${HOME}/Desktop/DMDirc.desktop
  87. fi;
  88. if [ "${TOOL}" != "" ]; then
  89. CURRENT=`${COMMAND} --get /desktop/gnome/url-handlers/irc/command`
  90. if [ "${CURRENT}" = "\"${INSTALL_LOCATION}/DMDirc.sh\" -e -c %s" ]; then
  91. echo "Removing Gnome Protocol Handler"
  92. ${COMMAND} --unset /desktop/gnome/url-handlers/irc/enabled
  93. ${COMMAND} --unset /desktop/gnome/url-handlers/irc/command
  94. else
  95. echo "Not Removing Gnome Protocol Handler"
  96. fi
  97. fi
  98. if [ -e "${FILENAME}" ]; then
  99. CURRENT=`grep DMDirc ${FILENAME}`
  100. if [ "" != "${CURRENT}" ]; then
  101. echo "Removing KDE Protocol Handler"
  102. rm -Rfv ${FILENAME}
  103. else
  104. echo "Not Removing KDE Protocol Handler"
  105. fi
  106. fi
  107. echo "Removing Installation Directory"
  108. rm -Rfv ${INSTALL_LOCATION}
  109. PROFILEDIR="${HOME}/.DMDirc"
  110. if [ -e ${PROFILEDIR}/dmdirc.config ]; then
  111. questiondialog "Uninstaller" "A DMDirc profile has been detected (${PROFILEDIR}) Do you want to delete it as well?"
  112. if [ $? -eq 0 ]; then
  113. rm -Rfv "${PROFILEDIR}"
  114. fi
  115. fi
  116. messagedialog "Uninstaller" "DMDirc Uninstalled Successfully"
  117. echo "Done."
  118. exit 0;