#! /bin/sh # This script restores updated editable files to # their original state upon patch removal. # MV=/usr/bin/mv PKGCOND=/usr/bin/pkgcond # If ROOTDIR = "/", we want to prevent the beginning of the absolute path # name from being assigned "// instead of "/" in the restore_file function. if [ "$ROOTDIR" = "/" ]; then rootdir="" else rootdir=$ROOTDIR fi restore_file () { efile_list="etc/system" for efile in $efile_list ; do if [ -f $rootdir/$efile ] && [ -f $rootdir/$efile.$PatchNum ] then ${MV} $rootdir/$efile.$PatchNum $rootdir/$efile elif [ ! -f $rootdir/$efile.$PatchNum ] && [ ! -f $rootdir/$efile ] then # neither backup nor original are present. ignore return elif [ ! -f $rootdir/$efile.$PatchNum ] && [ -f $rootdir/$efile ] then cat << ENDCAT Backup file $rootdir/$efile.$PatchNum appears to have been removed. Unable to restore original $rootdir/$efile file. ENDCAT # return fi done } ExecuteALLCmds() { restore_file return 0 } determine_pkgcond () { if $PKGCOND is_whole_root_nonglobal_zone > /dev/null 2>&1 ; then # Execute non-global whole root zone commands. # Should be same action as the default action. return 0 fi if $PKGCOND is_nonglobal_zone > /dev/null 2>&1 ; then # Execute non-global zone commands. Should be no action here return 0 fi if $PKGCOND is_netinstall_image > /dev/null 2>&1 ; then # Execute commands applicable to patching the mini-root. # There are usually no actions to take here since your patching # the mini-root on an install server. return 0 fi if $PKGCOND is_mounted_miniroot > /dev/null 2>&1 ; then # Execute commands specific to the mini-root ExecuteALLCmds return 0 fi if $PKGCOND is_diskless_client > /dev/null 2>&1 ; then # Execute commands specific to diskless client return 0 fi if $PKGCOND is_alternative_root > /dev/null 2>&1 ; then # Execute commands specific to an alternate root return 0 fi if $PKGCOND is_global_zone > /dev/null 2>&1 ; then # In a global zone and system is mounted on /. # Execute all commands. return 0 fi } # Main ZONENAME=global [ -x /sbin/zonename ] && ZONENAME=`/sbin/zonename` if [ -x $PKGCOND ] ; then determine_pkgcond && exit 0 || exit 1 else CheckZones if [ "${GLOBAL_ZONE}" = "true" ]; then ExecuteALLCmds else LocalZones fi fi exit 0