corz.org uses cookies to remember that you've seen this notice explaining that corz.org uses cookies, okay!
if [ -z $1 ]; then
echo
echo "Please supply a domain name on the command-line. e.g.."
echo
echo "$0 foobar.net"
echo
echo "grabcomments will then use settings file: ~/.sftp/foobar.net"
echo
exit 1
fi
. ~/.sftp/$1
newname=$now.$host.comments.tar.gz
mytmp=$comm_tmp/comments
mystore=$commentstore/comments
if [ ! -d $arcroot ]; then
mkdir -pv $arcroot > /dev/null
fi
if [ ! -d $mytmp ]; then
mkdir -pv $mytmp > /dev/null
fi
if [ ! -d $mystore ]; then
mkdir -pv $mystore > /dev/null
fi
echo "Searching for comments.."
for i in $( find $home -name "*.comment" ); do
echo $i
bn=`basename $i`
dir=`dirname $i`
dirbasename=`basename $dir`
if [ ! -e $mytmp/$dirbasename ]; then
mkdir -p $mytmp/$dirbasename > /dev/null
fi
cp $i $mytmp/$dirbasename/
done
cd $comm_tmp
echo "Zipping backup.."
tar cfz $newname comments >> $logfile
rc=$?
if [ $rc != 0 ] ; then
echo "**WARNING** grabcomments tar for $host returned an error: $rc"
echo "**WARNING** grabcomments tar for $host returned an error: $rc"|mailx -s "Error in up grabcomments!" postmaster
exit $rc
fi
mv $newname $mystore/
rm -rf $mytmp &> /dev/null
cd ..
rmdir $comm_tmp
remount > /dev/null
if [ ! -d $ol_comments ]; then
mkdir -pv $ol_comments > /dev/null
fi
if [ -e "$ol_comments" ];then
echo -n "Copying db backup to offline storage facility.. "
cp $mystore/$newname $ol_comments/
if [ -e "$ol_comments/$newname" ];then
echo "Success!"
rm $mystore/$newname >> $logfile &> /dev/null
rmdir $mystore
rmdir $commentstore
else
echo "Fail!"
echo "Could not copy $mystore/$newname to $ol_comments"
fi
fi
rmdir $arcroot
echo "Deleting local comment files.."
for i in $( find $home -name "*.comment" ); do rm $i; done
echo "Performing sftp operations for $user@$host.."
sftp -b "/usr/local/bin/$host/grabcomments" $user@$host
rc=$?
if [ $rc != 0 ] ; then
echo "**WARNING** grabcomments sftp for $host returned an error: $rc"
echo "**WARNING** grabcomments sftp for $host returned an error: $rc"|mailx -s "Error in up grabcomments sftp!" postmaster
exit $rc
fi
echo "Setting local file permissions.."
for i in $( find $home -name "*.comment" ); do chmod 777 $i; done
now=`date "+%Y.%m.%d-%H.%M"`
command -v fortune >/dev/null 2>&1 || { echo "Oooh! That Feels Good!"; exit 0; }
fortune
echo "grabcomments for $host complete at $now"
exit 0