#!/bin/sh
# $Id: ipmenu,v 1.10 2001/02/10 21:17:00 stes Exp $

IPLOG=${IPLOG-/tmp/ipmenu.log}
export IPLOG

IPMENU=${IPMENU-/usr/local/src/ipmenu}
export IPMENU

EDITOR=${EDITOR-vi}
export EDITOR

haveip=0
haveiptables=0
havecursel=0
IFS=:
set $PATH
while :
do
  case $# in
    0) break;;
    *) ;;
  esac
  if [ -x $1/iptables ]
  then
    haveiptables=1 
  fi
  if [ -x $1/ip ]
  then
    haveip=1 
  fi
  if [ -x $1/cursel ]
  then
    havecursel=1 
  fi
  shift
done

case $haveip in
 0)
    echo "Can't find 'ip'.  Please verify PATH settings."
    echo "iproute2 is available at ftp://ftp.sunet.se/pub/Linux/ip-routing/"
    exit 0
    ;;
 1) ;;
esac

case $haveiptables in
 0)
    echo "Can't find 'iptables'.  Please verify PATH settings."
    echo "iptables is available at http://netfilter.filewatcher.org"
    exit 0
    ;;
 1) ;;
esac

case $havecursel in
 0)
    echo "Can't find 'cursel'.  Please verify PATH settings."
    echo "cursel is available at http://users.pandora.be/stes/compiler.html"
    exit 0
    ;;
 1) ;;
esac

if [ ! -f /etc/iproute2/rt_tables ]
then
   echo "Can't find routing key database (/etc/iproute2/rt_tables)."
   echo " "
   echo "Copy the 'etc' directory from the iproute2 source package to /etc."
   echo " "
   exit 0
fi

if [ ! -x /usr/bin/perl ]
then
   echo "Can't find /usr/bin/perl."
   exit 0
fi

if [ ! -f $IPMENU/Menu.ip ]
then
   echo "Can't find $IPMENU/Menu.ipmenu.  Please verify IPMENU settings."
   exit 0
fi

cursel $IPMENU/Menu.iptables

