#!/bin/sh

if [ ! "$USER" = "root" ]
then
	if [ ! "$1" = "--demo" ]
	then
		echo "You must run dell-config-cluster with root permissions!"
		exit 1
	fi
fi

if [ ! -f /opt/dell/dell-config-cluster/share/dell-config-cluster-gui.py ]
then
	echo "Fatal error, please reinstall dell-config-cluster!"
	exit 1
fi

if [ -n "$DISPLAY" ]
then
	pushd /opt/dell/dell-config-cluster/share/
	python dell-config-cluster-gui.py "$@" 2>&1 | tee /tmp/dell-config-cluster.log
# Removed sending to background for now
#	python dell-config-cluster-gui.py "$@" &
	popd
else
	echo "You must be running X to use dell-config-cluster!"
	exit 1
fi
