#!/bin/sh # # This is a shell archive. To extract its contents, # execute this file with /bin/sh to create the file(s): # # deinstall.sh # # This shell archive created: Wed Feb 16 09:26:26 CST 2000 # echo "Extracting file deinstall.sh" sed -e 's/^X//' <<\SHAR_EOF > deinstall.sh X#!/bin/sh X################################################################################ X# X# deinstall.sh X# ============ X# X# Author: mailto:markus.holzbauer@mch.siemens.de X# (C) 2000 X# X# - Deinstall informix products. X# - Must be started as "root". X# - Tested on LINUX, SGI IRIX and SUN SOLARIS (not Reliant UNIX: use pkgrm) X# X# Notes: X# ------ X# - User changed configuration-files (e.g.: "$INFORMIXDIR/etc/sqlhosts" ) X# will be removed without warnings. X# - The script DO NOT remove $INFORMIXDIR and DO NOT remove X# "informix" in "/etc/passwd", "/etc/shadow" and "/etc/group" X# X################################################################################ X Xif [ "X$DEBUG" = "X1" ] Xthen X set -x Xfi X Xecho Xecho Xecho "Deinstallation Script" Xecho Xecho "This deinstallation procedure must be run by root (super-user)." Xecho "It will remove all files of a selected package in this directory." Xecho X Xecho "deinstall" > __deinstall__ Xchown root __deinstall__ 2> /dev/null X Xif [ "$?" -ne "0" ] Xthen X echo X echo "Please rerun this installation procedure as super-user." X rm __deinstall__ X exit 1 Xfi X Xchmod 4755 __deinstall__ 2> /dev/null X Xif [ "$?" -ne "0" ] Xthen X echo X echo "Please rerun this installation procedure as super-user." X rm __deinstall__ X exit 1 Xfi X Xrm __deinstall__ X Xecho Xecho "Press RETURN to continue," Xecho "or the interrupt key (usually CTRL-C or DEL) to abort." Xecho X Xread I X X# X# Check INFORMIXDIR is set, and we're in it X# X Xif [ "X$INFORMIXDIR" = "X" ] Xthen X echo "INFORMIXDIR is not set." X exit 1 Xfi X Xif [ "$INFORMIXDIR" != `pwd` ] Xthen X echo "INFORMIXDIR and working directory do not match." X echo "INFORMIXDIR is set to $INFORMIXDIR" X echo "Current working directory is `pwd`" X exit 1 Xfi X X# X# Get product names X# Xgrep "^PRODUCT" etc/*files > __products__ XN=1 Xecho Xecho "Please choose which package you wish to DEINSTALL." Xecho X Xwhile read keywd PRODUCT Xdo X echo "($N) - $PRODUCT" X N=`expr $N + 1` Xdone < __products__ XRET=`echo $?` X X# X# Since above while loop is executed in subshell, need to exit script if X# there were any errors. X# Xif [ "$RET" -ne "0" ] Xthen X rm __products__ X exit 1 Xfi X Xecho Xread P X XNR_PRODUCTS=`ls -1 etc/*files|awk 'END{print NR}'` XFILELIST=`ls etc/*files|awk '{if(NR=='"$P"'){print}}'` XPRODUCT=`grep "^PRODUCT" $FILELIST|awk '{print substr($0,9)}'` X X# X# Quit if selection is wrong X# Xif [ "$P" -lt "1" -o "$P" -gt "$NR_PRODUCTS" ] Xthen X echo X echo "No packages choosed. Deinstallation complete." X exit 0 Xfi X X# X# last chance to stop... X# Xecho Xecho "Deinstalling '$PRODUCT' ..." Xecho Xecho Xecho "Press RETURN to continue," Xecho "or the interrupt key (usually CTRL-C or DEL) to abort." Xecho X Xread I X# X# save the 'etc/...files' filelist X# X XFLIST=`echo "$FILELIST"|awk 'BEGIN{FS="/"}{print $2}'` Xcp $FILELIST __"$FLIST"__ Xrm $FILELIST XFILELIST=`find etc -type f -name "*files" -print` X X# X# delete the files (and links) X# Xwhile read NAM OWN GRP MOD FLG FLG2 Xdo X case $NAM in X \#* | "" | " "* | " "* | DISK* ) X continue X ;; X NAME* ) X continue X ;; X PRODUCT* ) X continue X ;; X esac X X if [ -f "$NAM" ] X then X if [ "$NR_PRODUCTS" -gt "1" -a -n "$FILELIST" ] X then X NR_FILES=`grep "^$NAM" $FILELIST|awk 'END{print NR}'` X X if [ "$NR_FILES" -eq "0" ] X then X rm $NAM X X case $FLG in X SHARELIB | LINK | ELINK ) X if [ -f "$FLG2" -o -h "$FLG2" ] X then X rm $FLG2 X fi X ;; X esac X fi X else X rm $NAM X X case $FLG in X SHARELIB | LINK | ELINK ) X if [ -f "$FLG2" -o -h "$FLG2" ] X then X rm $FLG2 X fi X ;; X esac X fi X fi X X if [ -d "$NAM" -a "$NAM" != "." ] X then X echo "$NAM" >> __directories__ X fi X X if [ -h "$NAM" ] X then X if [ "$NR_PRODUCTS" -gt "1" -a -n "$FILELIST" ] X then X NR_FILES=`grep "^$NAM" $FILELIST|awk 'END{print NR}'` X X if [ "$NR_FILES" -eq "0" ] X then X rm $NAM X X case $FLG in X SHARELIB | LINK | ELINK ) X if [ -f "$FLG2" -o -h "$FLG2" ] X then X rm $FLG2 X fi X ;; X esac X fi X else X rm $NAM X X case $FLG in X SHARELIB | LINK | ELINK ) X if [ -f "$FLG2" -o -h "$FLG2" ] X then X rm $FLG2 X fi X ;; X esac X fi X fi Xdone < __"$FLIST"__ XRET=`echo $?` X Xrm __"$FLIST"__ X X# X# Since above while loop is executed in subshell, need to exit script if X# there were any errors. X# Xif [ "$RET" -ne "0" ] Xthen X rm __products__ X exit 1 Xfi X X# X# sort the directory list X# Xcat __directories__|sort -r > __dirs__ Xrm __directories__ X X# X# remove product name and serial number in etc/.snfile and remove it X# if the file is empty X# Xif [ -f "etc/.snfile" ] Xthen X if [ -s "etc/.snfile" ] X then X cat etc/.snfile|awk '!/^'"$PRODUCT"'/{print}' > __snfile__ X X if [ ! -s "__snfile__" ] X then X rm etc/.snfile X else X cp __snfile__ etc/.snfile X fi X X rm __snfile__ X fi Xfi X X# X# remove the directories (if we can) X# Xwhile read NAM Xdo X if [ -d "$NAM" ] X then X RET=0 X echo "Removing directory $NAM" X X if [ "$NR_PRODUCTS" -gt "1" -a -n "$FILELIST" ] X then X NR_DIRS=`grep "^$NAM" $FILELIST|awk 'END{print NR}'` X X if [ "$NR_DIRS" -eq "0" ] X then X rmdir $NAM 2>/dev/null X RET=`echo $?` X fi X else X rm $NAM 2>/dev/null X RET=`echo $?` X fi X X if [ "$RET" -ne "0" ] X then X echo "Cannot remove '$NAM' - directory not empty." X fi X fi Xdone < __dirs__ XRET=`echo $?` X Xrm __dirs__ Xrm __products__ X X# X# Since above while loop is executed in subshell, need to exit script if X# there were any errors. X# Xif [ "$RET" -ne "0" ] Xthen X exit 1 Xfi X Xecho Xecho "Deinstallation of '$PRODUCT' complete." Xexit 0 SHAR_EOF if [ `wc -c < deinstall.sh` -ne 5487 ] then echo "Lengths do not match -- Bad Copy of deinstall.sh" fi echo "Done." exit 0