#!/bin/sh
OLDPATH="$PATH"
WHEREAMI="`pwd`"

SCRIPTDIR="`dirname \"$0\"`"
NODE="`cd \"$SCRIPTDIR\" && pwd`"

export PATH="$NODE/node_binaries/bin:$PATH"

if [ -r /dev/stdin ]; then
  if [ -p /dev/stdin ]; then
    node "$NODE/lib/qrtz.js" $@ < /dev/stdin
  else
    node "$NODE/lib/qrtz.js" $@
  fi
else
  # when running from crontab, stdin is not available and environment is often
  # erratically initialized -> resort to using an input pipe to run a script
  node "$NODE/lib/qrtz.js" < $@
fi

export PATH="$OLDPATH"
cd "$WHEREAMI"
