2015-02-11 17:13:12 +00:00
|
|
|
#!/bin/bash
|
2014-12-09 19:35:15 +00:00
|
|
|
|
2015-02-11 17:13:12 +00:00
|
|
|
function unsupported_platform() {
|
|
|
|
echo "Your platform (`uname -a`) is not supported." && exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
# Detect CPU arch.
|
|
|
|
ARCHITECTURE=`uname -m`
|
|
|
|
case "$ARCHITECTURE" in
|
|
|
|
i?86) ARCHITECTURE="x86" ;;
|
|
|
|
x86_64) ARCHITECTURE="x64" ;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
# Detect current OS, see http://stackoverflow.com/q/3466166/682252.
|
|
|
|
|
|
|
|
# Darwin
|
|
|
|
if [ "`uname`" == "Darwin" ]; then
|
2015-02-13 19:35:28 +00:00
|
|
|
NODE_BIN="node-darwin-$ARCHITECTURE"
|
2015-02-11 17:13:12 +00:00
|
|
|
|
|
|
|
# Linux
|
|
|
|
elif [ "`expr substr $(uname -s) 1 5`" == "Linux" ]; then
|
2015-02-13 19:35:28 +00:00
|
|
|
NODE_BIN="node-linux-$ARCHITECTURE"
|
2015-02-11 17:13:12 +00:00
|
|
|
|
|
|
|
# Win32
|
|
|
|
elif [ "`expr substr $(uname -s) 1 10`" == "MINGW32_NT" ]; then
|
2015-02-13 19:35:28 +00:00
|
|
|
NODE_BIN="node-win32-$ARCHITECTURE.exe"
|
2015-02-11 17:13:12 +00:00
|
|
|
|
|
|
|
# SunOS
|
|
|
|
elif [ "`uname`" == "SunOS" ]; then
|
2015-02-13 19:37:58 +00:00
|
|
|
NODE_BIN="node-sunos-$ARCHITECTURE"
|
2015-02-11 17:13:12 +00:00
|
|
|
|
|
|
|
else
|
|
|
|
unsupported_platform
|
|
|
|
fi
|
|
|
|
|
2015-02-27 18:20:56 +00:00
|
|
|
BIN_RESIN=$0
|
|
|
|
|
|
|
|
while [ -L "$BIN_RESIN" ]; do
|
|
|
|
BIN_RESIN=`readlink "$BIN_RESIN"`
|
|
|
|
done
|
|
|
|
|
|
|
|
BIN_DIRECTORY=`dirname $BIN_RESIN`
|
|
|
|
|
|
|
|
NODE_PATH=$BIN_DIRECTORY/node/$NODE_BIN
|
2015-02-11 17:13:12 +00:00
|
|
|
|
|
|
|
if [ ! -x $NODE_PATH ]; then
|
2015-02-11 19:38:03 +00:00
|
|
|
|
2015-02-27 18:20:56 +00:00
|
|
|
echo "$NODE_PATH does not exist"
|
|
|
|
|
2015-02-11 19:38:03 +00:00
|
|
|
# As a last resource, try to use an already available node
|
|
|
|
if command -v node >/dev/null 2>&1; then
|
|
|
|
NODE_PATH="node"
|
|
|
|
else
|
|
|
|
unsupported_platform
|
|
|
|
fi
|
2015-02-11 17:13:12 +00:00
|
|
|
fi
|
|
|
|
|
2015-02-27 18:20:56 +00:00
|
|
|
$NODE_PATH "$BIN_DIRECTORY/../build/app.js" "$@"
|