Get the full path (or BASEDIR) of the running script's path in bash. Put this at the top of every bash script so you never get lost.
BASEDIR=$( cd -P "$(dirname "$0")" && pwd) popd "${BASEDIR}" || exit 1