Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- TARGET_FILE=$0
- cd `dirname $TARGET_FILE`
- TARGET_FILE=`basename $TARGET_FILE`
- # Iterate down a (possible) chain of symlinks
- while [ -L "$TARGET_FILE" ]
- do
- TARGET_FILE=`readlink $TARGET_FILE`
- cd `dirname $TARGET_FILE`
- TARGET_FILE=`basename $TARGET_FILE`
- done
- # Compute the canonicalized name by finding the physical path
- # for the directory we're in and appending the target file.
- PHYS_DIR=`pwd -P`
- RESULT=$PHYS_DIR/$TARGET_FILE
- echo $RESULT
- DIR=$(dirname $RESULT)
- BIN=$(basename $RESULT)
- cd "$DIR" || exit $?
- # If name does not match a binary or is this same script, find the right one
- if [ ! -f "$BIN" ] || [ "$BIN" = "$(basename $RESULT)" ]
- then
- BIN=
- for bin in cataclysm-tiles cataclysm
- do
- [ -f "$bin" ] && BIN="$bin" && break
- done
- fi
- if [ "$BIN" ]
- then
- exec "./$BIN"
- else
- echo "Couldn't find cataclysm game binary in $DIR/"
- exit 1
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement