#!/bin/sh

DOBACKUP=yes
: ${MV:=mv} ${CP:=cp}

doinst() {
  echo "Installing $1 as $2..."
  case $DOBACKUP in
  [yY]*)	$MV "$2" "$2".orig
  esac
  $CP "$1" "$2"
}

installbin() {
  source=$1
  shift
  for file
  do
    if [ -f "$file" ]
    then
      doinst "$source" "$file"
      return
    fi
  done

  echo "Warning: unable to find system location for $source"
  doinst "$source" "$1"
}

#echo "Make backup copies [yN]?  \c"
#read DOBACKUP
#export DOBACKUP

echo

installbin telnet /bin/telnet /usr/bin/telnet /usr/ucb/telnet /usr/bsd/telnet /usr/local/bin/telnet

installbin ftp /bin/ftp /usr/bin/ftp /usr/ucb/ftp /usr/bsd/ftp /usr/local/bin/ftp

#FTPD=`grep "^ftp" /etc/inetd.conf | awk '{print $6}'`
installbin ftpd /usr/sbin/in.ftpd /usr/sbin/ftpd /usr/sbin/wu.ftpd /usr/etc/in.ftpd /usr/etc/ftpd /usr/etc/wu.ftpd /usr/libexec/ftpd $FTPD

#TELNETD=`grep "^telnet" /etc/inetd.conf | awk '{print $6}'`
installbin telnetd /usr/sbin/in.telnetd /usr/sbin/telnetd /usr/etc/in.telnetd /usr/etc/telnetd /usr/libexec/telnetd $TELNETD

echo Done.
