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.

setup.sh 4.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. #!/bin/sh
  2. #
  3. # This script launches the dmdirc java-based installer.
  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. errordialog() {
  26. # Send message to console.
  27. echo ""
  28. echo "-----------------------------------------------------------------------"
  29. echo "Error: ${1}"
  30. echo "-----------------------------------------------------------------------"
  31. echo "${2}"
  32. echo "-----------------------------------------------------------------------"
  33. # Now try to use the GUI Dialogs.
  34. ISKDE=`pidof -x -s kdeinit`
  35. KDIALOG=`which kdialog`
  36. ISGNOME=`pidof -x -s gnome-panel`
  37. ZENITY=`which zenity`
  38. if [ "" != "${ISKDE}" -a "" != "${KDIALOG}" -a "" != "${DISPLAY}" ]; then
  39. echo "Dialog on Display: ${DISPLAY}"
  40. ${KDIALOG} --title "DMDirc: ${1}" --error "${1}\n\n${2}"
  41. elif [ "" != "${ISGNOME}" -a "" != "${ZENITY}" -a "" != "${DISPLAY}" ]; then
  42. echo "Dialog on Display: ${DISPLAY}"
  43. ${ZENITY} --error --title "DMDirc: ${1}" --text "${1}\n\n${2}"
  44. fi
  45. }
  46. echo ""
  47. echo "---------------------"
  48. echo "Setup.sh"
  49. echo "---------------------"
  50. echo -n "Looking for java.. ";
  51. JAVA=`which java`
  52. if [ "" != "${JAVA}" ]; then
  53. echo "Success!"
  54. else
  55. echo "Failed!"
  56. # This should in future offer to download and install the JVM automatically.
  57. ERROR="Sorry, java is not installed on this machine.";
  58. ERROR=${ERROR}"\n"
  59. ERROR=${ERROR}"\nDMDirc requires a 1.6.0 compatible JVM, you can get one from:";
  60. ERROR=${ERROR}"\nhttp://jdl.sun.com/webapps/getjava/BrowserRedirect";
  61. errordialog "Unable to complete setup!" "${ERROR}";
  62. exit 1;
  63. fi
  64. echo "Success!"
  65. if [ "${UID}" = "" ]; then
  66. UID=`id -u`;
  67. fi
  68. if [ "0" = "${UID}" ]; then
  69. echo "Running as root.."
  70. isRoot="--isroot";
  71. else
  72. echo "Running as user.."
  73. isRoot="";
  74. fi
  75. showHelp() {
  76. echo "This will setup DMDirc on a unix based system."
  77. echo "The following command line arguments are known:"
  78. echo "---------------------"
  79. echo "-h, --help Help information"
  80. echo "-r, --release [version] This is a release"
  81. echo "-s, --script Don't use installer.jar (not implemented yet)"
  82. echo "---------------------"
  83. exit 0;
  84. }
  85. # Check for some CLI params
  86. scriptOnly="false"
  87. isRelease=""
  88. while test -n "$1"; do
  89. case "$1" in
  90. --script|-s)
  91. scriptOnly="true"
  92. shift
  93. ;;
  94. --release|-r)
  95. shift
  96. isRelease=${1}
  97. shift
  98. ;;
  99. --help|-h)
  100. showHelp;
  101. ;;
  102. esac
  103. done
  104. if [ "${isRelease}" != "" ]; then
  105. isRelease=" --release "${isRelease}
  106. fi
  107. if [ -e "installer.jar" ]; then
  108. if [ "${scriptOnly}" = "true" ]; then
  109. echo "Script-only install requested."
  110. else
  111. echo "Running installer.."
  112. ${JAVA} -cp DMDirc.jar -jar installer.jar ${isRoot}${isRelease}
  113. if [ $? -ne 0 ]; then
  114. ERROR="Sorry, the currently installed version of java is not compatible with";
  115. ERROR=${ERROR}"\nDMDirc.";
  116. ERROR=${ERROR}"\n";
  117. ERROR=${ERROR}"\nDMDirc requires a 1.6.0 compatible JVM, you can get one from:";
  118. ERROR=${ERROR}"\nhttp://jdl.sun.com/webapps/getjava/BrowserRedirect";
  119. errordialog "Unable to complete setup!" "${ERROR}";
  120. exit 1;
  121. fi
  122. exit 0;
  123. fi
  124. else
  125. echo "No installer found!"
  126. fi
  127. ## Script-Only install goes here.
  128. echo "Script-Only functionality not implemented."
  129. exit 1;