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.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. #!/bin/sh
  2. #
  3. # This script launches the dmdirc java-based installer.
  4. #
  5. # DMDirc - Open Source IRC Client
  6. # Copyright (c) 2006-2008 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. ISKDE=`pidof -x -s kdeinit`
  26. KDIALOG=`which kdialog`
  27. ISGNOME=`pidof -x -s gnome-panel`
  28. ZENITY=`which zenity`
  29. errordialog() {
  30. # Send message to console.
  31. echo ""
  32. echo "-----------------------------------------------------------------------"
  33. echo "Error: ${1}"
  34. echo "-----------------------------------------------------------------------"
  35. echo "${2}"
  36. echo "-----------------------------------------------------------------------"
  37. # Now try to use the GUI Dialogs.
  38. if [ "" != "${ISKDE}" -a "" != "${KDIALOG}" -a "" != "${DISPLAY}" ]; then
  39. echo "Dialog on Display: ${DISPLAY}"
  40. ${KDIALOG} --title "DMDirc: ${1}" --error "${2}"
  41. elif [ "" != "${ISGNOME}" -a "" != "${ZENITY}" -a "" != "${DISPLAY}" ]; then
  42. echo "Dialog on Display: ${DISPLAY}"
  43. ${ZENITY} --error --title "DMDirc: ${1}" --text "${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. installjre() {
  53. result=1
  54. if [ ! -e "jre.bin" ]; then
  55. message="Would you like to download and install java?"
  56. if [ "install" != "${1}" ]; then
  57. message="Java was not detected on your machine. Would you like to download and install it now?"
  58. elif [ "upgrade" != "${1}" ]; then
  59. message="The version of java detected on your machine is not compatible with DMDirc. Would you like to download and install a compatible version now?"
  60. fi;
  61. /bin/sh getjre.sh "${message}"
  62. if [ $? -eq 0 ]; then
  63. /bin/sh installjre.sh
  64. result=$?
  65. fi;
  66. else
  67. message="Would you like to install java?"
  68. if [ "install" != "${1}" ]; then
  69. message="Java was not detected on your machine. Would you like to install it now?"
  70. elif [ "upgrade" != "${1}" ]; then
  71. message="The version of java detected on your machine is not compatible with DMDirc. Would you like to install a compatible version now?"
  72. fi;
  73. /bin/sh installjre.sh "${message}"
  74. result=$?
  75. fi;
  76. if [ ${result} -ne 0 ]; then
  77. if [ "upgrade" != "${1}" ]; then
  78. errordialog "DMDirc Setup" "Sorry, DMDirc setup can not continue without an updated version of java."
  79. else
  80. errordialog "DMDirc Setup" "Sorry, DMDirc setup can not continue without java."
  81. fi;
  82. exit 1;
  83. else
  84. if [ -e ".jrepath" ]; then
  85. . .jrepath
  86. JAVA=`which java`
  87. fi;
  88. fi;
  89. }
  90. if [ "" != "${JAVA}" ]; then
  91. echo "Success!"
  92. else
  93. echo "Failed!"
  94. installjre "install"
  95. fi
  96. echo "Success!"
  97. if [ "${UID}" = "" ]; then
  98. UID=`id -u`;
  99. fi
  100. if [ "0" = "${UID}" ]; then
  101. echo "Running as root.."
  102. isRoot="--isroot";
  103. else
  104. echo "Running as user.."
  105. isRoot="";
  106. fi
  107. showHelp() {
  108. echo "This will setup DMDirc on a unix based system."
  109. echo "The following command line arguments are known:"
  110. echo "---------------------"
  111. echo "-h, --help Help information"
  112. echo "-r, --release [version] This is a release"
  113. echo "-s, --script Don't use installer.jar (not implemented yet)"
  114. echo "---------------------"
  115. exit 0;
  116. }
  117. # Check for some CLI params
  118. scriptOnly="false"
  119. isRelease=""
  120. while test -n "$1"; do
  121. case "$1" in
  122. --script|-s)
  123. scriptOnly="true"
  124. shift
  125. ;;
  126. --release|-r)
  127. shift
  128. isRelease=${1}
  129. shift
  130. ;;
  131. --help|-h)
  132. showHelp;
  133. ;;
  134. esac
  135. done
  136. if [ "${isRelease}" != "" ]; then
  137. isRelease=" --release "${isRelease}
  138. fi
  139. if [ -e "installer.jar" ]; then
  140. if [ "${scriptOnly}" = "true" ]; then
  141. echo "Script-only install requested."
  142. else
  143. echo "Running installer.."
  144. ${JAVA} -cp DMDirc.jar -jar installer.jar ${isRoot}${isRelease}
  145. if [ $? -ne 0 ]; then
  146. installjre "upgrade"
  147. echo "Trying to run installer again.."
  148. ${JAVA} -cp DMDirc.jar -jar installer.jar ${isRoot}${isRelease}
  149. if [ $? -ne 0 ]; then
  150. exit 1;
  151. fi;
  152. fi
  153. exit 0;
  154. fi
  155. else
  156. echo "No installer found!"
  157. fi
  158. ## Script-Only install goes here.
  159. echo "Script-Only functionality not implemented."
  160. exit 1;