Listing 2: replication_client.sh
if [ ${DIRECTORY} = "/" ] # IF someone tries to replicate root directory
then # THEN get out
rm -f ${CPIO_FILENAME}
rm -f ${FILE_LIST}
echo Someone tried to replicate "/". \
Investigate ${LIST_OF_DIRECTORIES} \
| mailx -s "Invalid directory being replicated!" \
root
exit
fi
if [ ! -d ${DIRECTORY} ] # IF the directory being replicated does not exist
then # THEN make the directory
mkdir ${DIRECTORY}
fi
cd ${DIRECTORY}
if [ -s ${CPIO_FILENAME} ] # IF a CPIO file was sent
then # THEN un-cpio/gunzip it
cat ${CPIO_FILENAME} | \
/usr/local/bin/gunzip | cpio -ivcdum
fi
if [ -s ${FILE_LIST} ] # IF there are files that need to be removed
then # THEN remove them
REMOVE_FILE_LIST=`cat ${FILE_LIST}`
for CLIENT_FILE in ${REMOVE_FILE_LIST} # For each file/directory in the list
do # remove it
`rm -rf ${DIRECTORY}/${CLIENT_FILE} `
done
fi # End of IF there are files that need to be removed
# End of File
|