#! /bin/bash

#
# This is a small bash-script that executes netGo with root-privileges.
# Either with "kdesu" (if available) or the "su -c"-method.
#

# Check if we allready are root.
if [ `id -u` = "0" ] 
then
	/usr/share/netgo/netgo-bin $1
else 
	# Check if the user wants to execute from command line.
	if [ "$1" != "" ]
	then
		echo "Please enter your root-password to be able to execute the profile."
		su -c "/usr/share/netgo/netgo-bin $1"
	else
		# Exec a command that searches for "kdesu" in the path.
		which kdesu > /dev/null 2>&1

		# If the exit-status is 1 - kdesu is not in the path.
		if [ $? = "1" ]; then
			xhost +localhost
			echo "Please enter your root-password to be able to use this program for changing your network-settings."
			su -c "/usr/share/netgo/netgo-bin $1"
		else
			kdesu "/usr/share/netgo/netgo-bin $1"
		fi
	fi
fi

