#!/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

# Stop it first.
/bin/launchctl unload -w /Library/LaunchDaemons/org.nxfilter.nxproxy.plist
sleep 2

# Set it to DHCP.
$NX_HOME/bin/undns.sh

# Delete files.
/bin/rm /Library/LaunchDaemons/org.nxfilter.nxproxy.plist
/bin/rm -rf $NX_HOME
