#!/bin/sh
# Check permission.
if ! [ $(/usr/bin/id -u) = 0 ]; then
   echo "Must be running with root permission!"
   exit 1
fi

# Export.
export NX_HOME=/Library/nxproxy
export JAVA_BIN=$NX_HOME/jre4mac/Contents/Home/bin/java

# Set permission.
/bin/chmod +x $NX_HOME/bin/*.sh
/bin/chmod +x $JAVA_BIN

# Run it.
$JAVA_BIN -Djdk.lang.Process.launchMechanism=FORK -cp $NX_HOME/nxproxy.jar:$NX_HOME/lib/* nxproxy.gMain
