add old md5 scripts

This commit is contained in:
6543 2019-02-03 11:08:48 +01:00
parent d157a23798
commit 6358248825
3 changed files with 116 additions and 0 deletions

View File

@ -0,0 +1,53 @@
#!/bin/bash
#@version 0.2
#@date 2019-01-22

cd /srv/services/log_movie_changes/md5

#sort & del dublicates
cat data_shares_Filme | sort -k 2 | uniq > data_shares_Filme_tmp
cat data_shares_Filme_tmp > data_shares_Filme

cat data_shares_Filme_tmp | while read line; do
#get md5
md5=$(echo $line | cut -c -32)

#get path of file
file=$( echo $line | cut -c 34-)

#wenn datei existiert
if [ -f "$file" ]; then
# do nothing
echo > /dev/null
else
echo "rm $line"
echo "$line" >> data_shares_Filme_RM
sed -i "/$md5/d" data_shares_Filme
fi

done

#search for new files
find /data/shares/Filme/ -type f | grep -v "/.Trash-" | grep -v '/data/shares/Filme/Clone' | grep -v '/data/shares/Filme/HandBrake'| sort | while read line; do
#save fiel path
result=$(grep "$line" data_shares_Filme); [ -z "$result" ] && {
#wenn kein eintrag in liste...
echo "new $line"
result=$(md5sum "$line")
echo $result >> data_shares_Filme_add
result_md5=$(echo $result | cut -c -32)
[ -f data_shares_Filme_RM ] && sed -i "/$result_md5/d" data_shares_Filme_RM
}
done
[ -f data_shares_Filme_add ] && {
cat data_shares_Filme_add >> data_shares_Filme
rm data_shares_Filme_add
}

#sort & del dublicates
cat data_shares_Filme | sort -k 2 | uniq > data_shares_Filme_tmp
rm data_shares_Filme && mv data_shares_Filme_tmp data_shares_Filme

sed -i 's/\ \/data/\ \ \/data/g' data_shares_Filme
sed -i 's/\ \ \ \/data/\ \ \/data/g' data_shares_Filme
sed -i 's/\ \ \ \/data/\ \ \/data/g' data_shares_Filme

58
tools/manage_md5-lists/diff_cp Executable file
View File

@ -0,0 +1,58 @@
#!/bin/bash
# @autor 6543@obermui.de
# @date 2019-01-09
# @version 0.2

function free() {
df "$1" | grep '/dev/' | sed -r -e "s/[\t\ ]+/ /g" | cut -d ' ' -f 4
}

md5="2cp"
aim="/tmp/sdl/oberoed"


md5_tmp=`mktemp`
freenow=0

cat "$md5" > "$md5_tmp"
cat "$md5_tmp" | while read line; do
file_orig="$(echo $line | cut -c 33- | sed -r -e "s/^[\ ]//g")"
file_size=$(du "$file_orig" | cut -f 1)
file_md5=$(echo $line | cut -c -32)
file_aim_dir=$(echo $file_orig | rev | cut -d '/' -f 2- | rev | sed 's/data\/shares\/Filme/tmp\/sdl\/oberoed/g')
file_aim=$(echo $file_orig | sed 's/data\/shares\/Filme/tmp\/sdl\/oberoed/g')

[ "$file_orig" == "$file_aim" ] && { echo Script ERROR; exit 255; }

freenow=$(free "$aim")
#add puffer
freenow=$((freenow-10240))

if [ -f "$file_orig" ]; then

if [ "$freenow" -ge "$file_size" ]; then

mkdir -p "$file_aim_dir"
[ -f "$file_aim" ] && rm "$file_aim"

file_md5_new=$(cat "$file_orig" | tee "$file_aim" | md5sum | cut -c -32)

if [ "${file_md5_new}" == "${file_md5}" ]; then
echo "$file_md5 $file_aim" >> /tmp/sdl/md5.txt
sed -i "/$file_md5/d" "$md5"
else
echo "Error: Hash mismatch: \"NEW:${file_md5_new} OLD:${file_md5}\" $file_aim"
rm "$file_aim"
fi

else
echo "To Big: $file_md5 $file_orig"
fi

else
echo "Error: Not Exist: $file_orig"
sed -i "/$file_md5/d" "$md5"
fi
done

rm "$md5_tmp"

View File

@ -0,0 +1,5 @@
#!/bin/bash

md5=$1
md5_dub=$(mktemp)
cat $md5 | cut -c -32 | awk 'seen[$0] {print} {++seen[$0]}' | sort -u > $md5_dub