#!/bin/sh
#
# Installation script for tin 1.22 binaries for MiNT
#

DIRS="/usr /usr/local /usr/local/bin /usr/local/man /usr/local/man/man1
/usr/src /usr/src/tin"

if test `whoami` != "root"
then
    echo "You must be root to install tin."
    exit
fi

for i in $DIRS
do
    if test -d $i
    then
	echo "Directory $i exists."
    else
	echo "Creating $i."
	mkdir $i
	chmod 775 $i
    fi
done

if test -f /usr/local/bin/tin
then
    echo "Save /usr/local/bin/tin to /usr/local/bin/tin.old"
    rm -f /usr/local/bin/tin.old
    mv /usr/local/bin/tin /usr/local/bin/tin.old
fi
echo "Copy tin to /usr/local/bin/tin"
cp bin/tin /usr/local/bin/tin
chmod 755 /usr/local/bin/tin
chown root.wheel /usr/local/bin/tin

if test -e /usr/local/bin/rtin
then
    echo "Save /usr/local/bin/rtin to /usr/local/bin/rtin.old"
    rm -f /usr/local/bin/rtin.old
    mv /usr/local/bin/rtin /usr/local/bin/rtin.old
fi
echo "Link /usr/local/bin/tin to /usr/local/bin/rtin"
ln /usr/local/bin/tin /usr/local/bin/rtin

echo "Install manual tin.1"
cp man/tin.1 /usr/local/man/man1/tin.1

echo "Install tin.diffs to /usr/src/tin/tin.diffs"
cp tin.diffs /usr/src/tin

cat <<EOF
Installation complete.

EOF
