#!/bin/bash
set -e

KUMATUXVERSION=1.1
SYSTEMPATH=$PATH
PATH=`echo $0 | sed 's/\/kumatux.org-setup.sh//'`/bin:$PATH

# get the absolute path of the executable
SELF_PATH=$(cd -P -- "$(dirname -- "$0")" && pwd -P) && SELF_PATH=$SELF_PATH/$(basename -- "$0")
# resolve symlinks
while [ -h $SELF_PATH ]; do
    # 1) cd to directory of the symlink
    # 2) cd to the directory of where the symlink points
    # 3) get the pwd
    # 4) append the basename
    DIR=$(dirname -- "$SELF_PATH")
    SYM=$(readlink $SELF_PATH)
    SELF_PATH=$(cd $DIR && cd $(dirname -- "$SYM") && pwd)/$(basename -- "$SYM")
done

KUMATUXSETUPBIN=$(dirname -- "$SELF_PATH")/bin
PATH=$KUMATUXSETUPBIN:$SYSTEMPATH
## The workaround via calling `kumatux-setup.sh' via bash is to enable setup on systems not having `bash' yet, and using `busybox'
bash $KUMATUXSETUPBIN/setup.sh/kumatux-setup.sh $*
