#!/bin/sh

config() {
  NEW="$1"
  OLD="`dirname $NEW`/`basename $NEW .new`"
  # If there's no config file by that name, mv it over:
  if [ ! -r $OLD ]; then
    mv $NEW $OLD
  elif [ "`cat $OLD | md5sum`" = "`cat $NEW | md5sum`" ]; then # toss the redundant copy
    rm $NEW
  fi
  # Otherwise, we leave the .new copy for the admin to consider...
}
config /etc/rc.d/rc.apache-tomcat.new
for i in `find /opt/apache-tomcat/conf/ -name "*.new"`;
do
    config $i
done

USER=apache-tomcat
/usr/sbin/groupadd $USER 2> /dev/null
/usr/sbin/useradd -c "User for Apache-Tomcat" -d /opt/$USER -g $USER -s "/bin/sh" $USER 2> /dev/null
chown -R $USER:$USER /opt/$USER

echo -e "\n"
echo -e "           \|||/          "
echo -e "           (o o)          "
echo -e "--------ooO-(_)-Ooo-------"
echo -e " by Diego @ www.slacky.eu "
echo -e "\n"

