#!/bin/sh

. /etc/efingerd/log 

echo
if [ $1 = '(null)' ]; then
  echo Hello $2,
else 
  echo Hello $1\@$2,
fi

if [ $3 = '/W' ]; then
  /usr/bin/finger
  exit 0
fi


if [ $3 = 'time' ]; then
  echo The time is...
  date
  exit 0
fi

if [ $3 = 'ping' ]; then
  echo 'PONG!'
  ping -c 5 $2
  exit 0
fi

if [ $3 = 'traceroute' ]; then
  /usr/sbin/traceroute -n -q 2 $2
  exit 0
fi

if [ $3 = 'fortune' ]; then
  /usr/games/fortune
  exit 0
fi

if [ $3 = 'users' ]; then
  /usr/bin/finger | grep -v garabik
  exit 0
fi

if [ $3 = 'who' ]; then
  who -iwH | grep -v garabik
  exit 0
fi

if [ $3 = 'date' ]; then
  date
  exit 0
fi

if [ $3 = 'w' ]; then
  w | grep -v garabik
  exit 0
fi

if [ $3 = 'cal' ]; then
  cal
  exit 0
fi

if [ $3 = 'calendar' ]; then
  calendar
  exit 0
fi

if [ $3 = 'help' ]; then
cat <<EOM

Help me if you can,
I'm feeling down

              (The Beatles)

try:
finger command@melkor.dnp.fmph.uniba.sk, where command is one of:

  fortune  : some wise words
  ping     : test the net
  help     : heeeeelp !!!
  users    : display selected users logged in
  who      : ditto
  w        : tritto
  date     : what's the day today?
  cal      : and yesterday and tommorow?
  calendar : there is always a reason to drink
EOM
  exit 0
fi

cat <<EOM
You tried to finger non existant user!
Your attempt is logged and sent to C.I.A., K.G.B. and S.I.S.
Expect a visit soon.

EOM
