| 1 | -- Run AE Installer
|
|---|
| 2 | -- for Anniversary Edition Seven
|
|---|
| 3 | -- by Iritscen
|
|---|
| 4 | -- Serves as a forking alias which opens either the AE Installer, or, if the AEI is
|
|---|
| 5 | -- not found, the AEI Updater so it can install the Installer. Used as both a
|
|---|
| 6 | -- shortcut for the user and as a part of the AE Setup process.
|
|---|
| 7 | -- History:
|
|---|
| 8 | -- 1.0.8 - Now that Mono is installed in /usr/local/bin/ in 10.11, we need to add
|
|---|
| 9 | -- that path to PATH when invoking Java.
|
|---|
| 10 | -- 1.0.7 - Now an AppleScriptObjC application to ensure signing integrity and OS
|
|---|
| 11 | -- compatibility for 10.6 through 10.11.
|
|---|
| 12 | -- 1.0.6 - The previous method fails sometimes, e.g. in 10.7 with Apple Java
|
|---|
| 13 | -- installed, so now we are just looking in either place and calling Java
|
|---|
| 14 | -- when we find it.
|
|---|
| 15 | -- 1.0.5 - Removing "which java" as "smart" method for finding Java, as it can now
|
|---|
| 16 | -- return a value like "/usr/bin/java" even when Java is not really
|
|---|
| 17 | -- there; now calling Java using a fixed path for 10.6 and another fixed
|
|---|
| 18 | -- path for 10.7+.
|
|---|
| 19 | -- 1.0.4 - Calling Java through command-line again before falling back to Internet
|
|---|
| 20 | -- Plug-Ins location, to restore 10.6 compatibility.
|
|---|
| 21 | -- 1.0.3 - Instead of escaping only space characters in paths, put paths in quotes
|
|---|
| 22 | -- to avoid need for escaping entirely.
|
|---|
| 23 | -- 1.0.2 - Calling Java at Internet plug-in location instead of using basic command-
|
|---|
| 24 | -- line "java", as only the JDK installs command-line Java.
|
|---|
| 25 | -- 1.0.1 - Now setting environment to UTF-8 in order to avoid 'ƒ' problem in Java 7.
|
|---|
| 26 | -- 1.0 - Initial release.
|
|---|
| 27 |
|
|---|
| 28 | script AppDelegate
|
|---|
| 29 | property parent : class "NSObject"
|
|---|
| 30 | global parentPathUnixNS
|
|---|
| 31 | global parentPathUnixStr
|
|---|
| 32 | global parentPathASAlias
|
|---|
| 33 | global parentPathASStr
|
|---|
| 34 |
|
|---|
| 35 | -- IBOutlets
|
|---|
| 36 | property theWindow : missing value
|
|---|
| 37 |
|
|---|
| 38 | on applicationWillFinishLaunching_(aNotification)
|
|---|
| 39 | tell application "Finder"
|
|---|
| 40 | tell current application's class "NSBundle"
|
|---|
| 41 | tell its mainBundle()
|
|---|
| 42 | set parentPathUnixNS to bundlePath()'s stringByDeletingLastPathComponent
|
|---|
| 43 | set parentPathUnixStr to parentPathUnixNS as string
|
|---|
| 44 | end tell
|
|---|
| 45 | end tell
|
|---|
| 46 | set parentPathASAlias to POSIX file parentPathUnixStr as alias
|
|---|
| 47 | set parentPathASStr to parentPathASAlias as string
|
|---|
| 48 | set success to true
|
|---|
| 49 |
|
|---|
| 50 | -- Test for Java at the two standard locations
|
|---|
| 51 | set javaPath to "/Library/Internet\\ Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java"
|
|---|
| 52 | set javaExistsTest to ("if [ -f " & javaPath & " ]; then echo okay; fi") as string
|
|---|
| 53 | set javaExists to do shell script javaExistsTest without altering line endings
|
|---|
| 54 | if (javaExists is "") then
|
|---|
| 55 | -- Test for Java at old location (Apple Java)
|
|---|
| 56 | set javaPath to "/usr/bin/java"
|
|---|
| 57 | set javaExistsTest to ("if [ -f " & javaPath & " ]; then echo okay; fi") as string
|
|---|
| 58 | set javaExists to do shell script javaExistsTest without altering line endings
|
|---|
| 59 | if (javaExists is "") then
|
|---|
| 60 | display alert "Could not find Java!"
|
|---|
| 61 | set success to false
|
|---|
| 62 | end if
|
|---|
| 63 | end if
|
|---|
| 64 |
|
|---|
| 65 | if (success is true) then
|
|---|
| 66 | set run_prefix to "export PATH=/usr/local/bin:${PATH};export LC_CTYPE=\"UTF-8\";"
|
|---|
| 67 | set AEIUfolder to parentPathASStr & "AEInstaller"
|
|---|
| 68 | set AEIU to AEIUfolder & ":AEInstaller2Updater.jar"
|
|---|
| 69 | set AEIU_CLI to POSIX path of AEIU
|
|---|
| 70 | set run_AEIU to run_prefix & javaPath & " -jar \"" & AEIU_CLI & "\" &> /dev/null &"
|
|---|
| 71 |
|
|---|
| 72 | set AEIfolder to parentPathASStr & "AEInstaller:bin"
|
|---|
| 73 | set AEI to AEIfolder & ":AEInstaller2.jar"
|
|---|
| 74 | set AEI_CLI to POSIX path of AEI
|
|---|
| 75 | set run_AEI to run_prefix & javaPath & " -jar \"" & AEI_CLI & "\" &> /dev/null &"
|
|---|
| 76 | if not (parentPathUnixNS's lastPathComponent as string is "AE") then
|
|---|
| 77 | display alert "Please put \"Run AE Installer\" in the AE/ folder so I can find the Installer."
|
|---|
| 78 | else if (AEI exists) then
|
|---|
| 79 | do shell script run_AEI
|
|---|
| 80 | else if (AEIU exists) then
|
|---|
| 81 | do shell script run_AEIU
|
|---|
| 82 | else
|
|---|
| 83 | display alert "Could not find AE Installer *or* AE Installer Updater! You may need to re-install the AE."
|
|---|
| 84 | end if
|
|---|
| 85 | end if
|
|---|
| 86 | end tell
|
|---|
| 87 | tell me
|
|---|
| 88 | quit
|
|---|
| 89 | end tell
|
|---|
| 90 | end applicationWillFinishLaunching_
|
|---|
| 91 |
|
|---|
| 92 | on applicationShouldTerminate_(sender)
|
|---|
| 93 | -- Insert code here to do any housekeeping before your application quits
|
|---|
| 94 | return current application's NSTerminateNow
|
|---|
| 95 | end applicationShouldTerminate_
|
|---|
| 96 |
|
|---|
| 97 | end script
|
|---|