2012-06-15 15:43:55 +00:00
|
|
|
#!/bin/sh
|
|
|
|
# This script is used by the xdcp APPEND: function to perform the
|
|
|
|
# append operation on the nodes.
|
|
|
|
#First parm is nodesyncfiledir, then after that are the lines for the
|
|
|
|
#APPEND clause put in the format
|
2012-07-13 11:39:53 +00:00
|
|
|
#appendfile1:orgfile1 appendfile2:orgfile2.....
|
2012-06-15 15:43:55 +00:00
|
|
|
#
|
|
|
|
nodesyncfiledir=$1
|
|
|
|
nodesyncfiledirorg="$nodesyncfiledir/org"
|
|
|
|
nodesyncfiledirappend="$nodesyncfiledir/append"
|
|
|
|
skip=0
|
|
|
|
for i in $*; do
|
|
|
|
# skip first parm
|
|
|
|
if [ $skip -eq 0 ]; then
|
|
|
|
skip=1
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
# get the append file location
|
|
|
|
appendfilebase=`echo "$i"|cut -d ':' -f 1`
|
|
|
|
appendfile="$nodesyncfiledirappend$appendfilebase"
|
|
|
|
# get the file to append to
|
|
|
|
orgfile=`echo "$i"|cut -d ':' -f 2`
|
|
|
|
# get the directory to backup the original file to append
|
|
|
|
orgfiledir=`dirname $orgfile`
|
|
|
|
filebackupdir="$nodesyncfiledirorg$orgfiledir"
|
|
|
|
filebackup="$nodesyncfiledirorg$orgfile"
|
|
|
|
# now do the work
|
|
|
|
mkdir -p $filebackupdir
|
2012-07-16 16:37:42 +00:00
|
|
|
# if there does not exist an original backup, make one
|
2012-06-15 15:43:55 +00:00
|
|
|
if [ ! -f "$filebackup" ]; then
|
|
|
|
cp -p $orgfile $filebackup
|
|
|
|
fi
|
2012-07-16 16:37:42 +00:00
|
|
|
# copy original backup to the local file and append
|
2012-06-15 15:43:55 +00:00
|
|
|
cp -p $filebackup $orgfile
|
|
|
|
cat $appendfile >> $orgfile
|
|
|
|
|
|
|
|
done
|
|
|
|
exit 0
|