123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203 |
- #!/bin/sh
- #
- # Install the JRE.
- #
-
- ISKDE=`pidof -x -s kdeinit`
- KDIALOG=`which kdialog`
- ISGNOME=`pidof -x -s gnome-panel`
- ZENITY=`which zenity`
-
- errordialog() {
- # Send message to console.
- echo ""
- echo "-----------------------------------------------------------------------"
- echo "Error: ${1}"
- echo "-----------------------------------------------------------------------"
- echo "${2}"
- echo "-----------------------------------------------------------------------"
-
- # Now try to use the GUI Dialogs.
- if [ "" != "${ISKDE}" -a "" != "${KDIALOG}" -a "" != "${DISPLAY}" ]; then
- echo "Dialog on Display: ${DISPLAY}"
- ${KDIALOG} --title "DMDirc: ${1}" --error "${2}"
- elif [ "" != "${ISGNOME}" -a "" != "${ZENITY}" -a "" != "${DISPLAY}" ]; then
- echo "Dialog on Display: ${DISPLAY}"
- ${ZENITY} --error --title "DMDirc: ${1}" --text "${2}"
- fi
- }
-
- messagedialog() {
- # Send message to console.
- echo ""
- echo "-----------------------------------------------------------------------"
- echo "Info: ${1}"
- echo "-----------------------------------------------------------------------"
- echo "${2}"
- echo "-----------------------------------------------------------------------"
-
- # Now try to use the GUI Dialogs.
- if [ "" != "${ISKDE}" -a "" != "${KDIALOG}" -a "" != "${DISPLAY}" ]; then
- echo "Dialog on Display: ${DISPLAY}"
- ${KDIALOG} --title "DMDirc: ${1}" --msgbox "${2}"
- elif [ "" != "${ISGNOME}" -a "" != "${ZENITY}" -a "" != "${DISPLAY}" ]; then
- echo "Dialog on Display: ${DISPLAY}"
- ${ZENITY} --info --title "DMDirc: ${1}" --text "${2}"
- fi
- }
-
- questiondialog() {
- # Send question to console.
- echo ""
- echo "-----------------------------------------------------------------------"
- echo "Question: ${1}"
- echo "-----------------------------------------------------------------------"
- echo "${2}"
- echo "-----------------------------------------------------------------------"
-
- # Now try to use the GUI Dialogs.
- if [ "" != "${ISKDE}" -a "" != "${KDIALOG}" -a "" != "${DISPLAY}" ]; then
- echo "Dialog on Display: ${DISPLAY}"
- ${KDIALOG} --title "DMDirc: ${1}" --yesno "${2}"
- elif [ "" != "${ISGNOME}" -a "" != "${ZENITY}" -a "" != "${DISPLAY}" ]; then
- echo "Dialog on Display: ${DISPLAY}"
- ${ZENITY} --question --title "DMDirc: ${1}" --text "${2}"
- else
- echo "Unable to ask question, assuming no."
- return 1;
- fi
- }
-
- showLicense() {
- # Get License Text
- FILE=`mktemp -p ${PWD} license.XXXXXXXXXXXXXX`
-
- # Location of license start
- STARTLINE=`grep -na "^more <<\"EOF\"$" jre.bin`
- STARTLINE=$((${STARTLINE%%:*} + 1))
- # Location of license end
- ENDLINE=`grep -na "Do you agree to the above license terms?" jre.bin`
- ENDLINE=$((${ENDLINE%%:*} - 2))
-
- head -n ${ENDLINE} jre.bin | tail -n +${STARTLINE} > ${FILE}
-
- # Send text to console.
- echo ""
- echo "-----------------------------------------------------------------------"
- echo "Java License"
- echo "-----------------------------------------------------------------------"
- cat ${FILE}
- echo "-----------------------------------------------------------------------"
-
- # Now try to use the GUI Dialogs.
- if [ "" != "${ISKDE}" -a "" != "${KDIALOG}" -a "" != "${DISPLAY}" ]; then
- echo "Dialog on Display: ${DISPLAY}"
- ${KDIALOG} --title "DMDirc: Java License" --textbox ${FILE} 600 400
- elif [ "" != "${ISGNOME}" -a "" != "${ZENITY}" -a "" != "${DISPLAY}" ]; then
- echo "Dialog on Display: ${DISPLAY}"
- ${ZENITY} --text-info --title "DMDirc: Java License" --filename=${FILE} --width=600 --height=400
- fi
-
- # Remove temp file
- rm -Rf ${FILE}
- }
-
-
- if [ "" != "${1}" ]; then
- questiondialog "Java Install" "${1}"
- result=$?
- if [ $result -ne 0 ]; then
- exit 1;
- fi;
- fi;
-
- messagedialog "Java Install" "Before java can be installed, please review the following license."
- showLicense
- questiondialog "Java Install" "Do you agree to the Java License?"
- if [ $? -eq 0 ]; then
- # Look to see where the JRE wants to install to
- JREJAVAHOME=`grep -na "^javahome=" jre.bin`
- JREJAVAHOME=${JREJAVAHOME##*=}
-
- if [ "${UID}" = "" ]; then
- UID=`id -u`;
- fi
- if [ "0" = "${UID}" ]; then
- installdir=/usr/lib/jvm/${JREJAVAHOME}
- else
- installdir=${HOME}/${JREJAVAHOME}
- fi;
-
- if [ -e ${installdir} ]; then
- # Hack jre.bin to allow us to install without asking for a license, or failing
- # the checksum.
-
- # Location of license start
- STARTLINE=`grep -na "^more <<\"EOF\"$" jre.bin`
- STARTLINE=${STARTLINE%%:*}
- # Location of license end
- ENDLINE=`grep -na "If you don't agree to the license you can't install this software" jre.bin`
- ENDLINE=$((${ENDLINE%%:*} + 3))
- # Location of checksum start
- CSSTARTLINE=`grep -na "^if \[ -x /usr/bin/sum \]; then$" jre.bin`
- CSSTARTLINE=${CSSTARTLINE%%:*}
- # Location of checksum end
- CSENDLINE=`grep -na "Can't find /usr/bin/sum to do checksum" jre.bin`
- CSENDLINE=$((${CSENDLINE%%:*} + 2))
- # Location of script end
- SCENDLINE=`grep -na "^echo \"Done.\"$" jre.bin`
- SCENDLINE=$((${SCENDLINE%%:*} + 2 - (${ENDLINE} - ${STARTLINE}) - (${CSENDLINE} - ${CSSTARTLINE})))
- # Remove the license and checksum stuff!
- head -n $((${STARTLINE} -1)) jre.bin > jre.bin.tmp
- tail -n +$((${ENDLINE})) jre.bin | head -n $((${CSSTARTLINE} -1 - ${ENDLINE})) >> jre.bin.tmp
- echo "tail \${tail_args} +${SCENDLINE} \"\$0\" > \$outname" >> jre.bin.tmp
- tail -n +$((${CSENDLINE})) jre.bin >> jre.bin.tmp
-
- 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."
- yes | sh jre.bin.tmp
- rm -Rf jre.bin.tmp
- mv ${JREJAVAHOME} ${installdir}
-
- if [ "0" = "${UID}" ]; then
- mkdir -p /usr/lib/jvm/
-
- # Add to global path.
- if [ -e "/usr/bin/java" ]; then
- rm -Rf /usr/bin/java
- fi;
- ln -s /usr/lib/jvm/${JREJAVAHOME}/bin/java /usr/bin/java
- else
- # Add to path.
- if [ -e ${HOME}/.profile ]; then
- echo "" >> ${HOME}/.profile
- echo "# set PATH so it includes user's private java if it exists" >> ${HOME}/.profile
- echo "if [ -d ~/${JREJAVAHOME}/bin ] ; then" >> ${HOME}/.profile
- echo " PATH=~/${JREJAVAHOME}/bin:\"\${PATH}\"" >> ${HOME}/.profile
- echo "fi" >> ${HOME}/.profile
- fi
- if [ -e ${HOME}/.cshrc ]; then
- echo "" >> ${HOME}/.cshrc
- echo "# set PATH so it includes user's private java if it exists" >> ${HOME}/.cshrc
- echo "if( -d ~/${JREJAVAHOME}/bin ) then" >> ${HOME}/.cshrc
- echo " set path = (~/${JREJAVAHOME}/bin \$path)" >> ${HOME}/.cshrc
- echo "endfi" >> ${HOME}/.cshrc
- fi
-
- # This allows the main installer to continue with the new java version.
- echo "export PATH=~/${JREJAVAHOME}/bin:\"\${PATH}\"" > .jrepath
-
- # This allows dmdirc launcher to find the jre if the path is not set.
- ln -sf ${installdir} ${HOME}/jre
- fi;
-
- messagedialog "Java Install" "Java installation complete"
- exit 0;
- else
- messagedialog "Java Install" "An existing install was found at ${installdir}, but this directory is not in the current path."
- echo "export PATH=~/${JREJAVAHOME}/bin:\"\${PATH}\"" > .jrepath
- exit 0;
- fi;
- else
- errordialog "Java Install" "You must agree to the license before java can be installed"
- fi;
- exit 1;
|