#!/bin/bash

 #
 # Fresque
 #
 # PHP 5.3
 # Redis 2
 #
 # Copyright (c) 2012, Wan Chen aka Kamisama <kami@kamisama.me>
 #
 # Licensed under The MIT License
 # Redistributions of files must retain the above copyright notice.
 #
 # @copyright 	Copyright (c) 2012, Wan Chen aka Kamisama
 # @link 		https://github.com/kamisama
 # @package 	Fresque
 # @version 	0.1
 # @license 	MIT License (http://www.opensource.org/licenses/mit-license.php)
 #

# Resolve symlink path
# @link: http://stackoverflow.com/questions/7665/how-to-resolve-symbolic-links-in-a-shell-script/697552#697552
SELF_PATH=$(cd -P -- "$(dirname -- "$0")" && pwd -P) && SELF_PATH=$SELF_PATH/$(basename -- "$0")

while [ -h $SELF_PATH ]; do
    DIR=$(dirname -- "$SELF_PATH")
    SYM=$(readlink $SELF_PATH)
    SELF_PATH=$(cd $DIR && cd $(dirname -- "$SYM") && pwd)/$(basename -- "$SYM")
done

exec php -q ${SELF_PATH/%fresque/}../src/init.php "$@"
exit;
