Commit 806bc822 authored by Vitaly Lipatov's avatar Vitaly Lipatov

grf: small fixes, add force key

parent 71d837da
...@@ -70,6 +70,11 @@ if [ "$1" = "--restore" ] ; then ...@@ -70,6 +70,11 @@ if [ "$1" = "--restore" ] ; then
shift shift
fi fi
if [ "$1" = "--force" ] ; then
force="$1"
shift
fi
WORKDIR=~/grf WORKDIR=~/grf
mkdir -p $WORKDIR mkdir -p $WORKDIR
...@@ -143,17 +148,22 @@ local sfile="$1" ...@@ -143,17 +148,22 @@ local sfile="$1"
echo echo
echo "mounted info for $sfile:" echo "mounted info for $sfile:"
[ -z "$restore" ] && md5sum "$sfile" if [ -z "$restore" ] ; then
md5sum "$sfile"
fi
FLAGBROKENFILE= FLAGBROKENFILE=
stat "$sfile" >/dev/null || FLAGBROKENFILE=1 stat "$sfile" >/dev/null || FLAGBROKENFILE=1
if [ -n "$restore" ] && [ -z "$FLAGBROKENFILE" ] ; then if [ -n "$restore" ] && [ -z "$FLAGBROKENFILE" ] && [ -z "$force" ] ; then
# skipping, file metainfo is readable PERM=$(stat -c "%a" "$sfile")
return 0 if [ "$PERM" != "1000" ] ; then
# skipping, file metainfo is readable
return 0
fi
fi fi
# hack: translate to a path on volume # hack: translate to a path on volume
file="$(echo "$sfile" | sed -e "s|$FTPROOT||g")" file="$(echo "$sfile" | sed -e "s|$FTPROOT/||g")"
# hack # hack
FLAGSYMLINK= FLAGSYMLINK=
...@@ -172,6 +182,8 @@ for brick in $LISTBRICKS ; do ...@@ -172,6 +182,8 @@ for brick in $LISTBRICKS ; do
# если каталог, показываем также информацию о самом каталоге # если каталог, показываем также информацию о самом каталоге
[ -d "$sfile" ] && opbrick "ls -ld" "$file" [ -d "$sfile" ] && opbrick "ls -ld" "$file"
sshopbrick "getfattr -d -m . -e hex" "$file"
# показываем информацию о файле или содержимом каталога # показываем информацию о файле или содержимом каталога
if opbrick "ls -l" "$file" ; then if opbrick "ls -l" "$file" ; then
if [ ! -L "$sfile" ] ; then if [ ! -L "$sfile" ] ; then
...@@ -199,6 +211,7 @@ if [ "$restore" = "--restore" ] ; then ...@@ -199,6 +211,7 @@ if [ "$restore" = "--restore" ] ; then
rm -f $WORKDIR/* rm -f $WORKDIR/*
for i in $LISTBRICKS ; do for i in $LISTBRICKS ; do
set_host_path "$i" set_host_path "$i"
# Надо отличать, есть файл или ошибка с ним. Если файла вообще нет, надо удалять всё на томах
FD=$(opbrick 'stat -c %z' "$file") FD=$(opbrick 'stat -c %z' "$file")
echo $FD echo $FD
if [ -n "$FD" ] ; then if [ -n "$FD" ] ; then
...@@ -235,6 +248,7 @@ if [ "$restore" = "--restore" ] ; then ...@@ -235,6 +248,7 @@ if [ "$restore" = "--restore" ] ; then
# Удаляем всё, кроме OLDFILE # Удаляем всё, кроме OLDFILE
if [ ! "$OLDFILE" = "$WORKDIR/$host-$COUNT" ] ; then if [ ! "$OLDFILE" = "$WORKDIR/$host-$COUNT" ] ; then
# FIXME: Нельзя удалять, если OLDFILE на неактивном томе
opbrick "rm -fv" "$file" opbrick "rm -fv" "$file"
echo "$path$file ($host)" >>grf.removed.list echo "$path$file ($host)" >>grf.removed.list
fi fi
...@@ -251,7 +265,7 @@ fi ...@@ -251,7 +265,7 @@ fi
} }
if [ -n "$uselist" ] ; then if [ -n "$uselist" ] ; then
cat "$uselist" | grep "^/" | while read sf ; do cat "$uselist" | sort -u | grep "^/" | while read sf ; do
test_file "$sf" </dev/null test_file "$sf" </dev/null
done done
else else
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment