#! /bin/bash
#
# splinux_r2u - Run a parallel Linux installation
# Copyright (c) 2010 Nebil Reyhani
#
# This file is part of splinux.
# Splinux is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
# Send your feedback or comments to: nebil.reyhani@gmail.com
# 


if [ -z "$1" ]; then
  echo "No username specifed"
  echo "This script is only to be started from splinux automatically"
  exit
fi

user=$1
command=$2
display=$3

#check_user=`finger "$user"`
#if [ -z "$check_user" ]; then
#  echo "User doesn't exist"
#  echo "Please enter a valid user name"
#  exit
#fi

echo " "
echo "==========================================================="
echo "root directory changed to specified mountpoint successfully"
echo "user: $user"
echo "command: $command"

if [ "$user" == "root" ]; then
splinux_u $command
else
su - $user /tmp/splinux_u $command $display
fi

exit
