Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

installjre.sh 7.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. #!/bin/sh
  2. #
  3. # Install the JRE.
  4. #
  5. ISKDE=`pidof -x -s kdeinit`
  6. KDIALOG=`which kdialog`
  7. ISGNOME=`pidof -x -s gnome-panel`
  8. ZENITY=`which zenity`
  9. errordialog() {
  10. # Send message to console.
  11. echo ""
  12. echo "-----------------------------------------------------------------------"
  13. echo "Error: ${1}"
  14. echo "-----------------------------------------------------------------------"
  15. echo "${2}"
  16. echo "-----------------------------------------------------------------------"
  17. # Now try to use the GUI Dialogs.
  18. if [ "" != "${ISKDE}" -a "" != "${KDIALOG}" -a "" != "${DISPLAY}" ]; then
  19. echo "Dialog on Display: ${DISPLAY}"
  20. ${KDIALOG} --title "DMDirc: ${1}" --error "${2}"
  21. elif [ "" != "${ISGNOME}" -a "" != "${ZENITY}" -a "" != "${DISPLAY}" ]; then
  22. echo "Dialog on Display: ${DISPLAY}"
  23. ${ZENITY} --error --title "DMDirc: ${1}" --text "${2}"
  24. fi
  25. }
  26. messagedialog() {
  27. # Send message to console.
  28. echo ""
  29. echo "-----------------------------------------------------------------------"
  30. echo "Info: ${1}"
  31. echo "-----------------------------------------------------------------------"
  32. echo "${2}"
  33. echo "-----------------------------------------------------------------------"
  34. # Now try to use the GUI Dialogs.
  35. if [ "" != "${ISKDE}" -a "" != "${KDIALOG}" -a "" != "${DISPLAY}" ]; then
  36. echo "Dialog on Display: ${DISPLAY}"
  37. ${KDIALOG} --title "DMDirc: ${1}" --msgbox "${2}"
  38. elif [ "" != "${ISGNOME}" -a "" != "${ZENITY}" -a "" != "${DISPLAY}" ]; then
  39. echo "Dialog on Display: ${DISPLAY}"
  40. ${ZENITY} --info --title "DMDirc: ${1}" --text "${2}"
  41. fi
  42. }
  43. questiondialog() {
  44. # Send question to console.
  45. echo ""
  46. echo "-----------------------------------------------------------------------"
  47. echo "Question: ${1}"
  48. echo "-----------------------------------------------------------------------"
  49. echo "${2}"
  50. echo "-----------------------------------------------------------------------"
  51. # Now try to use the GUI Dialogs.
  52. if [ "" != "${ISKDE}" -a "" != "${KDIALOG}" -a "" != "${DISPLAY}" ]; then
  53. echo "Dialog on Display: ${DISPLAY}"
  54. ${KDIALOG} --title "DMDirc: ${1}" --yesno "${2}"
  55. elif [ "" != "${ISGNOME}" -a "" != "${ZENITY}" -a "" != "${DISPLAY}" ]; then
  56. echo "Dialog on Display: ${DISPLAY}"
  57. ${ZENITY} --question --title "DMDirc: ${1}" --text "${2}"
  58. else
  59. echo "Unable to ask question, assuming no."
  60. return 1;
  61. fi
  62. }
  63. showLicense() {
  64. # Get License Text
  65. FILE=`mktemp -p ${PWD} license.XXXXXXXXXXXXXX`
  66. # Location of license start
  67. STARTLINE=`grep -na "^more <<\"EOF\"$" jre.bin`
  68. STARTLINE=$((${STARTLINE%%:*} + 1))
  69. # Location of license end
  70. ENDLINE=`grep -na "Do you agree to the above license terms?" jre.bin`
  71. ENDLINE=$((${ENDLINE%%:*} - 2))
  72. head -n ${ENDLINE} jre.bin | tail -n +${STARTLINE} > ${FILE}
  73. # Send text to console.
  74. echo ""
  75. echo "-----------------------------------------------------------------------"
  76. echo "Java License"
  77. echo "-----------------------------------------------------------------------"
  78. cat ${FILE}
  79. echo "-----------------------------------------------------------------------"
  80. # Now try to use the GUI Dialogs.
  81. if [ "" != "${ISKDE}" -a "" != "${KDIALOG}" -a "" != "${DISPLAY}" ]; then
  82. echo "Dialog on Display: ${DISPLAY}"
  83. ${KDIALOG} --title "DMDirc: Java License" --textbox ${FILE} 600 400
  84. elif [ "" != "${ISGNOME}" -a "" != "${ZENITY}" -a "" != "${DISPLAY}" ]; then
  85. echo "Dialog on Display: ${DISPLAY}"
  86. ${ZENITY} --text-info --title "DMDirc: Java License" --filename=${FILE} --width=600 --height=400
  87. fi
  88. # Remove temp file
  89. rm -Rf ${FILE}
  90. }
  91. if [ "" != "${1}" ]; then
  92. questiondialog "Java Install" "${1}"
  93. result=$?
  94. if [ $result -ne 0 ]; then
  95. exit 1;
  96. fi;
  97. fi;
  98. messagedialog "Java Install" "Before java can be installed, please review the following license."
  99. showLicense
  100. questiondialog "Java Install" "Do you agree to the Java License?"
  101. if [ $? -eq 0 ]; then
  102. # Look to see where the JRE wants to install to
  103. JREJAVAHOME=`grep -na "^javahome=" jre.bin`
  104. JREJAVAHOME=${JREJAVAHOME##*=}
  105. if [ "${UID}" = "" ]; then
  106. UID=`id -u`;
  107. fi
  108. if [ "0" = "${UID}" ]; then
  109. installdir=/usr/lib/jvm/${JREJAVAHOME}
  110. else
  111. installdir=${HOME}/${JREJAVAHOME}
  112. fi;
  113. if [ -e ${installdir} ]; then
  114. # Hack jre.bin to allow us to install without asking for a license, or failing
  115. # the checksum.
  116. # Location of license start
  117. STARTLINE=`grep -na "^more <<\"EOF\"$" jre.bin`
  118. STARTLINE=${STARTLINE%%:*}
  119. # Location of license end
  120. ENDLINE=`grep -na "If you don't agree to the license you can't install this software" jre.bin`
  121. ENDLINE=$((${ENDLINE%%:*} + 3))
  122. # Location of checksum start
  123. CSSTARTLINE=`grep -na "^if \[ -x /usr/bin/sum \]; then$" jre.bin`
  124. CSSTARTLINE=${CSSTARTLINE%%:*}
  125. # Location of checksum end
  126. CSENDLINE=`grep -na "Can't find /usr/bin/sum to do checksum" jre.bin`
  127. CSENDLINE=$((${CSENDLINE%%:*} + 2))
  128. # Location of script end
  129. SCENDLINE=`grep -na "^echo \"Done.\"$" jre.bin`
  130. SCENDLINE=$((${SCENDLINE%%:*} + 2 - (${ENDLINE} - ${STARTLINE}) - (${CSENDLINE} - ${CSSTARTLINE})))
  131. # Remove the license and checksum stuff!
  132. head -n $((${STARTLINE} -1)) jre.bin > jre.bin.tmp
  133. tail -n +$((${ENDLINE})) jre.bin | head -n $((${CSSTARTLINE} -1 - ${ENDLINE})) >> jre.bin.tmp
  134. echo "tail \${tail_args} +${SCENDLINE} \"\$0\" > \$outname" >> jre.bin.tmp
  135. tail -n +$((${CSENDLINE})) jre.bin >> jre.bin.tmp
  136. messagedialog "Java Install" "Java install will begin when you press OK.\nThis may take some time, so please wait.\n\nYou will be informed when the installation is completed."
  137. yes | sh jre.bin.tmp
  138. rm -Rf jre.bin.tmp
  139. mv ${JREJAVAHOME} ${installdir}
  140. if [ "0" = "${UID}" ]; then
  141. mkdir -p /usr/lib/jvm/
  142. # Add to global path.
  143. if [ -e "/usr/bin/java" ]; then
  144. rm -Rf /usr/bin/java
  145. fi;
  146. ln -s /usr/lib/jvm/${JREJAVAHOME}/bin/java /usr/bin/java
  147. else
  148. # Add to path.
  149. if [ -e ${HOME}/.profile ]; then
  150. echo "" >> ${HOME}/.profile
  151. echo "# set PATH so it includes user's private java if it exists" >> ${HOME}/.profile
  152. echo "if [ -d ~/${JREJAVAHOME}/bin ] ; then" >> ${HOME}/.profile
  153. echo " PATH=~/${JREJAVAHOME}/bin:\"\${PATH}\"" >> ${HOME}/.profile
  154. echo "fi" >> ${HOME}/.profile
  155. fi
  156. if [ -e ${HOME}/.cshrc ]; then
  157. echo "" >> ${HOME}/.cshrc
  158. echo "# set PATH so it includes user's private java if it exists" >> ${HOME}/.cshrc
  159. echo "if( -d ~/${JREJAVAHOME}/bin ) then" >> ${HOME}/.cshrc
  160. echo " set path = (~/${JREJAVAHOME}/bin \$path)" >> ${HOME}/.cshrc
  161. echo "endfi" >> ${HOME}/.cshrc
  162. fi
  163. # This allows the main installer to continue with the new java version.
  164. echo "export PATH=~/${JREJAVAHOME}/bin:\"\${PATH}\"" > .jrepath
  165. # This allows dmdirc launcher to find the jre if the path is not set.
  166. ln -sf ${installdir} ${HOME}/jre
  167. fi;
  168. messagedialog "Java Install" "Java installation complete"
  169. exit 0;
  170. else
  171. messagedialog "Java Install" "An existing install was found at ${installdir}, but this directory is not in the current path."
  172. echo "export PATH=~/${JREJAVAHOME}/bin:\"\${PATH}\"" > .jrepath
  173. exit 0;
  174. fi;
  175. else
  176. errordialog "Java Install" "You must agree to the license before java can be installed"
  177. fi;
  178. exit 1;