2 XCOMM $XConsortium: dinstall.dt.src /main/6 1996/04/23 11:18:22 drk $
4 XCOMM ==========================================================================
5 XCOMM ==========================================================================
8 XCOMM Script to deinstall the April 1994 Snapshot Desktop on
9 XCOMM HP, IBM, Sun, Fujitsu, or Novell Unix systems from a CDROM
11 XCOMM ==========================================================================
12 XCOMM ==========================================================================
16 XCOMM ==========================================================================
18 XCOMM DtiClearScreen - clears the screen
23 XCOMM ==========================================================================
34 XCOMM ==========================================================================
36 XCOMM Log - echo to log
39 XCOMM $1 - data to echo to log
42 XCOMM ==========================================================================
46 printf "$1" $2 $3 $4 $5 >> $LOG_FILE
49 XCOMM ==========================================================================
51 XCOMM DtiPrint - echo to stderr and log
54 XCOMM $1 - data to echo to stdout
57 XCOMM ==========================================================================
61 printf "$1" $2 $3 $4 $5 $6 $7 $8 $9 >&2
62 Log "$1" $2 $3 $4 $5 $6 $7 $8 $9
65 XCOMM ==========================================================================
67 XCOMM DtiShow - echo to stdout
70 XCOMM $1 - data to echo to stdout
73 XCOMM ==========================================================================
77 printf "$1" $2 $3 $4 $5 $6 $7 $8 $9 >&2
81 XCOMM ==========================================================================
83 XCOMM DtiReturn - return a string to stdout
86 XCOMM $1 - data to return
89 XCOMM ==========================================================================
98 XCOMM ==========================================================================
105 XCOMM result of system 'whoami' command
107 XCOMM ==========================================================================
115 XCOMM ==========================================================================
117 XCOMM Exit - log and exit
120 XCOMM $1 - data to echo to log
123 XCOMM ==========================================================================
127 Log "\n==================================================================\n"
128 Log "* $(date) $($WHOAMI_PATH/whoami)@$(hostname)*"
130 Log "\n*exit_code = $2*"
131 Log "\n==================================================================\n"
136 XCOMM ==========================================================================
149 XCOMM ==========================================================================
153 if [ -z "$getPlatform" ]; then
156 *HP-UX*) getPlatform=hp;;
157 *AIX*) getPlatform=ibm;;
158 *SunOS*) getPlatform=sun;;
159 *UNIX_System_V*) getPlatform=uxp;;
160 *UNIX_SV*) getPlatform=usl;;
161 *OSF1*) getPlatform=dec;;
164 DtiReturn $getPlatform
169 XCOMM ==========================================================================
171 XCOMM ValidOS - Verify OS is valid to deinstall on
174 XCOMM Output - Error message if invalid platform, will exit.
182 XCOMM ==========================================================================
186 platform=$(GetPlatform)
188 hp|ibm|sun|uxp|usl|dec)
191 *) Exit $INVALID_OS_MSG 1
197 XCOMM ==========================================================================
199 XCOMM ResolvePathName
201 XCOMM Input - File Name to be resolved to actual file
204 XCOMM Actual File Name resolved down to through all links
206 XCOMM ==========================================================================
208 if [ "/" = "$1" ]; then
211 ResolvePathName `/bin/ls -l $1 | awk '{print $NF}'` $2
213 ResolvePathName `dirname $1` `basename $1`${2+/}$2
218 XCOMM ==========================================================================
222 XCOMM Input - File Name
225 XCOMM TRUE, if file is a link
226 XCOMM FALSE, if file is not a link
227 XCOMM ==========================================================================
229 if [[ -L $1 ]] && [[ -a $1 ]]
239 XCOMM ==========================================================================
241 XCOMM StateObjective - States the objective of the Script to the user
246 XCOMM ==========================================================================
251 XCOMM Display information to the user, ask if user wishes to continue
256 DtiShow "$HERALD_MSG"
257 DtiPrint "$OBJECTIVE_MSG"
258 DtiPrint "$YESNO_MSG"
277 XCOMM ==========================================================================
279 XCOMM DoFilesetScript - Runs a unconfiguration script in the post_install dirs
284 XCOMM ==========================================================================
291 HASH Check for the lowercase PLATFORM dir. If doesn't exist then
292 HASH the tree is in uppercase.
294 if [ ! -f $TAR_TREE/dt.pkg ];
296 typeset -u ScriptName
300 if [ "$BUILD_TREE" = "" ]
307 test_string=${DATABASE_FILES#*$FilesetName}
308 if (( ${#DATABASE_FILES} > ${#test_string} ))
310 if [ -x $POST_INSTALL_DIR/$PLATFORM_SCRIPT_DIR/$ScriptName ]
312 DtiPrint "\n\nExecuting $PLATFORM specific $FilesetName unconfigure script...\n"
313 $POST_INSTALL_DIR/$PLATFORM_SCRIPT_DIR/$ScriptName -d 2>&1 | \
315 elif [ -x $POST_INSTALL_DIR/$ScriptName ]
317 DtiPrint "\n\nExecuting $FilesetName unconfigure script...\n"
318 $POST_INSTALL_DIR/$ScriptName -d 2>&1 | tee -a $LOG_FILE
324 XCOMM ==========================================================================
326 XCOMM RunUnconfigScripts - Runs relevant unconfiguration scripts, based on
327 XCOMM fileset installed, calls DoFilesetScript
331 XCOMM ==========================================================================
334 DtiPrint "\n\nRunning unconfigure scripts...\n"
336 DoFilesetScript CDE-TT configTT tt.cfg
337 DoFilesetScript CDE-MIN configMin min.cfg
338 DoFilesetScript CDE-RUN configRun run.cfg
339 DoFilesetScript CDE-HELP configHelp help.cfg
340 DoFilesetScript CDE-HELP-PRG configHelpPrg helpprg.cfg
341 DoFilesetScript CDE-HELP-RUN configHelpRun helprun.cfg
342 DoFilesetScript CDE-SHLIBS configShlibs shlibs.cfg
343 DoFilesetScript CDE-AB configAb ab.cfg
344 DoFilesetScript CDE-DEMOS configDemos demos.cfg
345 DoFilesetScript CDE-ICONS configIcons icons.cfg
346 DoFilesetScript CDE-INC configInc inc.cfg
347 DoFilesetScript CDE-MAN configMan man.cfg
348 DoFilesetScript CDE-MAN-DEV configManDev mandev.cvg
349 DoFilesetScript CDE-MSG-CAT configMsgCat msgcat.cfg
350 DoFilesetScript CDE-PRG configPrg prg.cfg
355 XCOMM ==========================================================================
357 XCOMM ValidConfiguration - Checks to see if the desktop was installed or
358 XCOMM partially installed on your system
362 XCOMM Return - TRUE, if valid configuration
363 XCOMM FALSE, for no desktop was found on the system
365 XCOMM ==========================================================================
366 ValidConfiguration() {
367 if (( [[ -a $ABSOLUTE_USR_LOCATION ]] || [[ -a $DEFAULT_USR_LOCATION ]] ) &&
368 ( [[ -a $ABSOLUTE_ETC_LOCATION ]] || [[ -a $DEFAULT_ETC_LOCATION ]] ) &&
369 ( [[ -a $ABSOLUTE_VAR_LOCATION ]] || [[ -a $DEFAULT_VAR_LOCATION ]] ))
375 for i in $ABSOLUTE_USR_LOCATION $ABSOLUTE_ETC_LOCATION \
376 $ABSLOUTE_VAR_LOCATION $DEFAULT_USR_LOCATION \
377 $DEFAULT_ETC_LOCATION $DEFAULT_VAR_LOCATION
391 XCOMM ==========================================================================
393 XCOMM DisplayDirs - Determines if directories should be presented
394 XCOMM to the user to determin if they will be deleted or not.
399 XCOMM Return - TRUE, if some directories will be deleted
400 XCOMM FALSE, if NO directories will be deleted
402 XCOMM ==========================================================================
404 if [[ -d $ABSOLUTE_USR_LOCATION ]] && [[ -a $ABSOLUTE_USR_LOCATION ]]
407 elif [[ -d $ABSOLUTE_ETC_LOCATION ]] && [[ -a $ABSOLUTE_ETC_LOCATION ]]
411 [[ -d $ABSOLUTE_VAR_LOCATION ]] && [[ -a $ABSOLUTE_VAR_LOCATION ]]
421 XCOMM ==========================================================================
423 XCOMM DisplayDirs - Determines if links should be presented
424 XCOMM to the user to determine if they will be deleted or not.
429 XCOMM Return - TRUE, if some links will be deleted
430 XCOMM FALSE, if NO links will be deleted
432 XCOMM ==========================================================================
434 if [[ -L $DEFAULT_USR_LOCATION ]] && [[ -a $DEFAULT_USR_LOCATION ]]
437 elif [[ -L $DEFAULT_ETC_LOCATION ]] && [[ -a $DEFAULT_ETC_LOCATION ]]
441 [[ -L $DEFAULT_VAR_LOCATION ]] && [[ -a $DEFAULT_VAR_LOCATION ]]
450 XCOMM ==========================================================================
452 XCOMM ShowDirsToBeDeleted - Shows what dirs and links will be deleted to the user
457 XCOMM ==========================================================================
460 ShowDirsToBeDeleted() {
462 XCOMM Display information to the user, ask if user wishes to continue
467 DtiShow "$HERALD_MSG"
469 if [ $(DisplayDirs) = "TRUE" ]
471 DtiPrint "$DELETE_DIRS_MSG"
472 if [ -a $ABSOLUTE_USR_LOCATION ]
474 DtiPrint "$DIR_MSG" "$ABSOLUTE_USR_LOCATION"
477 if [ -a $ABSOLUTE_ETC_LOCATION ]
479 DtiPrint "$DIR_MSG" "$ABSOLUTE_ETC_LOCATION"
482 if [ -a $ABSOLUTE_VAR_LOCATION ]
484 DtiPrint "$DIR_MSG" "$ABSOLUTE_VAR_LOCATION"
488 if [ $(DisplayLinks) = "TRUE" ]
490 DtiPrint "\n\n$DELETE_LINKS_MSG"
491 if [ $(FileIsLink $DEFAULT_USR_LOCATION) = "TRUE" ]
493 DtiPrint "$LINK_DIR_MSG" "$DEFAULT_USR_LOCATION"
496 if [ $(FileIsLink $DEFAULT_ETC_LOCATION) = "TRUE" ]
498 DtiPrint "$LINK_DIR_MSG" "$DEFAULT_ETC_LOCATION"
501 if [ $(FileIsLink $DEFAULT_VAR_LOCATION) = "TRUE" ]
503 DtiPrint "$LINK_DIR_MSG" "$DEFAULT_VAR_LOCATION"
507 DtiPrint "\n\n$WARNING_MSG"
508 DtiPrint "\n\n\n$YESNO_MSG"
528 XCOMM ==========================================================================
530 XCOMM StopDesktop - Stops the desktop if it was running
535 XCOMM ==========================================================================
538 if [ -f $ABSOLUTE_VAR_LOCATION/Xpid ]
540 DtiPrint "\n\nStopping Desktop... \n"
541 kill -TERM `cat $ABSOLUTE_VAR_LOCATION/Xpid` 2> /dev/null
546 XCOMM ==========================================================================
548 XCOMM RemoveDesktop - Deletes Desktop files from the system
553 XCOMM ==========================================================================
557 DtiPrint "Removing files from Desktop Directories...\n"
558 rm -rf $ABSOLUTE_USR_LOCATION
559 rm -rf $ABSOLUTE_ETC_LOCATION
560 rm -rf $ABSOLUTE_VAR_LOCATION
562 rm -rf $DEFAULT_USR_LOCATION
563 rm -rf $DEFAULT_ETC_LOCATION
564 rm -rf $DEFAULT_VAR_LOCATION
565 DtiPrint "The Desktop was successfully removed from your system.\n"
570 XCOMM ==========================================================================
573 XCOMM This is the MAIN of the script
576 XCOMM ==========================================================================
578 XCOMM Set up Messages
580 Usage: deinstall.dt [-noprompt]\n"
583 You must be ROOT to run this command\n"
589 The Common Open Systems Environment Desktop\n\
590 April 1994 Snapshot Deinstallation Procedure\n\n"
593 This procedure will REMOVE the Desktop from your system.\n\n\n"
596 Do you wish to continue? [y/n] "
599 The deinstallation will remove files from the following\n\
600 directories listed below:\n\n"
606 The deinstallation will remove the following symbolic \n\
607 link(s) listed below:\n\n"
613 Any customizations made will be LOST!\n"
621 The Desktop does not support this system configuration.\n\
622 The deinstallation procedure will terminate.\n"
624 INVALID_CONFIGURATION_MSG="\
625 The deinstallation procedure could not locate any Desktop files\n\
626 on your system. The deinstallation will terminate. Please check\n\
627 that you are running the deinstallation script on a system that\n\
628 has the Desktop already installed.\n"
635 XCOMM Set up variables
638 DEFAULT_USR_LOCATION="/usr/dt"
639 DEFAULT_ETC_LOCATION="/etc/dt"
640 DEFAULT_VAR_LOCATION="/var/dt"
642 ABSOLUTE_USR_LOCATION=$(ResolvePathName $DEFAULT_USR_LOCATION)
643 ABSOLUTE_ETC_LOCATION=$(ResolvePathName $DEFAULT_ETC_LOCATION)
644 ABSOLUTE_VAR_LOCATION=$(ResolvePathName $DEFAULT_VAR_LOCATION)
647 XCOMM Set up the log file
648 LOG_FILE="/tmp/dinstall.dt.log"
651 rm -rf $LOG_FILE 2>/dev/null
653 touch $LOG_FILE 2>/dev/null
654 chmod 777 $LOG_FILE 2>/dev/null
659 XCOMM change directories to deinstall.dt location as all
660 XCOMM installation packages are relative to this
662 if [ ${0%/STAR} != "dinstall.dt" ]; then
667 XCOMM set up the TOP directory of where the CD is mounted
671 XCOMM set up the path for whoami command
673 platform=$(GetPlatform)
675 hp) WHOAMI_PATH=/usr/bin
677 ibm) WHOAMI_PATH=/bin
679 sun) WHOAMI_PATH=/usr/ucb
681 uxp) WHOAMI_PATH=/usr/ucb
683 usl) WHOAMI_PATH=/usr/ucb
685 dec) WHOAMI_PATH=/usr/bin
689 DTIDINSTALLDT=dinstall.dt
691 dtiPlatform=$(GetPlatform)
692 DTIPLATFORMDIR=$dtiPlatform
693 DTIREADME=config/config.$dtiPlatform
695 if [ ${0##STAR/} != $DTIDINSTALLDT ]; then
697 HASH CDROM driver folds filenames to uppercase
699 typeset -u DTIDINSTALLDT
700 typeset -u DTICONFIGDIR
701 typeset -u DTIPLATFORMDIR
706 XCOMM Parse the command line
710 -noprompt) NO_PROMPT=TRUE
711 print "NO_PROMPT is set"
714 *) print "$USAGE_MSG"
721 XCOMM Verify that we have the Root User
722 if [ $(DtiWhoami) != "root" ]
724 DtiShow "$PERMISSION_MSG"
725 Exit "$PERMISSION_MSG" 1
728 XCOMM Check to see if the Desktop is actually installed on the system
729 if [ $(ValidConfiguration ) != "TRUE" ]
731 DtiPrint "$INVALID_CONFIGURATION_MSG"
735 XCOMM Determine if the OS is supported
739 XCOMM Initially PLATFORM is in lower case.
740 XCOMM Check if the $PLATFORM directory exists.
741 XCOMM if doesn't exist translate all to upper case.
746 TAR_TREE=$TOP/$PLATFORM
747 POST_INSTALL_DIR=$TAR_TREE/config
748 DATABASE_FILES=$(awk 'BEGIN {FS=":"} /FILESETS: /{print $2}' $TAR_TREE/dt.pkg 2>/dev/null)
750 PLATFORM=`echo "$PLATFORM" | /usr/bin/tr "[a-z]" "[A-Z]"`
751 TAR_TREE=$TOP/$PLATFORM
752 POST_INSTALL_DIR=$TAR_TREE/CONFIG
753 DATABASE_FILES=$(awk 'BEGIN {FS=":"} /FILESETS: /{print $2}' $TAR_TREE/DT.PKG 2>/dev/null)
757 XCOMM Tell the user what is going to happen
758 if [ $NO_PROMPT = FALSE ]
763 XCOMM Show the user what directories are going to be deleted
764 if [ $NO_PROMPT = FALSE ]
770 XCOMM Stop the Desktop
773 XCOMM Run the Unconfigure Scripts
776 XCOMM Remove the Desktop Files