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 5.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. #!/bin/sh
  2. if [ ! -e .uninstall.conf ]; then
  3. echo "No .uninstall.conf found, unable to continue."
  4. exit 1;
  5. else
  6. INSTALLED_AS_ROOT=""
  7. INSTALL_LOCATION=""
  8. . .uninstall.conf
  9. fi;
  10. PIDOF=`which pidof`
  11. if [ -z "${PIDOF}" ]; then
  12. # For some reason some distros hide pidof...
  13. if [ -e /sbin/pidof ]; then
  14. PIDOF=/sbin/pidof
  15. elif [ -e /usr/sbin/pidof ]; then
  16. PIDOF=/usr/sbin/pidof
  17. fi;
  18. fi;
  19. ## Helper Functions
  20. if [ -n "${PIDOF}" ]; then
  21. ISKDE=`${PIDOF} -x -s kdeinit`
  22. ISGNOME=`${PIDOF} -x -s gnome-panel`
  23. else
  24. ISKDE=`pgrep kdeinit`
  25. ISGNOME=`pgrep gnome-panel`
  26. fi;
  27. KDIALOG=`which kdialog`
  28. ZENITY=`which zenity`
  29. DIALOG=`which dialog`
  30. JAVA=`which java`
  31. messagedialog() {
  32. # Send message to console.
  33. echo ""
  34. echo "-----------------------------------------------------------------------"
  35. echo "DMDirc: ${1}"
  36. echo "-----------------------------------------------------------------------"
  37. echo "${2}"
  38. echo "-----------------------------------------------------------------------"
  39. if [ "" != "${ISKDE}" -a "" != "${KDIALOG}" -a "" != "${DISPLAY}" ]; then
  40. echo "Dialog on Display: ${DISPLAY}"
  41. ${KDIALOG} --title "DMDirc: ${1}" --msgbox "${2}"
  42. elif [ "" != "${ISGNOME}" -a "" != "${ZENITY}" -a "" != "${DISPLAY}" ]; then
  43. echo "Dialog on Display: ${DISPLAY}"
  44. ${ZENITY} --info --title "DMDirc: ${1}" --text "${2}"
  45. elif [ "" != "${DIALOG}" ]; then
  46. ${DIALOG} --title "DMDirc: ${1}" --msgbox "${2}" 8 40
  47. fi
  48. }
  49. questiondialog() {
  50. # Send question to console.
  51. echo ""
  52. echo "-----------------------------------------------------------------------"
  53. echo "DMDirc: ${1}"
  54. echo "-----------------------------------------------------------------------"
  55. echo "${2}"
  56. echo "-----------------------------------------------------------------------"
  57. if [ "" != "${ISKDE}" -a "" != "${KDIALOG}" -a "" != "${DISPLAY}" ]; then
  58. echo "Dialog on Display: ${DISPLAY}"
  59. ${KDIALOG} --title "DMDirc: ${1}" --yesno "${2}"
  60. elif [ "" != "${ISGNOME}" -a "" != "${ZENITY}" -a "" != "${DISPLAY}" ]; then
  61. echo "Dialog on Display: ${DISPLAY}"
  62. ${ZENITY} --question --title "DMDirc: ${1}" --text "${2}"
  63. elif [ "" != "${DIALOG}" ]; then
  64. ${DIALOG} --title "DMDirc: ${1}" --yesno "${2}" 8 40
  65. else
  66. echo "Unable to show Dialog for question, assuming no"
  67. return 1
  68. fi
  69. }
  70. errordialog() {
  71. # Send error to console.
  72. echo ""
  73. echo "-----------------------------------------------------------------------"
  74. echo "[Error] DMDirc: ${1}"
  75. echo "-----------------------------------------------------------------------"
  76. echo "${2}"
  77. echo "-----------------------------------------------------------------------"
  78. if [ "" != "${ISKDE}" -a "" != "${KDIALOG}" -a "" != "${DISPLAY}" ]; then
  79. echo "Dialog on Display: ${DISPLAY}"
  80. ${KDIALOG} --title "DMDirc: ${1}" --error "${2}"
  81. elif [ "" != "${ISGNOME}" -a "" != "${ZENITY}" -a "" != "${DISPLAY}" ]; then
  82. echo "Dialog on Display: ${DISPLAY}"
  83. ${ZENITY} --error --title "DMDirc: ${1}" --text "${2}"
  84. elif [ "" != "${DIALOG}" ]; then
  85. ${DIALOG} --title "[Error] DMDirc: ${1}" --msgbox "${2}" 8 40
  86. fi
  87. }
  88. if [ ${INSTALLED_AS_ROOT} -eq 1 ]; then
  89. USER=`whoami`
  90. if [ "${USER}" != "root" ]; then
  91. errordialog "Uninstaller" "Uninstall Aborted. Only root can use this script"
  92. exit 1;
  93. fi
  94. fi
  95. questiondialog "Uninstaller" "Are you sure you want to uninstall DMDirc?"
  96. if [ $? -ne 0 ]; then
  97. messagedialog "Uninstaller" "Uninstall Aborted."
  98. echo "Uninstall Aborted"
  99. exit 1;
  100. fi
  101. ${JAVA} -jar ${INSTALL_LOCATION}/DMDirc.jar -k
  102. if [ $? -eq 0 ]; then
  103. errordialog "Uninstaller" "Uninstall Aborted - DMDirc is still running. Please close DMDirc before continuing"
  104. echo "Uninstall Aborted - DMDirc already running."
  105. exit 1;
  106. fi
  107. echo "Uninstalling DMDirc"
  108. echo "Removing Shortcuts.."
  109. TOOL=`which gconftool-2`
  110. COMMAND=""
  111. FILENAME=""
  112. if [ ${INSTALLED_AS_ROOT} -eq 1 ]; then
  113. COMMAND="${TOOL} --config-source=`${TOOL} --get-default-source`"
  114. FILENAME="/usr/share/services/irc.protocol"
  115. rm -Rfv /usr/share/applications/DMDirc.desktop
  116. else
  117. COMMAND="${TOOL}"
  118. FILENAME="${HOME}/.kde/share/services/irc.protocol"
  119. rm -Rfv ${HOME}/.local/share/applications/DMDirc.desktop
  120. rm -Rfv ${HOME}/Desktop/DMDirc.desktop
  121. fi;
  122. if [ "${TOOL}" != "" ]; then
  123. CURRENT=`${COMMAND} --get /desktop/gnome/url-handlers/irc/command`
  124. if [ "${CURRENT}" = "\"${INSTALL_LOCATION}/DMDirc.sh\" -e -c %s" ]; then
  125. echo "Removing Gnome Protocol Handler"
  126. ${COMMAND} --unset /desktop/gnome/url-handlers/irc/enabled
  127. ${COMMAND} --unset /desktop/gnome/url-handlers/irc/command
  128. else
  129. echo "Not Removing Gnome Protocol Handler"
  130. fi
  131. fi
  132. if [ -e "${FILENAME}" ]; then
  133. CURRENT=`grep DMDirc ${FILENAME}`
  134. if [ "" != "${CURRENT}" ]; then
  135. echo "Removing KDE Protocol Handler"
  136. rm -Rfv ${FILENAME}
  137. else
  138. echo "Not Removing KDE Protocol Handler"
  139. fi
  140. fi
  141. echo "Removing Installation Directory"
  142. rm -Rfv ${INSTALL_LOCATION}
  143. PROFILEDIR="${HOME}/.DMDirc"
  144. if [ -e ${PROFILEDIR}/dmdirc.config ]; then
  145. questiondialog "Uninstaller" "A DMDirc profile has been detected (${PROFILEDIR}) Do you want to delete it aswell?"
  146. if [ $? -eq 0 ]; then
  147. rm -Rfv "${PROFILEDIR}"
  148. fi
  149. fi
  150. messagedialog "Uninstaller" "DMDirc Uninstalled Successfully"
  151. echo "Done."
  152. exit 0;