home *** CD-ROM | disk | FTP | other *** search
- #ident "@(#)postremove 17.11 98/08/10"
- #copyright "%c%"
- #!/usr/bin/sh
-
- # Define variables for use
- BIN=/usr/bin
- TTY=/dev/tty
- PKGINST=${PKG}
- UPDINST=/var/sadm/pkg/${PKGINST}/install
- UPDLOGFILE=/var/sadm/install/logs/${PKGINST}.out
- UPDTMP=/tmp/${PKGINST}
- UPDMENUANS=${UPDTMP}/results
- UPDVARFILE=${1}
-
- export TTY UPDINST UPDTMP UPDMENUANS
-
- # Load RC Scripts
- . ${UPDINST}/updpkg.rc
-
- MenuLang
-
- #
- # Define trap and trap command for interruption (delete key)
- # of the Update Installation.
- #
- TrapCmd ()
- {
- MsgHandler 1 UpdIntrMsg
- RmExit 3
- }
- trap 'TrapCmd' 2 3 15
-
- #
- # Restore update backup from disk location
- #
- RestoreFromDisk ()
- {
- LogMsg "RestoreFromDisk: `GetText STARTED`"
- DbgMsg "RestoreFromDisk: STARTED"
-
- DbgMsg " RestoreFromDisk: display brmsg menu"
- MenuCmd regular brmsg
- DbgMsg " RestoreFromDisk: up ulimit to ${UPD_ULIMIT}"
- ulimit ${UPD_ULIMIT}
-
- #
- # Restore backup.
- #
- cd /
- ECPIO=${UPDTMP}/upd.cpio.err
- OCPIO=${UPDTMP}/upd.cpio.out
- DbgMsg " RestoreFromDisk: try to restore from ${UPDBKUPFILE}.Z or ${UPDBKUPFILE}"
- if [ -f ${UPDBKUPFILE}.Z ]
- then
- DbgMsg " RestoreFromDisk: run zcat/cpio on ${UPDBKUPFILE}.Z"
- ${BIN}/zcat ${UPDBKUPFILE} | \
- ${BIN}/cpio -icdmu >${OCPIO} 2>${ECPIO}
- else
- DbgMsg " RestoreFromDisk: run cpio on ${UPDBKUPFILE}.Z"
- ${BIN}/cpio -icdmu -I ${UPDBKUPFILE} >${OCPIO} 2>${ECPIO}
- fi
- rc=${?}
- DbgMsg " RestoreFromDisk: cpio completed"
-
- ${BIN}/grep "ERROR" ${ECPIO} >/dev/null 2>&1
- greprc=${?}
-
- if [ ${rc} -ne 0 -o ${greprc} -eq 0 ]
- then
- DbgMsg " RestoreFromDisk: error during cpio, cpio rc = ${rc}, grep rc = ${rc}"
- CPIOEFILES="${ECPIO}"
- export CPIOEFILES
- DbgMsg " RestoreFromDisk: display cperr menu"
- MenuCmd error cperr
- rc=1
- unset CPIOEFILES
- fi
- unset OCPIO ECPIO
-
- LogMsg "RestoreFromDisk: `GetText COMPLRET` - ${rc}"
- DbgMsg "RestoreFromDisk: completion return code - ${rc}"
- return ${rc}
- }
-
- #
- # Perform the restore the main control section.
- #
- RestoreMain ()
- {
- LogMsg "RestoreMain: `GetText STARTED`"
- DbgMsg "RestoreMain: STARTED"
-
- CPIOFILE=update.cpio
-
- # Get the number of Update Package Overlays performed.
- . ${UPDCNTFILE}
- LogMsg " RestoreMain: From ${UPDCNTFILE}, UPDCNT=${UPDCNT}"
-
- CNT=${UPDCNT}
- while [ ${CNT} -ge 0 ]
- do
- if [ ! -f ${UPDBKUPDIR}/bkup${CNT}/bkup.disk ]
- then
- # Display restore starting menu.
- LogMsg " RestoreMain: display rsmain menu"
- MenuCmd regular rsmain
- break
- fi
- CNT=`${BIN}/expr ${CNT} - 1`
- done
-
- CNT=${UPDCNT}
- while [ ${CNT} -ge 0 ]
- do
- DbgMsg " RestoreMain: try to restore part ${CNT}"
- UPDBACKUP=${UPDBKUPDIR}/bkup${CNT}
- UPDBKUPFILE=${UPDBACKUP}/${CPIOFILE}
- export UPDBACKUP UPDBKUPFILE
- DbgMsg " RestoreMain: UPDBACKUP=${UPDBACKUP}"
- DbgMsg " RestoreMain: UPDBKUPFILE=${UPDBKUPFILE}"
-
- DbgMsg " RestoreMain: restore from disk"
- DbgMsg " RestoreMain: exec RestoreFromDisk"
- RestoreFromDisk
- rc=${?}
- DbgMsg " RestoreMain: RestoreFromDisk rc = ${rc}"
- if [ ${rc} -ne 0 ]
- then
- LogMsg "RestoreMain: `GetText COMPLRET` - ${rc}"
- DbgMsg "RestoreMain: COMPLRET - ${rc}"
- return ${rc}
- fi
-
- # Process next backup.
- DbgMsg " RestoreMain: restore of part ${CNT} succeeded"
- CNT=`${BIN}/expr ${CNT} - 1`
- done
- DbgMsg " RestoreMain: All files restored"
-
- if [ -f ${UPDBACKUP}/bkup.disk ]
- then
- DbgMsg " RestoreMain: display brsucc menu"
- MenuCmd regular brsucc
- ${BIN}/sleep 3
- fi
-
- LogMsg "RestoreMain: `GetText COMPLRET` - 0"
- DbgMsg "RestoreMain: COMPLRET - 0"
- return 0
- }
-
- LogMsg "postremove: `GetText STARTED`"
- DbgMsg "postremove: STARTED"
-
- #
- # Create temporary work directory.
- #
- DbgMsg " postremove: remake dir UPDTMP = ${UPDTMP}"
- ${BIN}/rm -rf ${UPDTMP} 2> /dev/null
- ${BIN}/mkdir -p ${UPDTMP}
-
- UPD_INSTRM="${UPD_INSTRM_r}"
- UPD_instrm="${UPD_instrm_r}"
- UPD_INSTRMED="${UPD_INSTRMED_r}"
- UPD_BKUPREST="${UPD_BKUPREST_r}"
- export UPD_INSTRM UPD_instrm UPD_INSTRMED UPD_BKUPREST
- unset UPD_INSTRM_i UPD_instrm_i UPD_INSTRMED_i UPD_BKUPREST_i
- unset UPD_INSTRM_r UPD_instrm_r UPD_INSTRMED_r UPD_BKUPREST_r
- unset ProcMsg GenericProcMsg
- DbgMsg " UPD_INSTRM=${UPD_INSTRM}"
- DbgMsg " UPD_instrm=${UPD_instrm}"
- DbgMsg " UPD_INSTRMED=${UPD_INSTRMED}"
- DbgMsg " UPD_BKUPREST=${UPD_BKUPREST}"
-
- #
- # Perform the restore.
- #
- DbgMsg " postremove: exec RestoreMain"
- RestoreMain
- rc=${?}
- DbgMsg " postremove: Restore Main exited with rc = ${rc}"
- if [ ${rc} != 0 ]
- then
- LogMsg "postremove: `GetText RESFAIL`"
- DbgMsg " postremove: Restore Failed"
- menu_colors regular
- MenuClear
- LogMsg "postremove: `GetText COMPLEXIT` - ${1}\n"
- DbgMsg "postremove: exit with rc=1"
- RmExit 1
- fi
-
- #
- # Display working menu.
- #
- DbgMsg " UPD_POSTREMOVE_MSG=${UPD_POSTREMOVE_MSG}"
- DbgMsg " postremove: display working menu at 0%"
- WorkMenu "${UPD_POSTREMOVE_MSG}" 0
-
- #
- # Remove all marks about the updated packages.
- #
- ${BIN}/rm -f /var/sadm/pkg/*/${PKGINST} 2> /dev/null
-
- #
- # Prepare list of packages and their files for installf
- #
- ${BIN}/cat ${UPDBKUPDIR}/contents >${UPDTMP}/installf
-
- DbgMsg " postremove: display working menu at 5%"
- WorkMenu "" 5
-
- DbgMsg " postremove: display working menu at 10%"
- WorkMenu "" 10
-
- DbgMsg " postremove: display working menu at 15%"
- WorkMenu "" 15
-
- ########################################
- # Update 1 BL1 specific postremove code
- ########################################
-
-
- # ul98-16307 alexma (Xenix removal)
-
- # recreate hard links for Xenix restoration
- ln -f /usr/bin/xrestor /usr/bin/xrestore
- ln -f /usr/bin/touch /usr/bin/settime
- if `/bin/pkginfo usoftint >/dev/null 2>&1`
- then
- ln -f /usr/lib/libxtermlib.a /usr/lib/libxtermcap.a
- fi
- ln -f /usr/bin/.restore /usr/sbin/.restore
- ln -f /usr/bin/.restore /usr/bin/restore
- ln -f /usr/bin/.restore /usr/sbin/restore
- cp /sbin/.restore /sbin/restore
- ln -f /usr/bin/.backup /usr/sbin/.backup
- ln -f /usr/bin/.backup /usr/bin/backup
- ln -f /usr/bin/.backup /usr/sbin/backup
- #ln -s /etc/fs/XENIX/fsck /usr/lib/fs/XENIX/fsck
- #ln -s /etc/fs/XENIX/mount /usr/lib/fs/XENIX/mount
- #ln -s /usr/bin/dosdir /usr/bin/dosls
- #ln -s /usr/bin/dosrm /usr/bin/dosrmdir
- #ln -s /sbin/xinstall /usr/sbin/xinstall
- #ln -s /usr/bin/.restore /sbin/.restore
- #ln -s /usr/bin/.backup /sbin/.backup
- #ln -s /etc/Backup /usr/sbin/Backup
- #ln -s /etc/Ignore /usr/sbin/Ignore
-
- DbgMsg " postinstall: finished creating hard links for Xenix restoration"
-
- # ul98-16307 end
-
- # ul98-06811a0 kd (reverse postinstall actions)
- cp /sbin/rc1 /usr/sbin/rc1
- installf base /usr/sbin/rc1
- installf -f base
- DbgMsg "postinstall for ul98-06811a0 done"
- # ul98-06811a0 kd end
-
- # PTF7003 specific remove of the /etc/.snum file
- removef ${PKGINST} /etc/.snum > /dev/null 2>&1
- removef -f ${PKGINST} > /dev/null 2>&1
- # end PTF7003 specific removal
-
- # PTF7011 begin
- # The dlpi driver in /etc/inst/nd/dlpi has been replaced by the saved version
- # but now do the same for the driver in the link kit (assuming its been configured).
- [ -f /etc/conf/pack.d/dlpi/Driver.o ] && {
- cd /etc/inst/nd/dlpi
- if ${CONFBIN}/idinstall -u -k dlpi
- then
- DbgMsg "Restoring original dlpi driver into the linkkit"
- else
- DbgMsg "DLPI Driver restoration failed"
- fi
- }
- # PTF7011 end
-
- # ul98-11502a0 begin
- # The dlpibase driver in /etc/inst/nd/dlpibase has been replaced by the saved
- # version but now do the same for the driver in the link kit (assuming its
- # been configured).
-
- #echo
- #echo "Restoring the original dlpibase driver into the link kit..."
- #echo
- [ -f /etc/conf/pack.d/dlpibase/Driver_atup.o ] && {
- cd /etc/inst/nd/dlpibase
- if ${CONFBIN}/idinstall -u -k dlpibase
- then
- DbgMsg "Restoring original dlpibase driver into the linkkit"
- else
- DbgMsg "DLPIbase Driver restoration failed"
- fi
- }
- # ul98-11502a0 end
-
- ########################################
- # Update 1 BL2 specific postremove code
- ########################################
-
- # ul98-14106 anurags start
- # although the files have been deleted, deconfigure the hotplug object
- DbgMsg " postremove - ul98-14106:Removing the SCOadmin Hotplug object"
- /usr/bin/scoadmin -f -p Hardware -d hotplug.obj
- # ul98-14106 end
-
- # PTF7002 begin
- # restore the mpio depend file to its original state
- [ -f /var/sadm/pkg/mpio/install/depend ] && {
- sed "s/^P/R/" /var/sadm/pkg/mpio/install/depend > /var/sadm/pkg/mpio/install/depend_tmp
- sed '/^#/d' /var/sadm/pkg/mpio/install/depend_tmp > /var/sadm/pkg/mpio/install/depend
- rm /var/sadm/pkg/mpio/install/depend_tmp
- }
- # PTF7002 end
-
- # Update the LIBRARIES from /usr/lib/tmp and /usr/ccs/lib/tmp
- #
- for file in /usr/lib/tmp/* /usr/ccs/lib/tmp/*
- do
- if [ -f "${file}" ]
- then
- orig=`echo ${file} | ${BIN}/sed 's%/tmp/%/%'`
- DbgMsg " installing ${orig}"
- ${BIN}/mv -f ${file} ${orig} >/dev/null 2>&1
- rc=${?}
- DbgMsg " mv to lib rc=${rc}"
- fi
- done
- unset file orig rc
-
- ${BIN}/rm -rf /usr/lib/tmp /usr/ccs/lib/tmp >/dev/null 2>&1
-
- #
- # Strictly speaking, we should not make the link to libsocket.so.2
- # when restoring to UW2.1; but safest to leave that link lying around
- #
- ${BIN}/ln -f /usr/lib/libthread.so.1 /usr/lib/libthread.so >/dev/null 2>&1
- ${BIN}/ln -f /usr/lib/libthreadT.so.1 /usr/lib/libthreadT.so >/dev/null 2>&1
- ${BIN}/ln -f /usr/lib/libsocket.so /usr/lib/libsocket.so.1 >/dev/null 2>&1
- ${BIN}/ln -f /usr/lib/libsocket.so /usr/lib/libsocket.so.2 >/dev/null 2>&1
- ${BIN}/ln -f /usr/lib/libresolv.so /usr/lib/libresolv.so.2 >/dev/null 2>&1
- ${BIN}/ln -f /usr/lib/libc.so.1 /usr/lib/ld.so.1 >/dev/null 2>&1
-
-
- # ul98-05506 start
- # check for "crypt" package, re-create link back to original library.
- Ver=`grep "^VERSION=" /var/sadm/pkg/base/pkginfo | cut -f2 -d'='`
- if [ "${Ver}" = "7" ]
- then
- rm -f /usr/lib/libnsl_i.so > /dev/null 2>&1
- removef ${PKGINST} /usr/lib/libnsl_i.so > /dev/null 2>&1
- removef -f ${PKGINST} > /dev/null 2>&1
- else
- if `/bin/pkginfo crypt >/dev/null 2>&1`
- then
- ${BIN}/ln -f /usr/lib/libnsl_d.so /usr/lib/libnsl.so >/dev/null 2>&1
- DbgMsg " postremove libnsl"
- DbgMsg " link libnsl.so to libnsl_d.so "
- sumd=`/usr/bin/sum -r /usr/lib/libnsl_d.so`
- DbgMsg " sum of libnsl_d.so is ${sumd}"
- else
- ${BIN}/ln -f /usr/lib/libnsl_i.so /usr/lib/libnsl.so >/dev/null 2>&1
- DbgMsg " postremove libnsl"
- DbgMsg " link libnsl.so to libnsl_i.so "
- sumi=`/usr/bin/sum -r /usr/lib/libnsl_i.so`
- DbgMsg " sum of libnsl_i.so is ${sumi}"
- fi
- fi
- ${BIN}/ln -f /usr/lib/libnsl.so /usr/lib/libnsl.so.1 >/dev/null 2>&1
- installf base /usr/lib/libnsl.so.1=/usr/lib/libnsl.so l > /dev/null 2>&1
- installf -f base > /dev/null 2>&1
-
- # ul98-05506 end
-
- DbgMsg " postremove: old tmp files removed and new ones relinked"
-
-
- ########################################
- # Update 1 BL3 specific postremove code
- ########################################
-
- # fix acp links
- ${BIN}/ln -f /usr/bin/ls /usr/bin/lx >/dev/null 2>&1
- ${BIN}/ln -f /usr/bin/ls /usr/bin/l >/dev/null 2>&1
- ${BIN}/ln -f /usr/bin/ls /usr/bin/lc >/dev/null 2>&1
- ${BIN}/ln -f /usr/bin/ls /usr/bin/lf >/dev/null 2>&1
- ${BIN}/ln -f /usr/bin/ls /usr/bin/lr >/dev/null 2>&1
-
- # ul98-15517 rene fix to sdistatic
- sed '/pdi0/d' /etc/inittab > /tmp/inittab.new
- cp -f /tmp/inittab.new /etc/inittab
- chmod 444 /etc/inittab
- chown bin /etc/inittab
- chgrp bin /etc/inittab
- DbgMsg " postremove: sdistatic entry removed from /etc/inittab"
-
- # remove /etc/sdistatic entry from /etc/conf/init.d/kernel
- sed '/pdi0/d' /etc/conf/init.d/kernel > /tmp/kernel.new
- cp -f /tmp/kernel.new /etc/conf/init.d/kernel
- chmod 0644 /etc/conf/init.d/kernel
- chown root /etc/conf/init.d/kernel
- chgrp sys /etc/conf/init.d/kernel
- DbgMsg " postremove: sdistatic entry removed from /etc/conf/init.d/kernel"
- # ul98-15517 end
-
- ########################################
- # end Update specific postremove code
- ########################################
-
- DbgMsg " postremove: display working menu at 20%"
- WorkMenu "" 20
-
- DbgMsg " postremove: display working menu at 20%"
- WorkMenu "" 20
-
- #
- # Man Command postremove:
- # - restore /etc/default/man configuration file
- #
- if [ -f /etc/default/man.bak ]
- then
- mv /etc/default/man.bak /etc/default/man
- fi
-
- #
- # Mail postremove:
- # - restore sendmail.cf configuration
- # - restore mailx.rc configuration
- # - remove the sticky bit on /var/mail
- #
- if [ -f /etc/sendmail.cf.bak ]
- then
- # mv /etc/sendmail.cf.bak /etc/sendmail.cf
- # Changed "mv" to "cp" and "rm" to correct pkgadd ownership problem 8/3/09
- cp /etc/sendmail.cf.bak /etc/sendmail.cf
- rm -f /etc/sendmail.cf.bak
- fi
- if [ -f /etc/mail/mailx.rc.bak ]
- then
- # mv /etc/mail/mailx.rc.bak /etc/mail/mailx.rc
- # Changed "mv" to "cp" and "rm" to correct pkgadd ownership problem 8/1/09
- cp /etc/mail/mailx.rc.bak /etc/mail/mailx.rc
- rm -f /etc/mail/mailx.rc.bak
- fi
- chmod 777 /var/mail
-
- DbgMsg " postremove: display working menu at 25%"
- WorkMenu "" 25
-
- DbgMsg " postremove: display working menu at 30%"
- WorkMenu "" 30
-
- DbgMsg " postremove: display working menu at 35%"
- WorkMenu "" 35
-
- #
- # Restore original file information in the software
- # installation database.
- #
- pkglist=`${BIN}/cut -f1 -d' ' ${UPDTMP}/installf | ${BIN}/sort -u`
- DbgMsg " RestoreFileParameters: pkglist = ${pkglist}"
-
- step=0
- steps=`echo ${pkglist} | ${BIN}/wc -w`
-
- # Extract all file info for a given package for restoration
- # to the software installation database at once.
- for pkg in ${pkglist}
- do
- # Restore file parameters.
- DbgMsg " RestoreFileParameters: restoring for ${pkg}"
- ${BIN}/grep "^${pkg} " ${UPDTMP}/installf | \
- ${BIN}/sed -e "s/^${pkg} //" -e "s/ 4 NONE NONE//" | \
- ${BIN}/sort -u |
- ${USBIN}/installf ${pkg} - >/dev/null 2>&1
-
- # If installf fails, and $pkg is no longer installed,
- # then we ought to remove its files; but if $pkg is
- # somehow wrong, that would be dangerous: deferred.
-
- # Restore package.
- ${USBIN}/installf -f ${pkg} >/dev/null 2>&1
- DbgMsg " RestoreFileParameters: restored for ${pkg}"
-
- step=`${BIN}/expr $step + 1 2>/dev/null`
- gauge=`${BIN}/expr $step \* 60 / $steps + 35 2>/dev/null`
- [ "$gauge" -le 95 ] && WorkMenu "" "$gauge"
- done
-
- DbgMsg " postremove: display working menu at 95%"
- WorkMenu "" 95
-
- EXITRC=10 # please reboot
- > /etc/conf/.rebuild # idbuild on shutdown
-
- ${BIN}/rm -rf ${UPDBKUPDIR} >/dev/null 2>&1
-
- DbgMsg " postremove: Display working menu at 100%"
- WorkMenu "" 100
-
- ${BIN}/sleep 2
- MenuClear
-
- # Remove menu directory.
- DbgMsg " postremove: remove menu dir ${UPDMENUDIR}"
- ${BIN}/rm -rf ${UPDMENUDIR}
-
- LogMsg "postremove: `GetText COMPLEXIT` - ${EXITRC}"
- DbgMsg "postremove: completed with exit code - ${EXITRC}"
- RmExit ${EXITRC}
-