Try Applications/MyApp.app
for the location if it is in the given area, or you could use a Unix command to launch the jar at the desired directory (and not hardcode it into the .jar
file).
-x
is used for executables, but apps usually also work with -d
and all work with -e
commands.
To implement, place your AutoUpdater.jar
with the other .jar files in MyApp.app/contents/resources/java
. The AutoUpdater.jar
should look something like this:
main()
{
if [ -x Applications/MyApp.app];then
cd Applications/MyApp.app/contents/resources/java
java AutoUpdater.jar
wait 86400
main
else
wait 3600
fi
}
main
The next bit of code will attempt to see if the app exists every hour and update daily if left running.
download()
{
cd Applications/MyApp.app/contents/resources/java
if ! curl -LO http://your.url.that.it.is.updating.from;then
echo "Failed to download"
wait 3600
else
wait 86400
fi
}
You can completely remove AutoUpdate.jar
by adding this to the code before the last line. Replace this:
java AutoUpdater.jar
wait 86400
... with this:
download
This is designed only for JarBundler
apps. You should use this to replace the current .jar file.
if ! curl -LO http://cbukk.it/craftbukkit-dev.jar;
As a side note, the command user.dir
usually gets /Users/yourName
as the path. You could change this to use a global identifier in JarBundler
like so:
String path = com.mycommpany.myapp;