#!/sbin/sh
#Tag 0x00000f00

# The software installation will leave a message, and versions will give
# a zero exit status, if installation has altered one or more configuration
# files.  Print the message, which is a reminder to the user to go find
# them and resolve the differences.
#
# Also search for directories that have been moved aside due to the
# filesystem re-org, and inform the user about such.
#
# Also rebuild the man page database for whatis/apropos after anything
# installed or removed.

MSG=/var/inst/.config_changed
MSGTIMER=/var/inst/.change_cnt
LIMIT=13

# rebuild the man page apropos/whatis database after an install
if [ ! -r /usr/share/catman/whatis -o \
	"`find /var/inst/hist -newer /usr/share/catman/whatis -print 2>/dev/null`" = /var/inst/hist  ]
then
	npri -h 85 /usr/lib/makewhatis 2>&1 | logger -t makewhatis &
fi

#  Check for configuration file changes
if test ! -r $MSG -o ! -x /usr/sbin/versions
then exit 0 # don't check for dirs either, if versions isn't there.
	# or we have already resolved config files and removed $MSG
fi

cnt=`cat $MSGTIMER 2>/dev/null`
cnt=`expr ${cnt:=0} + 1`
echo $cnt > $MSGTIMER 2>/dev/null
if test $cnt -le $LIMIT && /usr/sbin/versions -t changed>/tmp/x; then
	logger -s -t inst -f $MSG
	if chkconfig visuallogin; then
		# give user a chance to see the message before pandora
		sleep 5
	fi
else
	rm -f $MSG $MSGTIMER
	exit 0 # that's enough times to check for directories also
fi

# Check for moved-aside directories.
BANNERPRINT=0
  DIRS='
/usr/Cadmin/classes.O
/usr/CaseVision.O
/usr/Insight/lib/data/config/C.O
/usr/Insight/lib/data/entities.O
/usr/Insight/library/SGI_bookshelves/SGI_Admin/books/SiteAdmin/styles.O
/usr/Insight/library/SGI_bookshelves/SGI_EndUser/books/IRISEssentials/styles.O
/usr/Insight/library/SGI_bookshelves/SGI_EndUser/books/PerSysAdmin/styles.O
/usr/Insight/library/SGI_bookshelves/SGI_EndUser/books/ShowcaseUG/styles.O
/usr/Insight/library/SGI_bookshelves/SGI_EndUser/books/Utilities/styles.O
/usr/Insight/library/SGI_bookshelves/SGI_EndUser/books/glossary/styles.O
/usr/WorkShop.O
/usr/adm.O
/usr/catman/u_man/cat1/explorer.O
/usr/demos/bin.O
/usr/diags/crash/Sproc.O
/usr/etc/boot.O
/usr/etc/dn.O
/usr/etc/named.d.O
/usr/etc/yp.O
/usr/frame/.fminit2.0.O
/usr/frame/docs.O
/usr/frame/fmtemplates.O
/usr/gfx/CLOVER2/lib/IP7GT.O
/usr/gfx/libgl/EXPRESSEXPRESS/libGL.so.O
/usr/gfx/libgl/EXPRESSEXPRESS/libGLcore.so.O
/usr/gfx/libgl/LIGHTLG1MC.O
/usr/gfx/libgl/LIGHTLIGHT.O
/usr/gfx/ucode/SKYWR/vof.O
/usr/gfx/ucode/VGX/vof.O
/usr/include/DPS.O
/usr/include/Mrm.O
/usr/include/NCC.O
/usr/include/Vk.O
/usr/include/X11/Mrm.O
/usr/include/X11/Xirisw.O
/usr/include/X11/Xm.O
/usr/include/X11/uil.O
/usr/include/Xm.O
/usr/include/make.O
/usr/include/oz.O
/usr/include/uil.O
/usr/lib/DPS/AFM.O
/usr/lib/DPS/outline/base.O
/usr/lib/Insight.O
/usr/lib/TeamVision.O
/usr/lib/X11.O
/usr/lib/X11/Schemes.O
/usr/lib/X11/app-defaults/XClipboard.O
/usr/lib/X11/app-defaults/Xmh.O
/usr/lib/X11/ja_JP.EUC/schemes/Base.O
/usr/lib/X11/schemes/Base.O
/usr/lib/X11/schemes/FaxMgr.O
/usr/lib/X11/schemes/Lascaux.O
/usr/lib/cron.O
/usr/lib/dict.O
/usr/lib/font/devX100.O
/usr/lib/images.O
/usr/lib/locale/de_AT/LC_MESSAGES.O
/usr/lib/locale/de_CH/LC_MESSAGES.O
/usr/lib/locale/fr_BE/LC_MESSAGES.O
/usr/lib/locale/fr_CA/LC_MESSAGES.O
/usr/lib/locale/fr_CH/LC_MESSAGES.O
/usr/lib/onlineHelp.O
/usr/lib/onlineHelp/CaseVision.O
/usr/lib/sounds.O
/usr/lib/terminfo.O
/usr/lib/tmac.O
/usr/lib/wnn/dic.O
/usr/mail.O
/usr/preserve.O
/usr/relnotes/motif_dev.O
/usr/relnotes/motif_eoe.O
/usr/sbin/r4kpp.O
/usr/spool.O
/usr/sysgen.O
/usr/sysgen/system.O
/usr/tmp.O
/usr/var/X11/input.O
/usr/var/adm/lastlog.O
/usr/var/config.O
/usr/var/inst.O
/usr/var/mail.O
/usr/var/sna/log.O
/usr/var/spool.O
/usr/var/spool/mqueue.O
/usr/var/sysgen/boot.O
/usr/var/sysgen/root.O
/usr/var/tmp.O
'

for dir in $DIRS; do
  if test -d $dir; then
    # grumble.  These dirs are unlikely to hold user modified info.  If they did,
    # tough.  That's what backups are for.
    if test $dir = "/usr/include/X11/Mrm.O" -o \
      $dir = "/usr/include/X11/Xirisw.O" -o \
      $dir = "/usr/include/X11/Xm.O" -o \
      $dir = "/usr/include/X11/uil.O" -o \
      $dir = "/usr/lib/sounds.O" -o \
      $dir = "/usr/lib/terminfo.O" -o \
      $dir = "/usr/var/inst.O" -o \
      $dir = "/usr/diags/crash/Sproc.O" -o \
      $dir = "/usr/lib/cron.O" ; then
      rm -rf $dir
      continue
    fi
    if test $BANNERPRINT -ne 1; then
      logger -s -t inst "These directories were unable to be moved properly during the"
      logger -s -t inst "installation process.  Check for any user-modified files, then"
      logger -s -t inst "delete the directories."
      BANNERPRINT=1
    fi
    logger -s -t inst "   $dir"
  fi     
done
