home *** CD-ROM | disk | FTP | other *** search
- # @(#)postremove 1.3
- # nws postremove
-
- #
- trap "" 2
-
- ADMINUSER=/usr/bin/adminuser
- GREP=/usr/bin/grep
-
- if [ "$RANDOM" = "$RANDOM" ]
- then
- exec /usr/bin/winxksh $0 $*
- fi
-
- # Redirect stderr to a file
- ERR="/tmp/nwsrvr.premove.err"
- exec 2>$ERR
-
-
- # Load strings
- . ${LANGDEP_SCRIPTS}/set_strings
-
- function ProtocolStackCleanup
- {
- [ -n "$DEBUG" ] && set -x
-
- #
- # Remove drivers
- #
- cd /etc/conf
-
- for i in nwetc ncpipx nemux sfd
- do
- # unload modules
- modadmin -U $i >/dev/null 2>&1
- /etc/conf/bin/idinstall -d $i
-
- # remove modules from the system
- /etc/conf/bin/idinstall -d -P nws $i
- done
-
- }
-
- function NWSCleanup
- {
- [ -n "$DEBUG" ] && set -x
-
- typeset -u YN_UPPER
- TRASH_VOLS="FALSE"
- # ask "Do you want to remove all volumes and user created files and dirs?"
- echo -n $REMOVE_ALL_VOLS
- read
- YN_UPPER=$REPLY
- if [ "$YN_UPPER" = $Y -o "$YN_UPPER" = $YES ]
- then
- echo -n $ARE_YOU_SURE
- read
- YN_UPPER=$REPLY
- if [ "$YN_UPPER" = $Y -o "$YN_UPPER" = $YES ]
- then
- TRASH_VOLS="TRUE"
- fi
- fi
-
- print -u2 TRASH_VOLS[$TRASH_VOLS]
-
- SYSVOL=""
-
- # Remove volume control directories
- exec 3< /etc/netware/voltab
- while read -u3
- do
- # Skip blank lines
- if (( "${#REPLY}" == 0 ))
- then
- continue
- fi
-
- set $REPLY # put into postional parameter form
-
- # skip comment lines
- tmp=`echo "$1" | cut -c1`
- if [ "$tmp" = "#" ]
- then
- continue
- fi
-
- # skip syntax errors (rudimentary test)
- if (( "$#" != 7 ))
- then
- continue
- fi
-
- print -u2 4[$4]
- print -u2 5[$5]
- # trash all volumes if user specified "yes" above
- if [ "$TRASH_VOLS" = "TRUE" ]
- then
- if [ "$4" != "/" -a "$5" != "/" ]
- then
- /sbin/rm -rf $4
- /sbin/rm -rf $5
- fi
- fi
-
- if [ "$2" = "SYS" ]
- then
- SYSVOL="$4"
- CONTROL="$5"
-
- # Remove Directory Services database
- /sbin/rm -rf $SYSVOL/_netware
- fi
-
-
- done
- # close file
- exec 3<&-
-
- # remove license directory and all license files
- /sbin/rm -rf /etc/netware/licenses > /dev/null 2>&1
-
- # Remove voltab file
- /sbin/rm -f /etc/netware/voltab > /dev/null 2>&1
-
- # Clean up nwconfig file
- /usr/sbin/nwcm -x
-
- if [ "$SYSVOL" = "" ]
- then
- return 0
- fi
-
- # remove all files in mail directory
- /sbin/rm -f $SYSVOL/mail/* > /dev/null 2>&1
- /sbin/rm -f $SYSVOL/mail/.* > /dev/null 2>&1
-
- return 0
- }
-
- function TFMCleanup
- {
-
- # Remove root privs for the following
- $ADMINUSER -r dsinstall,dsrepair,dsadmin,nwserver,ndsbackup,ndsrestore,tsadmin,nwshut,nwvm,nwcm,pserver,stopprint,nwserverstatus,NWS_Status,NWVolume_Setup,NWS_Licensing root >/dev/null 2>&1
-
- }
-
- function NetMgtCleanup
- {
- /usr/sbin/nwcm -q -snwum=off
- }
-
- function RestoreOriginalDrivers
- {
- #
- # If we had saved a copy of the old sfd driver, then reinstall it
- #
- if [ -d ${PKGSAV}/sfd_backup ] ; then
- #We had saved the old SFD driver
- CWD=${PKGSAV}/sfd_backup
- cd ${CWD}
- #Install the old driver
- echo "/etc/conf/bin/idinstall -M sfd"
- /etc/conf/bin/idinstall -M sfd
- if [ $? -eq 0 ] ; then
- #Rebuild the kernel
- echo "/etc/conf/bin/idbuild -M sfd"
- /etc/conf/bin/idbuild -M sfd
- fi
- cd /
- rm -rf ${CWD}
- fi
- }
-
- function RemoveScoAdmin
- {
- #
- # Remove SCOadmin stuff
- #
- /usr/bin/scoadmin -p NetWare -d /usr/lib/scoadmin/NetWare/NWVolume_Setup.obj
- /usr/bin/scoadmin -p NetWare -d /usr/lib/scoadmin/NetWare/NWS_Status.obj
- /usr/bin/scoadmin -p NetWare -d /usr/lib/scoadmin/NetWare/NWS_Licensing.obj
- /usr/bin/scoadmin -p NetWare -d /usr/lib/scoadmin/NetWare/dsinstall.obj
- /usr/bin/scoadmin -p NetWare -d /usr/lib/scoadmin/NetWare/dsrepair.obj
- }
-
- ProtocolStackCleanup
- RestoreOriginalDrivers
- NWSCleanup
- TFMCleanup
- NetMgtCleanup
- RemoveScoAdmin
-
- exit 0
-