diff options
Diffstat (limited to 'src/launch.sh')
-rw-r--r-- | src/launch.sh | 30 |
1 files changed, 25 insertions, 5 deletions
diff --git a/src/launch.sh b/src/launch.sh index 7f8fd82..01f56c2 100644 --- a/src/launch.sh +++ b/src/launch.sh @@ -1,9 +1,29 @@ -#!/bin/sh +#!/bin/sh -xeu # Launch script for unix systems, loads bundled libraries if there are any. -cd "$(dirname $0)" -DYLD_LIBRARY_PATH=libs/ LD_LIBARY_PATH=libs/ ./Pong > output.log 2>&1 -if [ ! $? = "0" ]; -then +EXIT_STATUS=0 + +failed() { zenity --error --text="The program appears to not have closed correctly. Please check output.log to see details." + EXIT_STATUS=1 +} + +run_game() { + cd "$(dirname "$0")" || return 1 + PAYLOAD_LINE="$(awk '/^__PAYLOAD_BEGINS__/ { print NR + 1; exit 0; }' "$0")" || return 1 + tail -n +"${PAYLOAD_LINE}" "$0" | xz -d > "$TMPFILE" || return 1 + chmod +x "$TMPFILE" || return 1 + DYLD_LIBRARY_PATH=libs/ LD_LIBARY_PATH=libs/ "$TMPFILE" > output.log 2>&1 || return 1 + return 0 +} + +TMPDIR=/tmp +TMPFILE="$(mktemp /tmp/Pong-XXXXXXXXXXXXXXXXXXXXX)" + +if ! run_game; +then + failed fi +rm "$TMPFILE" +exit "$EXIT_STATUS" +__PAYLOAD_BEGINS__ |