#!/bin/sh ################################################# ## ## ## Silly little script to connect an Indy ## ## To a modem pool with dynamically ## ## Assigned IP addresses under IRIX 5.2 ## ## ## ## Certainly longer than necessary, ## ## And not written very well... ## ## ## ## By: Bri Hatch, bri@ifokr.org ## ## ## ## Last Updated 1995-02-21 ## ## ## ## Released under the GPL ## ## ## ## ## ################################################# force="no" mach="lucky" domain="acns|ais" success_string="Your IP address" failure_string="NO CARRIER" default_route="129.105.9.0" netmask="255.255.255.0" blip_blurb="/usr/local/lib/blip.blurb" command=$1 chk () { rm -f /tmp/blip.connections 2> /dev/null # Put netstat output into /tmp/blip.connections netstat -f inet | grep tcp | egrep "$domain" \ | awk '{ print $4 " " $5 " " $6}' > /tmp/blip.connections ; } Check () { # Set blip.connections file chk connections=`wc /tmp/blip.connections| awk '{print $1 }'` if [ "$connections" = "0" ] then echo "\nNo Live Connections\n" > /tmp/blip.connections fi if [ $interactive = "no" ] then cat /tmp/blip.connections else xconfirm -c -name Connections -file /tmp/blip.connections \ > /dev/null fi unset iconic; } Connect () { # Remove trash files, and /tmp/.slip files /bin/rm -f /tmp/blip.out /tmp/.slip* # Check for active connections ps -ef | egrep -v "egrep" | egrep -s "/usr/etc/slip" # If no active connections: if [ $? -ne 0 ] then xwsh -bg black -name BLIP -fn screen7 -iconic \ -geometry 80x24 -log /tmp/slip.out -e /usr/etc/slip \ -dd -cp cslip -m $netmask -u $mach & # Save pid for killing later. xwshpid=$! while # Got connected one way or other egrep -s "$failure_string|$success_string" /tmp/slip.out [ $? = "1" -o $? = "2" ] do sleep 2 done egrep -s "$success_string" /tmp/slip.out # It made a successful connection, and all is well if [ $? = "0" ] # This will take tweeking depending on the output of your specific server. # I get a string that says "Your IP address is 129.105.9.XXX # Where XXX is the only differing portion, so I only need the last number. # Your mileage will vary. then node=`egrep "Your IP address" /tmp/slip.out \ | awk -F. '{ print $5 }'` # It didn't, due to busy signal, line noise, etc... else blip DISCONN exec blip conn fi # Make our machine masquerade as the IP we recieved. # Again, this is what I need, change the 129.105.9.$node to whatever you need, # In coordination with the grepping above, etc... /usr/etc/ifconfig sl0 129.105.9.$node netmask $netmask # remove any old default route, add the current one. remove=`netstat -r | grep default | awk '{print $1 " " $2}'` /usr/etc/route delete $remove /usr/etc/route add net default $default_route 1 # Kill the xwsh itself, so no-one sees our password... # You might want to keep it going to watch the "Week Beep" messages... kill $xwshpid > /dev/null # Here's a good spot to put anything else you might like to include. # Below is schtuff I use for NU specifically, but isn't 100% NU specific. # Determine the name of the terminal we are attached to. machine=`nslookup 129.105.9.$node|grep Name|awk '{ print $2 }'` #echo $machine > /var/tmp/blip.machine #chmod 644 /var/tmp/blip.machine # !!DO NOT!! uncomment these lines unless you have two files, # /etc/sendmail.cf.top (which is /etc/sendmail until the line # #R$*<@alternatename.foo.com>$* $@$1<@@$j>$2 # which is the alternate name section. The /etc/sendmail.cf.bot # is everything below this line. # This hack makes you machine's mailer respond to the current domain name # assigned to it. #/bin/rm -f /etc/sendmail.cf #( cat /etc/sendmail.cf.top ; echo \ # 'R$*<@'$machine'>$*'\\t'$@$1<@@$j>$2'; \ # cat /etc/sendmail.cf.bot ) > /etc/sendmail.cf #/etc/init.d/mail start # keepalive is a stupid script that fingers myself every 20 minutes to keep # the remote end from hanging up from lack of network activity. # don't forget to uncomment the killall in the killit section too... #keepalive & # announce is a script which mails my elm-filter at other machines which # executes a separate script which adds the current machine name to # my aliases, so I never have to think about it. #announce $machine # This line lets ytalk respond to the funky IP address so I can use ytalk # when slipped in. #echo "readdress kami $machine 129.0.0.0" > $HOME/.ytalkrc # Nope - a connection is still alive. else if [ $interactive = "yes" ] then trash=`xconfirm -c -name "Connect" -t \ "Current connection active" -t "" -t \ "Please hang up any live connections first"\ -t "" -B "Continue"` else exec echo "Current connection active." fi fi unset iconic ; } Minimize () { iconic="-iconic" ; } killit () { #killall keepalive killall -INT slip & killall -9 slip rm -f /tmp/.slip*; } Hangup () { chk connections=`wc /tmp/blip.connections| awk '{print $1}'` # If no connections, or we're sure we want to kill it anyway if [ "$connections" = "0" -o $force = "yes" ] then killit # We found connections still active, and aren't forcing a hang up. # What should we do? else /bin/rm -f /tmp/connections.out # Set up output file echo "The Following Connections are still active:\n" \ > /tmp/connections.out cat /tmp/blip.connections >> /tmp/connections.out echo "\nKill Connection anyway?" >> /tmp/connections.out if [ $interactive = "no" ] then cat /tmp/connections.out read cont else cont=`xconfirm -c -B "Nope" -b "Hangup" -file \ /tmp/connections.out -header \ "Really Hang Up???"` fi # We're abso-smurfly sure we want to kill the connection if [ "$cont" = "yes" -o $cont = "Hangup" ] then killit fi fi unset iconic ; } Quit () { exit 0 ; } # Main code schtuff # If somethin' specified on the command line. if [ $command ] then interactive="no" case $command in check|chk) command=Check;; conn|connect) command=Connect;; disconnect|disconn|hangup|hang) command=Hangup;; DISCONNECT|DISCONN|HANGUP|HANG) force="yes" command=Hangup;; esac $command # Command line blip supports only one command at a time. Exit. exit 0 fi interactive="yes" # Repeat until the cows come home. while [ "a" = "a" ] do command=`xconfirm -header "BLIP" -file $blip_blurb -c $iconic \ -font '-*-utopia-medium-r-normal--17-*-*-*-p-91-iso8859-1' \ -B "Check" -b "Connect" -b "Hangup" -b "Minimize" -b "Quit"` $command done