Skip to content

Instantly share code, notes, and snippets.

@didenko
Last active December 15, 2015 05:39
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save didenko/5210584 to your computer and use it in GitHub Desktop.
Save didenko/5210584 to your computer and use it in GitHub Desktop.
A Technic downloader and launcher for OSX systems where Java 6 got upgraded to Java 7. Save the gist as `.command` file, e.g. `technic_osx.command`, make it executable and run it from Finder.
#!/bin/bash
#
# Copyright 2013 Vlad Didenko
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see http://www.gnu.org/licenses/.
#
# Vlad Didenko can be reached for comments via the distribution URL
# of this program at https://gist.github.com/didenko/5210584
export JAVA_HOME=/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
SOURCE_URL=http://mirror.technicpack.net/files/technic-launcher-latest.jar
function on_exit() {
echo "Please, copy the output above for troubleshooting." 1>&2
echo "Press ENTER/RETURN to exit." 1>&2
read junk
}
trap on_exit ERR EXIT
[ "$(uname -s)" == "Darwin" ] || {
echo "This script should be only run on Apple OS X systems." 1>&2
exit 1
}
CACHE_DIR=~/Library/Caches/com.didenko.technic_osx_shell
DOWNLOADED=$(basename ${SOURCE_URL})
EPOC_TIME=$(date +%s)
PREFIX=launcher_
KEEP_LIMIT=10
[ -d "${CACHE_DIR}" ] || mkdir -p ${CACHE_DIR}
pushd ${CACHE_DIR} >/dev/null 2>&1
LAST_CACHED=$(ls -r1 ${PREFIX}*.jar 2>/dev/null | head -n 1)
if curl -s -O ${SOURCE_URL}
then
if diff -q ${LAST_CACHED} ${DOWNLOADED} >/dev/null 2>&1
then
rm ${DOWNLOADED}
else
LAST_CACHED=${PREFIX}${EPOC_TIME}.jar
mv ${DOWNLOADED} ${LAST_CACHED}
fi
else
echo "Failed to download the latest technic launcher." 1>&2
echo "Will try to use a previously downloaded launcher." 1>&2
echo "Press ENTER/RETURN to continue."
read junk
fi
[ -f "${LAST_CACHED}" ] || {
echo "Failed to download or find a previously downloaded technic launcher." 1>&2
echo "Aborted script $0" 1>&2
exit 1
}
java -jar ${LAST_CACHED}
ls -r1 ${PREFIX}*.jar 2>/dev/null |
tail -n +$((KEEP_LIMIT + 1)) |
xargs -L 1 -J % rm %
popd >/dev/null
trap - ERR EXIT
@didenko
Copy link
Author

didenko commented Mar 24, 2014

This is the script featured in the http://youtu.be/AzZzaWwGaQ4 tutorial.

@KANAATIBAN
Copy link

How To Download This

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment