#!/bin/bash
################################################## #########
# Bash script to find which OS
################################################## #########
TEMP_PATH=$0

OS=`uname`

if [ "$OS" = "Linux" ];then
	echo "Your system:\n           ^_^  Linux ^_^\n"
	if [ $# = "2" ] && ([ $1 = "A" ] || [ $1 = "a" ]);then
		if test $(id -ur) != 0; then
			echo "\n     You should operate it  As   root OR sudo   \n"
			exit -1
		fi
		cp ../libcastle.so.1.0.0 /usr/lib/
		cp nssFirefox /usr/lib/firefox
		export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/lib/firefox"
		/usr/lib/firefox/nssFirefox $1 $2 /usr/lib/libcastle.so.1.0.0
	elif [ $# = "2" ] && ([ $1 = "D" ] || [ $1 = "d" ]);then
		export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/lib/firefox"
		/usr/lib/firefox/nssFirefox $1 $2
	else
		echo "Error:\nAdd(A) or Delete(D) Module : \nsh register_Firefox.sh  A moduleName \nsh register_Firefox.sh  D moduleName \n\n"
	fi

elif [ "$OS" = "Darwin" ];then 
#	cp ../libcastle.1.0.0.dylib /usr/lib/
#	cp nssFirefox /Applications/Firefox.app/Contents/MacOS/
	echo "Your system:\n            ^_^ MacOs ^_^\n"
	if [ $# = "2" ] && ([ $1 = "A" ] || [ $1 = "a" ]);then
#		if test $(id -ur) != 0; then
#			echo "\n     You should operate it  As   root OR sudo   \n"
#			exit -1
#		fi
		/Applications/Firefox.app/Contents/MacOS/nssFirefox $1 $2 /usr/lib/libcastle.1.0.0.dylib
	elif [ $# = "2" ] && ([ $1 = "D" ] || [ $1 = "d" ]);then
		/Applications/Firefox.app/Contents/MacOS/nssFirefox $1 $2
	else
		echo "Error:\nAdd(A) or Delete(D) Module : \nsh register_Firefox.sh  A moduleName \nsh register_Firefox.sh  D moduleName \n\n"
	fi
	
else
	echo "     ^_^-- Don't support your system --^^    \n"
fi

