buddycloud/buddycloud-server — Issue #37: fix for (my) start script bug
Author: highfellow
Created: 2012-01-19 14:46:15+00:00
State: open

I've found there's a bug in the bit I wrote to find the full path of the buddycloud module dir from a symlink in $PREFIX/bin.

This version should work:

```
#!/bin/sh
cwd=`pwd`
# find where this file really is by dereferencing the symlink(s).
this=$0
cd `dirname $this`
while [ -n "`readlink $this`" ] ; do
this=`readlink $this`
cd `dirname $this`
done
moduleDir=`pwd`
moduleDir=${moduleDir%%/bin}
# build or display help.
for arg in $@; do
case $arg in
'--nobuild') nobuild=1 ;;
'--help') help=1 ;;
esac
done
# cd to right destination
export PATH=`dirname $0`:$PATH
cd $moduleDir
# compile coffeescript
if [ -z "$nobuild" ] && [ -z "$help" ]; then
env ./node_modules/.bin/cake build || exit 1
fi
# go back where we came from
cd "$cwd"
# execute the real program.
exec env node "$moduleDir/lib/main.js" $@
```