make the bash scripts more resilient to symlinks

As it currently stands on 1.4.0-beta1, you can't symlink to the logstash script as it breaks the basedir variable. It seems pretty likely that 

This patch uses a bit more bash to properly resolve basedir so that it handles symlinks.

This bash is lifted from the stackoverflow post: http://stackoverflow.com/questions/59895/can-a-a-script-tell-what-directory-its-stored-in, except for basedir doing one more cd ..

Obviously, this isn't very dry, perhaps a better solution is possible?