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.8KB

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