#!/bin/sh
# Written by Danny Bickson, HUJI
# modified by Ohad Serfaty , TAU (11.9.05)
#USERNAME=`whoami`
CURRENT_DIR=$(pwd)
CLASSES_DIR="$CURRENT_DIR/Classes"
BASE_DIR="$CURRENT_DIR/Classes/Base"
CONF_DIR="$BASE_DIR/conf"

. colors.sh
echo "Installing DIMES"
echo "Updating properties file $CONF_DIR/properties.xml"
echo -n "You can later edit this file manually if needed........."

test -f $CONF_DIR/properties.xml  
verify $?  "Missing properties file: $CONF_DIR/properties.xml" 

echo -n "setting JARS dir: $CLASSES_DIR/JARs.........................."
sed -i "s#<jarDir>.*</jarDir>#<jarDir>$CLASSES_DIR/JARs</jarDir>#g" $CONF_DIR/properties.xml
sed -i "s#<base>.*</base>#<base>$BASE_DIR</base>#g" $CONF_DIR/properties.xml
verify $?


# deprecated : set IP address :
#IP_ADDR=`ifconfig eth0 | grep "inet addr" | awk '{print $2}' | sed -e "s/addr\://g"`
#echo -n "setting IP address: $IP_ADDR............................"
#if [ $IP_ADDR != "" ]; then
#	sed -i "s#132.66.48.22#$IP_ADDR#g" $CONF_DIR/properties.xml
#fi
#verify $?

chmod a+rx . *.sh > /dev/null 2>&1
#verify $? "failed to setup file permissions"

#The following should be executed as root!
echo "Going to set root priviliges for running ping and traceroute"
echo "Please enter root password"
sudo bash ./fix_permissions.sh

echo "Installation OK!"
