#!/bin/bash
#
#	Run a command with privilege
#
#	Copyright (c) Mbedthis Software LLC, 2003-2007. All Rights Reserved.
#
################################################################################

env

if [ $DISABLE_PRIV ]; then
	echo "Installing $* without root privilege"
	sh -c "$*"
else
	if [ `id -u` = 0 ] ; then
		sh -c "$*"
	else
		if type sudo >/dev/null 2>&1 ; then
			echo
			PASS_PROMPT="Root privilege required, please enter the root password: "
			sudo -S -p "$PASS_PROMPT" sh -c "$*"
		else
			sh -c "$*"
		fi
	fi
fi
