archie/release/scripts/archie.shell
2024-05-27 20:18:02 +02:00

117 lines
2.8 KiB
Bash
Executable File

#!/bin/sh
# This script written by Jim Martin, Rutgers University (jim@rutgers.edu)
#
# Modified by Alan Emtage, Bunyip Information Systems (bajan@bunyip.com)
# Modified by Luc Boulianne, Bunyip Information Systems (lucb@bunyip.com)
# Modified by Andreas Liebe for Solaris <liebe@hrz.th-darmstadt.de>
# Modified by Lee McLoughlin for Solaris 2.3 and for security <lmjm@doc.ic.ac.uk>
# DONT let the user interrupt me to try and get a shell
trap "kill -HUP 0" 1 2 3 15
#
# Set the maximum number of interactive sessions here
#
max=10
# define this to specify a file to print before going into telnet-client
# this is useful if dirsrv looses the MOTD.
motd=$HOME/etc/motd
# Set the nice level (priority) here. It must be >= 0
#
nicelevel=0
# define this if you want to warn the user about reaching the wrong
# host. You will also need to update the message below.
host=`uname -n`
prog=$0
fatal()
{
echo ""
echo "${prog}: $1"
exit 1
}
get_home()
{
if [ $# -ne 1 ] ; then
fatal "get_home: bad number of arguments"
fi
if p=`grep "^${1}:" /etc/passwd` ; then
echo $p | awk -F: '{print $6}'
elif p=`ypmatch $1 passwd` ; then
echo $p | awk -F: '{print $6}'
else
fatal "get_home: can't find home directory for $1"
fi
}
HOME=`get_home ${LOGNAME:-\`whoami\`}`
#stty new crt erase "^?" kill "^u" echo intr "^c"
#stty crt erase "^?" kill "^u" echo intr "^c"
stty erase "^?" kill "^u" echo intr "^c"
case "$fixing" in
'') ;;
*)
echo "working on archie - please try again later or try one of:"
cat $HOME/etc/serverlist
echo The current time is `date`
sleep 5
exit 0
esac
# # Tailor this if required.
# case "$host" in
# '') ;;
# phoenix.*)
# ;;
# *)
# echo "You must be running old nameserver software"
# echo "archie.doc.ic.ac.uk should now get you to:"
# echo " phoenix.doc.ic.ac.uk [146.169.2.10]"
# echo "please check with your local administrators about this"
# sleep 6
# exit 0
# ;;
# esac
if [ `uname -s` = AIX ] ; then
sofar=`/bin/ps agux | grep telnet-client | grep -v grep | wc -l`
else
sofar=`who | grep archie | grep -v grep | wc -l`
fi
#
# The message that you want displayed should be set here after the
# ALL ARCHIE SESSIONS IN USE message and before the _end_
#
if [ $sofar -gt $max ]; then
cat <<_end_
ALL ARCHIE SESSIONS IN USE
I'm sorry. This archie server is currently at the limit of its
interactive login sessions. Please use another archie server or try again
later.
-archie administration
_end_
echo "So far $sofar > $max (max)"
cat $HOME/etc/serverlist
echo The current time is `date`
sleep 5
exit 0
fi
case "$motd" in
'') ;;
*)
if [ -r $motd ]; then
cat $motd
fi
;;
esac
exec nice -$nicelevel $HOME/bin/telnet-client -s