#!/bin/bash
if [ "$(id -u)" == "0" ]; then
	echo "This will install Meinberg Protocol Simulation Version 2 (MPSv2) on your local disk."
	echo "Please note that it should only be installed on 64-bit Linux systems."
	read -p "Press Enter to start the installation!"
	echo "...Installing copy protection libraries"	
   	cp -f sglock/libsgllnx64-2.29.02.so /usr/lib/
	ln -f -s /usr/lib/libsgllnx64-2.29.02.so /usr/lib/libsgllnx.so
	cp -f sglock/98-sglock.rules /etc/udev/rules.d/
	chmod 666 /etc/udev/rules.d/98-sglock.rules
	echo "...Optimizing kernel buffer settings"
	echo 134217728 > /proc/sys/net/core/rmem_default
	echo 134217728 > /proc/sys/net/core/rmem_max
	echo 134217728 > /proc/sys/net/core/wmem_default
	echo 134217728 > /proc/sys/net/core/wmem_max
	echo "...Copying MPSv2 binaries to your local disk"
	cp -f mpsd /usr/bin/
	chmod +x /usr/bin/mpsd
	cp -f mpsrc /usr/bin/
	chmod +x /usr/bin/mpsrc
	cp -f mps /usr/bin/
	chmod +x /usr/bin/mps
   	echo "Installation complete."
	echo "You can now run MPSv2 with the commands 'mps start' or 'mpsd (-d)' (Daemon) and 'mpsrc' (GUI)."
	read -p "Press Enter to Exit!"
else
	sudo ./install
fi
exit 1

