work with relative paths | log sucess to stdout | all paths to vars
This commit is contained in:
parent
022ad36b6e
commit
b5cb6a2245
20
cp_sh
20
cp_sh
@ -11,18 +11,26 @@ md5="2cp.md5"
|
|||||||
aim="/mnt/export/transport"
|
aim="/mnt/export/transport"
|
||||||
source="/data/Filme"
|
source="/data/Filme"
|
||||||
|
|
||||||
|
## prepare
|
||||||
|
aim="$(echo $aim | sed 's/\/$//g')"
|
||||||
|
source="$(echo $source | sed 's/\/$//g')"
|
||||||
|
|
||||||
md5_tmp=`mktemp`
|
md5_tmp=`mktemp`
|
||||||
freenow=0
|
|
||||||
|
|
||||||
cat "$md5" > "$md5_tmp"
|
cat "$md5" > "$md5_tmp"
|
||||||
sed -i '/^$/d' "$md5_tmp"
|
sed -i '/^$/d' "$md5_tmp"
|
||||||
|
sed -i "s/${source//'/'/'\/'}//g" "$md5_tmp" #from absolut to relative paths
|
||||||
|
|
||||||
|
freenow=0
|
||||||
|
|
||||||
|
|
||||||
|
## start prosessing
|
||||||
cat "$md5_tmp" | while read line; do
|
cat "$md5_tmp" | while read line; do
|
||||||
file_orig="$(echo $line | cut -c 33- | sed -r -e "s/^[\ ]//g")"
|
file="$(echo $line | cut -c 33- | sed -r -e "s/^[\ ]//g")"
|
||||||
|
file_orig="${source}${file}"
|
||||||
file_size=$(du "$file_orig" | cut -f 1)
|
file_size=$(du "$file_orig" | cut -f 1)
|
||||||
file_md5=$(echo $line | cut -c -32)
|
file_md5=$(echo $line | cut -c -32)
|
||||||
file_aim_dir=$(echo $file_orig | rev | cut -d '/' -f 2- | rev | sed 's/data\/Filme/mnt\/export\/transport/g') #prepare destination - not automated jet
|
file_aim="${aim}${file}"
|
||||||
file_aim=$(echo $file_orig | sed 's/data\/Filme/mnt\/export\/transport/g') #prepare destination - not automated jet
|
file_aim_dir=$(echo $file_aim | rev | cut -d '/' -f 2- | rev)
|
||||||
|
|
||||||
[ "$file_orig" == "$file_aim" ] && { echo Script ERROR; exit 255; }
|
[ "$file_orig" == "$file_aim" ] && { echo Script ERROR; exit 255; }
|
||||||
|
|
||||||
@ -40,7 +48,7 @@ cat "$md5_tmp" | while read line; do
|
|||||||
file_md5_new=$(cat "$file_orig" | tee "$file_aim" | md5sum | cut -c -32)
|
file_md5_new=$(cat "$file_orig" | tee "$file_aim" | md5sum | cut -c -32)
|
||||||
|
|
||||||
if [ "${file_md5_new}" == "${file_md5}" ]; then
|
if [ "${file_md5_new}" == "${file_md5}" ]; then
|
||||||
echo "$file_md5 $file_aim" >> "${md5}.sucess-log"
|
echo "$file_md5 $file_aim" | tee -a "${md5}.sucess-log"
|
||||||
sed -i "/$file_md5/d" "$md5"
|
sed -i "/$file_md5/d" "$md5"
|
||||||
else
|
else
|
||||||
echo "Error: Hash mismatch: \"NEW:${file_md5_new} OLD:${file_md5}\" $file_aim" | tee -a "${md5}.error-log"
|
echo "Error: Hash mismatch: \"NEW:${file_md5_new} OLD:${file_md5}\" $file_aim" | tee -a "${md5}.error-log"
|
||||||
|
Loading…
Reference in New Issue
Block a user