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.

DMDirc.sh 4.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. #!/bin/sh
  2. #
  3. # This script launches dmdirc and attempts to update the jar file if needed.
  4. #
  5. # DMDirc - Open Source IRC Client
  6. # Copyright (c) 2006-2007 Chris Smith, Shane Mc Cormack, Gregory Holmes
  7. #
  8. # Permission is hereby granted, free of charge, to any person obtaining a copy
  9. # of this software and associated documentation files (the "Software"), to deal
  10. # in the Software without restriction, including without limitation the rights
  11. # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  12. # copies of the Software, and to permit persons to whom the Software is
  13. # furnished to do so, subject to the following conditions:
  14. #
  15. # The above copyright notice and this permission notice shall be included in
  16. # all copies or substantial portions of the Software.
  17. #
  18. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  19. # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  20. # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  21. # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  22. # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  23. # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  24. # SOFTWARE.
  25. params="${@}"
  26. # Check for some CLI params
  27. profiledir="${HOME}/.DMDirc/"
  28. while test -n "$1"; do
  29. case "$1" in
  30. --directory|-d)
  31. shift
  32. profiledir=${1}
  33. ;;
  34. esac
  35. shift
  36. done
  37. errordialog() {
  38. # Send message to console.
  39. echo ""
  40. echo "-----------------------------------------------------------------------"
  41. echo "Error: ${1}"
  42. echo "-----------------------------------------------------------------------"
  43. echo "${2}"
  44. echo "-----------------------------------------------------------------------"
  45. # Now try to use the GUI Dialogs.
  46. ISKDE=`pidof -x -s kdeinit`
  47. KDIALOG=`which kdialog`
  48. ISGNOME=`pidof -x -s gnome-panel`
  49. ZENITY=`which zenity`
  50. if [ "" != "${ISKDE}" -a "" != "${KDIALOG}" -a "" != "${DISPLAY}" ]; then
  51. echo "Dialog on Display: ${DISPLAY}"
  52. ${KDIALOG} --title "DMDirc: ${1}" --error "${1}\n\n${2}"
  53. elif [ "" != "${ISGNOME}" -a "" != "${ZENITY}" -a "" != "${DISPLAY}" ]; then
  54. echo "Dialog on Display: ${DISPLAY}"
  55. ${ZENITY} --error --title "DMDirc: ${1}" --text "${1}\n\n${2}"
  56. fi
  57. }
  58. jar=`dirname $0`/DMDirc.jar
  59. echo "---------------------"
  60. echo "DMDirc - Open Source IRC Client"
  61. echo "Copyright (c) 2006-2007 Chris Smith, Shane Mc Cormack, Gregory Holmes"
  62. echo "---------------------"
  63. echo -n "Checking for updates in ${profiledir} - ";
  64. if [ -e "${profiledir}/.DMDirc.jar" ]; then
  65. echo "Found!";
  66. echo "Attempting to update..";
  67. mv -Rfv ${profiledir}/.DMDirc.jar ${jar}
  68. if [ $? -eq 0 ]; then
  69. echo "Update successful."
  70. else
  71. echo "Update failed."
  72. fi
  73. else
  74. echo "Not found.";
  75. fi;
  76. echo -n "Looking for java - ";
  77. JAVA=`which java`
  78. if [ "" != "${JAVA}" ]; then
  79. echo "Success!"
  80. else
  81. echo "Failed!"
  82. # This should in future offer to download and install the JVM automatically.
  83. ERROR="Sorry, java is not installed on this machine.";
  84. ERROR=${ERROR}"\n"
  85. ERROR=${ERROR}"\nDMDirc requires a 1.6.0 compatible JVM, you can get one from:";
  86. ERROR=${ERROR}"\nhttp://jdl.sun.com/webapps/getjava/BrowserRedirect";
  87. errordialog "Unable to launch dmdirc!" "${ERROR}";
  88. exit 1;
  89. fi
  90. echo -n "Running DMDirc - "
  91. if [ -e "${jar}" ]; then
  92. # Check that DMDirc will run, if java is not 1.6 this will fail.
  93. # We do it this way otherwise segfaults etc would cause an unable to launch
  94. # error message to be printed.
  95. ${JAVA} -jar ${jar} --help >/dev/null 2>&1
  96. if [ $? -ne 0 ]; then
  97. echo "Failed."
  98. ERROR="Sorry, the currently installed version of java is not compatible with";
  99. ERROR=${ERROR}"\nDMDirc.";
  100. ERROR=${ERROR}"\n";
  101. ERROR=${ERROR}"\nDMDirc requires a 1.6.0 compatible JVM, you can get one from:";
  102. ERROR=${ERROR}"\nhttp://jdl.sun.com/webapps/getjava/BrowserRedirect";
  103. errordialog "Unable to launch dmdirc!" "${ERROR}";
  104. exit 1;
  105. fi
  106. # Now we can run the client for real, this allows stderr/stdout output
  107. # to be seen, and the shell script exits with the correct exit code.
  108. ${JAVA} -jar ${jar} ${params}
  109. exit $?;
  110. else
  111. echo "Failed.";
  112. errordialog "Unable to launch dmdirc!" "No jar file found";
  113. fi