#
# snaulmod
#
# Remove all the SNAP-IX loadable modules
# (ALL calling scripts should ensure sna stopped first)

# 
# Set path for message catalog file.  Set "C" to be the default.
NLSPATH=/opt/ibm/sna/lib/nls/msg/LC_MESSAGES/%N:/opt/ibm/sna/lib/nls/msg/%L/%N
export NLSPATH=${NLSPATH}:/opt/ibm/sna/lib/nls/msg/C/%N

#
# Set path for snareadinstcat binary
READINSTCAT=/opt/ibm/sna/bin/snareadinstcat

#
#  Check that Communications Server for Linux daemon/appl is not running
#
ACTIVE=`ps -ef | egrep "snadaemon" | grep -v grep`
if [ "x$ACTIVE" != "x" ]
then
  # echo "Error: SNA must be stopped before running this script"
  $READINSTCAT 18
  exit 10
fi
#

if [ `uname -r | cut -c 1-3` = 2.6 ]
then
  KERNEL26=1
else
  KERNEL26=0
fi

# -s directs output to the syslog
cat /proc/modules | grep sna_linux > /dev/null 2>&1
if [ $? = 0 ]
then
  if [ $KERNEL26 = 1 ]
  then
    /sbin/rmmod -s snapixq
    /sbin/rmmod -s snapixs
    /sbin/rmmod -s snapixi
    /sbin/rmmod -s snapixy
    /sbin/rmmod -s snapixn
    /sbin/rmmod -s snapixr
    /sbin/rmmod -s snapixt
  else
    /sbin/rmmod -s streams-sixq
    /sbin/rmmod -s streams-sixs
    /sbin/rmmod -s streams-sixi
    /sbin/rmmod -s streams-sixy
    /sbin/rmmod -s streams-sixn
    /sbin/rmmod -s streams-sixr
    /sbin/rmmod -s sna_trace
  fi
  /sbin/rmmod -s sna_linux
fi
#
# Delete the sna device entries
#
rm -f /dev/sna_* 2> /dev/null
