#!/bin/sh

# When this patch was added to the target system, the i.EtcDefLu class action
# script saved a copy of the original etc/default/lu file.  Upon the removal of
# this patch revision, the original source file needs to now be restored back
# onto the target system.

MV=/usr/bin/mv

# 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

# DEFINE FUNCTIONS

restore_file () {

if [ -f $rootdir/etc/default/lu ] && [ -f $rootdir/etc/default/lu.$PatchNum ]
  then
       ${MV} $rootdir/etc/default/lu.$PatchNum $rootdir/etc/default/lu
  elif [ ! -f $rootdir/etc/default/lu.$PatchNum ] && [ ! -f $rootdir/etc/default/lu ]
    then
       # neither backup nor original are present. ignore
       exit
  elif [ ! -f $rootdir/etc/default/lu.$PatchNum ] && [ -f $rootdir/etc/default/lu ]
    then
       cat << ENDCAT

          Backup file $rootdir/etc/default/lu.$PatchNum
          appears to have been removed.  Unable to restore
          original $rootdir/etc/default/lu file.

ENDCAT

       exit
fi

}

# Main

restore_file

exit 0
