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.

DMDirc.sh 18KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528
  1. #!/bin/sh
  2. #
  3. # This script launches dmdirc and attempts to update the jar file if needed.
  4. #
  5. # DMDirc - Open Source IRC Client
  6. # Copyright (c) 2006-2010 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. LAUNCHERVERSION="17"
  26. LAUNCHERINFO="unix-${LAUNCHERVERSION}"
  27. params=""
  28. # Check the which command exists, and if so make sure it behaves how we want
  29. # it to...
  30. WHICH=`which which 2>/dev/null`
  31. if [ "" = "${WHICH}" ]; then
  32. echo "which command not found. Aborting.";
  33. exit 0;
  34. else
  35. # Solaris sucks
  36. BADWHICH=`which /`
  37. if [ "${BADWHICH}" != "" ]; then
  38. echo "Replacing bad which command.";
  39. # "Which" on solaris gives non-empty results for commands that don't exist
  40. which() {
  41. OUT=`${WHICH} ${1}`
  42. if [ $? -eq 0 ]; then
  43. echo ${OUT}
  44. else
  45. echo ""
  46. fi;
  47. }
  48. fi;
  49. fi
  50. # Find out where we are
  51. BASEDIR=${0%/*}
  52. if [ "${BASEDIR}" = "${0}" ]; then
  53. BASEDIR=`which $0`
  54. BASEDIR=${BASEDIR%/*}
  55. fi
  56. CHECKBASEDIR=`echo "${BASEDIR}" | sed 's#^/##'`
  57. if [ "${CHECKBASEDIR}" = "${BASEDIR}" ]; then
  58. BASEDIR=${PWD}/${BASEDIR}
  59. fi;
  60. # Store params so that we can pass them back to the client
  61. for param in "$@"; do
  62. if [ "${param}" = "--noprofile" -o "${param}" = "--updateonly" ]; then
  63. continue;
  64. fi;
  65. PSN=`echo "${param}" | grep "^-psn_"`
  66. if [ "" = "${PSN}" ]; then
  67. SPACE=`echo "${param}" | grep " "`
  68. if [ "${SPACE}" != "" ]; then
  69. niceParam=`echo "${param}" | sed 's/"/\\\\"/g'`
  70. params=${params}" \"${niceParam}\""
  71. else
  72. params=${params}" ${param}"
  73. fi;
  74. fi;
  75. done;
  76. if [ -e "${BASEDIR}/functions.sh" ]; then
  77. . ${BASEDIR}/functions.sh
  78. else
  79. echo "Unable to find functions.sh, using built in functions"
  80. ###FUNCTIONS_FILE###
  81. fi;
  82. # Check to see if we can bspatch things
  83. BSPATCH="./bspatch"
  84. if [ ! -e "${BSPATCH}" ]; then
  85. BSPATCH=`which bspatch`
  86. fi;
  87. # This launcher supports zip files.
  88. LAUNCHERINFO=${LAUNCHERINFO}",zip"
  89. if [ "${BSPATCH}" != "" ]; then
  90. # TODO: Website should (if available) send bsdiff patches
  91. # to clients with bsdiff compatible launchers
  92. LAUNCHERINFO=${LAUNCHERINFO}",bsdiff";
  93. fi;
  94. # Check for some CLI params
  95. if [ "${ISOSX}" = "1" ]; then
  96. profiledir="${HOME}/Library/Preferences/DMDirc/"
  97. else
  98. profiledir="${HOME}/.DMDirc/"
  99. if [ ! -d "${profiledir}" ]; then
  100. profiledir="${XDG_CONFIG_HOME}"
  101. if [ "${profiledir}" = "" ]; then
  102. profiledir="${HOME}/.config"
  103. fi;
  104. profiledir="${profiledir}/DMDirc/"
  105. fi;
  106. fi;
  107. USEPROFILE=1;
  108. UPDATEONLY=0;
  109. while test -n "$1"; do
  110. case "$1" in
  111. --directory|-d)
  112. shift
  113. profiledir=${1}
  114. ;;
  115. --noprofile)
  116. USEPROFILE=0;
  117. ;;
  118. --updateonly)
  119. UPDATEONLY=1;
  120. ;;
  121. -p|--portable)
  122. profiledir=${PWD};
  123. ;;
  124. esac
  125. shift
  126. done
  127. getConfigOption() {
  128. FILE="${profiledir}/dmdirc.config"
  129. WANTED_DOMAIN="${1}"
  130. WANTED_KEY="${2}"
  131. CURRENT_SECTION=""
  132. if [ "${WANTED_KEY}" != "" -a "${WANTED_DOMAIN}" = "" ]; then
  133. if [ -e "${FILE}" ]; then
  134. cat ${FILE} | sed 's/\\/\\\\/g' | while IFS='' read -r LINE; do
  135. IS_SECTION=`echo ${LINE} | egrep "^.*:$"`
  136. IS_KEYVALUE=`echo ${LINE} | egrep "^[[:space:]]+.*=.*$"`
  137. if [ "" != "${IS_SECTION}" ]; then
  138. CURRENT_SECTION=${LINE%%:*}
  139. elif [ "" != "${IS_KEYVALUE}" ]; then
  140. KEY=`echo ${LINE%%=*} | sed 's/^\s*//g'`
  141. VALUE=${LINE##*=}
  142. if [ "${WANTED_DOMAIN}" = "${CURRENT_SECTION}" -a "${WANTED_KEY}" = "${KEY}" ]; then
  143. echo ${VALUE};
  144. fi;
  145. fi;
  146. done;
  147. fi;
  148. fi;
  149. }
  150. if [ "${ISOSX}" = "1" ]; then
  151. jarDir=${BASEDIR}/../Resources/Java/
  152. jar=${jarDir}DMDirc.jar
  153. else
  154. jar=${BASEDIR}/DMDirc.jar
  155. fi
  156. launcherUpdater=${profiledir}/updateLauncher.sh
  157. BSDJava1="/usr/local/jdk1.6.0/jre/bin/java"
  158. BSDJava2="/usr/local/diablo-jdk1.6.0/jre/bin/java"
  159. echo "---------------------"
  160. echo "DMDirc - Open Source IRC Client"
  161. echo "Launcher Version: ${LAUNCHERVERSION}"
  162. echo "Copyright (c) 2006-2010 Chris Smith, Shane Mc Cormack, Gregory Holmes"
  163. echo "---------------------"
  164. if [ "${ISOSX}" = "1" ]; then
  165. echo "Running on OS X."
  166. elif [ "${KERNEL}" = "Linux" ]; then
  167. echo "Running on Linux."
  168. elif [ "`echo ${KERNEL} | grep -i BSD`" != "" ]; then
  169. echo "Running on BSD."
  170. elif [ "`echo ${KERNEL} | grep -i SunOS`" != "" ]; then
  171. echo "Running on Solaris."
  172. else
  173. echo "Running on unknown unix variation: ${KERNEL}."
  174. fi;
  175. if [ -e "${profiledir}/.launcher.zip" ]; then
  176. # Unzip!
  177. unzip ${profiledir}/.launcher.zip -d ${profiledir}/
  178. fi;
  179. echo -n "Checking for launcher updates in ${profiledir} - ";
  180. if [ -e "${profiledir}/.launcher.sh.ignore" ]; then
  181. rm -Rf "${profiledir}/.launcher.sh.ignore"
  182. echo "Ignoring!";
  183. elif [ -e "${profiledir}/.launcher.sh" ]; then
  184. echo "Found!";
  185. echo "Attempting to update..";
  186. # The code below intentionally doesn't use the FUNCTIONS_FILE include as it
  187. # wouldn't correctly escape \${0} and \${2} where needed and thus stuff would
  188. # break!
  189. cat <<EOF> ${launcherUpdater}
  190. cd ${BASEDIR}
  191. if [ -e "${BASEDIR}/functions.sh" ]; then
  192. . ${BASEDIR}/functions.sh
  193. else
  194. echo "Unable to find functions.sh, using old functions"
  195. errordialog() {
  196. # Send message to console.
  197. echo ""
  198. echo "-----------------------------------------------------------------------"
  199. echo "Error: \${1}"
  200. echo "-----------------------------------------------------------------------"
  201. echo "\${2}"
  202. echo "-----------------------------------------------------------------------"
  203. if [ "${ISOSX}" = "1" -a "" != "${OSASCRIPT}" ]; then
  204. echo "Displaying dialog.."
  205. ${OSASCRIPT} -e 'tell application "System Events"' -e "activate" -e "display dialog \"${1}\n${2}\" buttons {\"Ok\"} with icon stop" -e 'end tell'
  206. else
  207. if [ "" != "${ISKDE}" -a "" != "${KDIALOG}" -a "" != "${DISPLAY}" ]; then
  208. echo "Dialog on Display: ${DISPLAY}"
  209. ${KDIALOG} --title "DMDirc: \${1}" --error "\${1}\n\n\${2}"
  210. elif [ "" != "${ISGNOME}" -a "" != "${ZENITY}" -a "" != "${DISPLAY}" ]; then
  211. echo "Dialog on Display: ${DISPLAY}"
  212. ${ZENITY} --error --title "DMDirc: \${1}" --text "\${1}\n\n\${2}"
  213. fi
  214. fi
  215. }
  216. messagedialog() {
  217. # Send message to console.
  218. echo ""
  219. echo "-----------------------------------------------------------------------"
  220. echo "Info: \${1}"
  221. echo "-----------------------------------------------------------------------"
  222. echo "\${2}"
  223. echo "-----------------------------------------------------------------------"
  224. if [ "${ISOSX}" = "1" -a "" != "${OSASCRIPT}" ]; then
  225. echo "Displaying dialog.."
  226. ${OSASCRIPT} -e 'tell application "System Events"' -e "activate" -e "display dialog \"${1}\n${2}\" buttons {\"Ok\"} giving up after 120 with icon note" -e 'end tell'
  227. else
  228. if [ "" != "${ISKDE}" -a "" != "${KDIALOG}" -a "" != "${DISPLAY}" ]; then
  229. echo "Dialog on Display: ${DISPLAY}"
  230. ${KDIALOG} --title "DMDirc: \${1}" --msgbox "\${1}\n\n\${2}"
  231. elif [ "" != "${ISGNOME}" -a "" != "${ZENITY}" -a "" != "${DISPLAY}" ]; then
  232. echo "Dialog on Display: ${DISPLAY}"
  233. ${ZENITY} --info --title "DMDirc: \${1}" --text "\${1}\n\n\${2}"
  234. fi
  235. fi;
  236. }
  237. fi;
  238. mv -fv ${profiledir}/.launcher.sh ${0}
  239. if [ ! -e "${profiledir}/.launcher.sh" ]; then
  240. echo "Launcher Update successful."
  241. messagedialog "Launcher Update" "Launcher Update successful"
  242. else
  243. if [ "${UID}" = "" ]; then
  244. UID=`id -u`;
  245. fi
  246. if [ "0" != "${UID}" ]; then
  247. if [ "${ISOSX}" = "1" ]; then
  248. messagedialog "DMDirc" "The DMDirc Client Updater was unable to modify the client installation, trying again with administrator access"
  249. if [ $? -eq 0 ]; then
  250. echo "Password dialog on display"
  251. osascript -e do shell script "mv -fv \"${profiledir}/.launcher.sh\" \"${0}\"" with administrator privileges
  252. fi;
  253. else
  254. if [ "" != "${ISKDE}" -a "" != "${KSUDO}" -a "" != "${DISPLAY}" ]; then
  255. echo "Password dialog on ${DISPLAY}"
  256. ${KSUDO} --comment "DMDirc Client Updater requires root access to modify the global installation" -- mv -fv "${profiledir}/.launcher.sh" "${0}"
  257. elif [ "" != "${ISGNOME}" -a "" != "${GSUDO}" -a "" != "${DISPLAY}" ]; then
  258. echo "Password dialog on ${DISPLAY}"
  259. ${GSUDO} -k --message "DMDirc Client Updater requires root access to modify the global installation" -- mv -fv "${profiledir}/.launcher.sh" "${0}"
  260. elif [ "" != "${ZENITY}" -a "" != "${DISPLAY}" ]; then
  261. sudo -k
  262. ${ZENITY} --entry --title="DMDirc" --text="DMDirc Client Updater requires root access to modify the global installation, please enter your password to continue." --entry-text="" --hide-text | sudo -S -- mv -fv "${profiledir}/.launcher.sh" "${0}"
  263. else
  264. echo "DMDirc Client Updater requires root access to modify the global installation"
  265. sudo mv -fv "${profiledir}/.launcher.sh" "${0}"
  266. fi;
  267. fi;
  268. fi
  269. if [ ! -e "${profiledir}/.launcher.sh" ]; then
  270. echo "Update successful."
  271. messagedialog "Launcher Update" "Launcher Update successful"
  272. else
  273. echo "Launcher failed."
  274. errordialog "Launcher Update" "Launcher Update failed, using old version"
  275. touch ${profiledir}/.launcher.sh.ignore
  276. fi;
  277. fi;
  278. sh ${0} ${params}
  279. EOF
  280. chmod a+x ${launcherUpdater}
  281. ${launcherUpdater}
  282. exit 0;
  283. else
  284. echo "Not found.";
  285. fi;
  286. if [ -e "${launcherUpdater}" ]; then
  287. rm -Rf "${launcherUpdater}"
  288. fi;
  289. echo -n "Checking for client updates in ${profiledir} - ";
  290. UPDATESOURCE="${profiledir}/.DMDirc.jar"
  291. BSDIFF="0"
  292. if [ -e "${profiledir}/.DMDirc.jar.bsdiff" -a "${BSPATCH}" != "" ]; then
  293. UPDATESOURCE="${profiledir}/.DMDirc.jar.bsdiff"
  294. BSDIFF="1"
  295. fi;
  296. if [ -e "${UPDATESOURCE}" ]; then
  297. UPDATEOK="0"
  298. TRYROOT="1"
  299. echo "Found!";
  300. echo "Attempting to update..";
  301. if [ "${BSDIFF}" = "1" ]; then
  302. cp ${jar} ${jar}.bak
  303. ${BSPATCH} ${jar}.bak ${jar} ${UPDATESOURCE}
  304. if [ "${?}" = "0" ]; then
  305. FILEINFO=`which ${jar} | egrep "data$"`
  306. if [ "${FILEINFO}" = "" ]; then
  307. UPDATEOK="1"
  308. else
  309. # Let the user know the update failed.
  310. echo "1" >> "${profiledir}/.updatefailed";
  311. chmod 777 "${profiledir}/.updatefailed";
  312. # Replace the attempted update with the old jar
  313. cp ${jar}.bak ${jar}
  314. # Don't bother trying as root.
  315. TRYROOT="0"
  316. fi;
  317. fi;
  318. else
  319. mv -fv ${UPDATESOURCE} ${jar}
  320. if [ ! -e "${profiledir}/.DMDirc.jar" ]; then
  321. UPDATEOK="1"
  322. fi;
  323. fi;
  324. if [ "${UPDATEOK}" = "1" ]; then
  325. echo "Update successful."
  326. messagedialog "Client Update" "Client Update successful"
  327. if [ "${UPDATEONLY}" = "1" ]; then
  328. exit 0;
  329. fi;
  330. else
  331. if [ "${UID}" = "" ]; then
  332. UID=`id -u`;
  333. fi
  334. if [ "0" != "${UID}" -a "1" = "${TRYROOT}" ]; then
  335. if [ "${ISOSX}" = "1" ]; then
  336. messagedialog "DMDirc" "The DMDirc Client Updater was unable to modify the client installation, trying again with administrator access"
  337. if [ $? -eq 0 ]; then
  338. echo "Password dialog on display"
  339. # osascript -e "do shell script \"mv -fv \\\"${profiledir}/.DMDirc.jar\\\" \\\"${jar}\\\"\" with administrator privileges"
  340. osascript -e "do shell script \"sh ${0} ${params} -d "${profiledir}" --updateonly\" with administrator privileges"
  341. fi;
  342. else
  343. if [ "" != "${ISKDE}" -a "" != "${KSUDO}" -a "" != "${DISPLAY}" ]; then
  344. echo "Password dialog on ${DISPLAY}"
  345. # ${KSUDO} --comment "DMDirc Client Updater requires root access to modify the global installation" -- mv -fv "${profiledir}/.DMDirc.jar" "${jar}"
  346. ${KSUDO} --comment "DMDirc Client Updater requires root access to modify the global installation" -- sh ${0} ${params} -d "${profiledir}" --updateonly
  347. elif [ "" != "${ISGNOME}" -a "" != "${GSUDO}" -a "" != "${DISPLAY}" ]; then
  348. echo "Password dialog on ${DISPLAY}"
  349. # ${GSUDO} -k --message "DMDirc Client Updater requires root access to modify the global installation" -- mv -fv "${profiledir}/.DMDirc.jar" "${jar}"
  350. ${GSUDO} -k --message "DMDirc Client Updater requires root access to modify the global installation" -- sh ${0} ${params} -d "${profiledir}" --updateonly
  351. elif [ "" != "${ZENITY}" -a "" != "${DISPLAY}" ]; then
  352. sudo -k
  353. ${ZENITY} --entry --title="DMDirc" --text="DMDirc Client Updater requires root access to modify the global installation, please enter your password to continue." --entry-text="" --hide-text | sudo -S -- sh ${0} ${params} -d "${profiledir}" --updateonly
  354. else
  355. echo "DMDirc Client Updater requires root access to modify the global installation"
  356. # sudo mv -fv "${profiledir}/.DMDirc.jar" "${jar}"
  357. sudo sh ${0} ${params} -d "${profiledir}" --updateonly
  358. fi;
  359. fi;
  360. elif [ "${UPDATEONLY}" = "1" ]; then
  361. # Update failed as root, so give up.
  362. echo "1" >> "${profiledir}/.updatefailed";
  363. chmod 777 "${profiledir}/.updatefailed";
  364. exit 1;
  365. fi;
  366. if [ ! -e "${profiledir}/.updatefailed" ]; then
  367. echo "Update successful."
  368. messagedialog "Client Update" "Client Update successful"
  369. else
  370. rm -Rf ${profiledir}/.updatefailed;
  371. echo "Update failed."
  372. errordialog "Client Update" "Client Update failed, using old version"
  373. if [ "${BSDIFF}" = "1" ]; then
  374. # Run the client without bspatch support
  375. LAUNCHERINFO=`echo ${LAUNCHERINFO} | sed 's/|bsdiff//'`
  376. fi;
  377. fi;
  378. fi
  379. else
  380. echo "Not found.";
  381. fi;
  382. if [ "${UPDATEONLY}" = "1" ]; then
  383. exit 0;
  384. fi;
  385. relaunch() {
  386. trap - INT TERM EXIT
  387. echo ""
  388. echo "============================================================="
  389. echo "ERROR"
  390. echo "============================================================="
  391. echo "${HOME}/.profile has errors in it (or an 'exit' command)."
  392. echo "Setup will now restart with the --noprofile option."
  393. echo "============================================================="
  394. sh ${0} ${params} --noprofile
  395. }
  396. echo -n "Looking for java - ";
  397. if [ "${ISOSX}" = "1" ]; then
  398. JAVA=`which java`
  399. if [ -e "/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Commands/java" ]; then
  400. JAVA="/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Commands/java"
  401. elif [ -e "/System/Library/Frameworks/JavaVM.framework/Versions/1.6/Commands/java" ]; then
  402. JAVA="/System/Library/Frameworks/JavaVM.framework/Versions/1.6/Commands/java"
  403. fi;
  404. else
  405. if [ -e "${HOME}/.profile" -a "${USEPROFILE}" = "1" ]; then
  406. # Source the profile incase java can't be found otherwise
  407. trap relaunch INT TERM EXIT
  408. . ${HOME}/.profile
  409. trap - INT TERM EXIT
  410. fi;
  411. JAVA=`which java`
  412. if [ ! -e "${JAVA}" ]; then
  413. # Location where ports on FreeBSD/PCBSD installs java6
  414. # check it first, because it isn't added to the path automatically
  415. JAVA=${BSDJava1}
  416. if [ ! -e "${JAVA}" ]; then
  417. # Try alternative BSD Location
  418. JAVA=${BSDJava2}
  419. fi;
  420. fi;
  421. fi;
  422. if [ "" != "${JAVA}" ]; then
  423. echo "Success! (${JAVA})"
  424. else
  425. echo "Failed!"
  426. ERROR="Sorry, java does not appear to be installed on this machine.";
  427. ERROR=${ERROR}"\n"
  428. if [ "${ISOSX}" = "1" ]; then
  429. ERROR=${ERROR}"\nDMDirc requires a 1.6.0 compatible JVM.";
  430. else
  431. ERROR=${ERROR}"\nDMDirc requires a 1.6.0 compatible JVM, you can get one from: http://www.java.com";
  432. ERROR=${ERROR}"\nor reinstall DMDirc and let the installer install one for you.";
  433. fi;
  434. errordialog "Unable to launch dmdirc!" "${ERROR}";
  435. exit 1;
  436. fi
  437. echo -n "Running DMDirc - "
  438. if [ -e "${jar}" ]; then
  439. # Check that DMDirc will run, if java is not 1.6 this will fail.
  440. # We do it this way otherwise segfaults etc would cause an unable to launch
  441. # error message to be printed.
  442. ${JAVA} -jar ${jar} --help >/dev/null 2>&1
  443. if [ $? -ne 0 ]; then
  444. FAILED=1
  445. # If we are on BSD, check to see if there is alternative versions of java
  446. # than the one in the path.
  447. if [ "`echo ${KERNEL} | grep -i BSD`" != "" ]; then
  448. if [ "${JAVA}" != "${BSDJava1}" -a "${JAVA}" != "${BSDJava2}" ]; then
  449. JAVA=${BSDJava1}
  450. if [ ! -e "${JAVA}" ]; then
  451. JAVA=${BSDJava2}
  452. fi;
  453. # Now check to see if DMDirc runs again.
  454. ${JAVA} -jar ${jar} --help >/dev/null 2>&1
  455. if [ $? -eq 0 ]; then
  456. # It runs!
  457. FAILED=0
  458. fi;
  459. fi;
  460. fi;
  461. if [ ${FAILED} -eq 1 ]; then
  462. echo "Failed."
  463. ERROR="Sorry, the currently installed version of java is not compatible with DMDirc.";
  464. ERROR=${ERROR}"\n";
  465. if [ "${ISOSX}" = "1" ]; then
  466. ERROR=${ERROR}"\nDMDirc requires a 1.6.0 compatible JVM.";
  467. else
  468. ERROR=${ERROR}"\nDMDirc requires a 1.6.0 compatible JVM, you can get one from: http://www.java.com";
  469. ERROR=${ERROR}"\nor reinstall DMDirc and let the installer install one for you.";
  470. fi;
  471. errordialog "Unable to launch dmdirc!" "${ERROR}";
  472. exit 1;
  473. fi;
  474. fi
  475. # Now we can run the client for real, this allows stderr/stdout output
  476. # to be seen, and the shell script exits with the correct exit code.
  477. APPLEOPTS=""
  478. if [ "${ISOSX}" = "1" ]; then
  479. APPLEOPTS="${APPLEOPTS} -Djava.library.path=${jarDir}"
  480. #APPLEOPTS="${APPLEOPTS} -Dcom.apple.mrj.application.growbox.intrudes=false"
  481. #APPLEOPTS="${APPLEOPTS} -Dcom.apple.mrj.application.live-resize=true"
  482. APPLEOPTS="${APPLEOPTS} -Dcom.apple.mrj.application.apple.menu.about.name=DMDirc"
  483. #APPLEOPTS="${APPLEOPTS} -Dapple.awt.showGrowBox=true"
  484. #APPLEOPTS="${APPLEOPTS} -Dapple.laf.useScreenMenuBar=true"
  485. fi;
  486. ${JAVA}${APPLEOPTS} -ea -jar ${jar} -l ${LAUNCHERINFO} ${params}
  487. EXITCODE=${?}
  488. if [ ${EXITCODE} -eq 42 ]; then
  489. # The client says we need to up update, rerun ourself before exiting.
  490. ${0} ${params}
  491. fi;
  492. exit ${EXITCODE};
  493. else
  494. echo "Failed.";
  495. errordialog "Unable to launch dmdirc!" "No jar file found";
  496. fi