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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  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. PIDOF=`which pidof`
  26. if [ "" != "${PIDOF}" ]; then
  27. ISKDE=`${PIDOF} -x -s kdeinit`
  28. KDIALOG=`which kdialog`
  29. ISGNOME=`${PIDOF} -x -s gnome-panel`
  30. ZENITY=`which zenity`
  31. else
  32. ISKDE=""
  33. KDIALOG=""
  34. ISGNOME=""
  35. ZENITY=""
  36. fi;
  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. if [ "" != "${ISKDE}" -a "" != "${KDIALOG}" -a "" != "${DISPLAY}" ]; then
  47. echo "Dialog on Display: ${DISPLAY}"
  48. ${KDIALOG} --title "DMDirc: ${1}" --error "${2}"
  49. elif [ "" != "${ISGNOME}" -a "" != "${ZENITY}" -a "" != "${DISPLAY}" ]; then
  50. echo "Dialog on Display: ${DISPLAY}"
  51. ${ZENITY} --error --title "DMDirc: ${1}" --text "${2}"
  52. fi
  53. }
  54. UNAME=`uname -a`
  55. isLinux=`echo ${UNAME} | grep -i linux`
  56. echo ""
  57. echo "---------------------"
  58. echo "Setup.sh"
  59. echo "---------------------"
  60. echo -n "Looking for java.. ";
  61. # Location where ports on FreeBSD/PCBSD installs java6
  62. # check it first, because it isn't added to the path automatically
  63. JAVA="/usr/local/jdk1.6.0/jre/bin/java"
  64. if [ ! -e "${JAVA}" ]; then
  65. JAVA=`which java`
  66. fi
  67. installjre() {
  68. result=1
  69. if [ ! -e "jre.bin" ]; then
  70. message="Would you like to download and install java?"
  71. if [ "install" != "${1}" ]; then
  72. message="Java was not detected on your machine. Would you like to download and install it now?"
  73. elif [ "upgrade" != "${1}" ]; then
  74. 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?"
  75. fi;
  76. /bin/sh getjre.sh "${message}"
  77. if [ $? -eq 0 ]; then
  78. /bin/sh installjre.sh
  79. result=$?
  80. fi;
  81. else
  82. message="Would you like to install java?"
  83. if [ "install" != "${1}" ]; then
  84. message="Java was not detected on your machine. Would you like to install it now?"
  85. elif [ "upgrade" != "${1}" ]; then
  86. message="The version of java detected on your machine is not compatible with DMDirc. Would you like to install a compatible version now?"
  87. fi;
  88. /bin/sh installjre.sh "${message}"
  89. result=$?
  90. fi;
  91. if [ ${result} -ne 0 ]; then
  92. if [ "upgrade" != "${1}" ]; then
  93. errordialog "DMDirc Setup" "Sorry, DMDirc setup can not continue without an updated version of java."
  94. else
  95. errordialog "DMDirc Setup" "Sorry, DMDirc setup can not continue without java."
  96. fi;
  97. exit 1;
  98. else
  99. if [ -e ".jrepath" ]; then
  100. . .jrepath
  101. JAVA=`which java`
  102. fi;
  103. fi;
  104. }
  105. if [ "" != "${JAVA}" ]; then
  106. echo "Success!"
  107. else
  108. echo "Failed!"
  109. if [ "" == "${isLinux}" ]; then
  110. errordialog "DMDirc Setup" "Sorry, DMDirc setup can not continue without java 6."
  111. exit 1
  112. fi;
  113. installjre "install"
  114. fi
  115. echo "Success!"
  116. if [ "${UID}" = "" ]; then
  117. UID=`id -u`;
  118. fi
  119. if [ "0" = "${UID}" ]; then
  120. echo "Running as root.."
  121. isRoot="--isroot";
  122. else
  123. echo "Running as user.."
  124. isRoot="";
  125. fi
  126. showHelp() {
  127. echo "This will setup DMDirc on a unix based system."
  128. echo "The following command line arguments are known:"
  129. echo "---------------------"
  130. echo "-h, --help Help information"
  131. echo "-r, --release [version] This is a release"
  132. # echo "-s, --script Don't use installer.jar (not implemented yet)"
  133. echo "---------------------"
  134. exit 0;
  135. }
  136. # Check for some CLI params
  137. scriptOnly="false"
  138. isRelease=""
  139. while test -n "$1"; do
  140. case "$1" in
  141. --script|-s)
  142. scriptOnly="true"
  143. shift
  144. ;;
  145. --release|-r)
  146. shift
  147. isRelease=${1}
  148. shift
  149. ;;
  150. --help|-h)
  151. showHelp;
  152. ;;
  153. esac
  154. done
  155. if [ "${isRelease}" != "" ]; then
  156. isRelease=" --release "${isRelease}
  157. fi
  158. if [ -e "DMDirc.jar" ]; then
  159. if [ "${scriptOnly}" = "true" ]; then
  160. echo "Script-only install requested."
  161. else
  162. echo "Running installer.."
  163. ${JAVA} -cp DMDirc.jar com.dmdirc.installer.Main ${isRoot}${isRelease}
  164. if [ $? -ne 0 ]; then
  165. if [ "" == "${isLinux}" ]; then
  166. errordialog "DMDirc Setup" "Sorry, DMDirc setup can not continue without java 6."
  167. exit 1
  168. fi;
  169. installjre "upgrade"
  170. echo "Trying to run installer again.."
  171. ${JAVA} -cp DMDirc.jar com.dmdirc.installer.Main ${isRoot}${isRelease}
  172. if [ $? -ne 0 ]; then
  173. exit 1;
  174. fi;
  175. fi
  176. exit 0;
  177. fi
  178. else
  179. echo "No installer found!"
  180. fi
  181. ## Script-Only install goes here.
  182. echo "Script-Only functionality not implemented."
  183. exit 1;