if [ "$1" == "" ]
then
echo "Usage $0 /Path/To/Gameband/Drive"
exit 0
fi

echo "Patching Gameband_linux.bat at $1"
cd $1
cp ./Gameband_linux.bat ./.rungblin.bat

if [ "$(whoami)" == "0" ]
then
 echo "Running As root... Installing Udev Rules For Gameband HID Access"
 echo 'SUBSYSTEM=="usb", ATTR{idVendor}=="2a90", ATTR{idProduct}=="0021", MODE="0666"' > /etc/udev/rules.d/99-gameband.rules
 udevadm control --reload
else
clear
echo "Requires sudo access for udev rules"
 sudo sh -c 'echo SUBSYSTEM=="usb", ATTR{idVendor}=="2a90", ATTR{idProduct}=="0021", MODE="0666" > /etc/udev/rules.d/99-gameband.rules'
sudo udevadm control --reload
fi

echo '#!/bin/bash' > Gameband_linux.bat
echo 'LD_LIBRARY_PATH=.lib /usr/lib/jvm/java-8-openjdk-amd64/bin/java -jar .lib/gblauncher.jar' >> Gameband_linux.bat