#!/bin/ksh
# IBM_PROLOG_BEGIN_TAG 
# This is an automatically generated prolog. 
#  
# bos720 src/bos/usr/lpp/nfs/nfs_lku_copy_exports 1.1 
#  
# Licensed Materials - Property of IBM 
#  
# Restricted Materials of IBM 
#  
# COPYRIGHT International Business Machines Corp. 2014 
# All Rights Reserved 
#  
# US Government Users Restricted Rights - Use, duplication or 
# disclosure restricted by GSA ADP Schedule Contract with IBM Corp. 
#  
# IBM_PROLOG_END_TAG 

# This script makes sure what was exported on the original is exported on the
# surrogate

# @(#)55       1.1 src/bos/usr/lpp/nfs/nfs_lku_copy_exports, pkgnfs, bos720, 1449A_720 11/18/14 13:53:46

nfs_lku_dir=/var/adm/ras/liveupdate/kext/nfs/
exports=/etc/exports
exports_copy=/var/adm/ras/liveupdate/kext/nfs/exports
xtab=/etc/xtab

# create the nfs liveupdate directory if it does not exist
if [[ ! -d $nfs_lku_dir ]]; then
	mkdir -p $nfs_lku_dir
	if [[ $? -ne 0 ]]; then
		exit 1
	fi
fi

# remove the copy if one already exists
if [[ -e $exports_copy ]]; then
    rm $exports_copy
    if [[ $? -ne 0 ]]; then
        exit 1
    fi
fi

# save a copy of /etc/exports
if [[ -e $exports ]]; then
	cp $exports $exports_copy
	if [[ $? -ne 0 ]]; then
		exit 1
	fi
fi

# copy /etc/xtab to /etc/exports
if [[ -e $xtab ]]; then
	cp $xtab $exports
	if [[ $? -ne 0 ]]; then
		exit 1
	fi
fi

exit 0