dataset-file-chek/file-in-disk.sh

22 lines
866 B
Bash

#!/bin/bash
rm dataset-0.txt dataset-1.txt Diff.html
php -f file-in-db.php
cat dataset-0.txt | while read oneline;
do
uuid=`echo $oneline | awk '{print $1}'`
datapath=`echo "$oneline" | awk -F'\t' '{print $4}'`
fcount=`find -L "$datapath"/* | wc -l`
if [ $fcount -gt 0 ]; then
volume=`du -sbL "$datapath"/* | awk '{a+=$1}END{print a}'`
echo -e $uuid'\t'$volume'\t'$fcount'\t'$datapath >> dataset-1.txt
else
echo $datapath;
fi
done
if ! diff -q dataset-0.txt dataset-1.txt > /dev/null; then
vimdiff -c ":TOhtml | :wq | :q | :q" dataset-0.txt dataset-1.txt
cp Diff.html /var/www/ftp2.westgis.ac.cn/
echo "FTP2 dataset file has been changed. Please use the attachment to find the differences." | mail -s "FTP2 dataset file change" -A Diff.html wangliangxu@lzb.ac.cn
fi
exit 0