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
shift
fi
if [ "$1" = "--force" ] ; then
force="$1"
shift
fi
WORKDIR=~/grf
mkdir -p $WORKDIR
......@@ -143,17 +148,22 @@ local sfile="$1"
echo
echo "mounted info for $sfile:"
[ -z "$restore" ] && md5sum "$sfile"
if [ -z "$restore" ] ; then
md5sum "$sfile"
fi
FLAGBROKENFILE=
stat "$sfile" >/dev/null || FLAGBROKENFILE=1
if [ -n "$restore" ] && [ -z "$FLAGBROKENFILE" ] ; then
# skipping, file metainfo is readable
return 0
if [ -n "$restore" ] && [ -z "$FLAGBROKENFILE" ] && [ -z "$force" ] ; then
PERM=$(stat -c "%a" "$sfile")
if [ "$PERM" != "1000" ] ; then
# skipping, file metainfo is readable
return 0
fi
fi
# hack: translate to a path on volume
file="$(echo "$sfile" | sed -e "s|$FTPROOT||g")"
file="$(echo "$sfile" | sed -e "s|$FTPROOT/||g")"
# hack
FLAGSYMLINK=
......@@ -172,6 +182,8 @@ for brick in $LISTBRICKS ; do
# если каталог, показываем также информацию о самом каталоге
[ -d "$sfile" ] && opbrick "ls -ld" "$file"
sshopbrick "getfattr -d -m . -e hex" "$file"
# показываем информацию о файле или содержимом каталога
if opbrick "ls -l" "$file" ; then
if [ ! -L "$sfile" ] ; then
......@@ -199,6 +211,7 @@ if [ "$restore" = "--restore" ] ; then
rm -f $WORKDIR/*
for i in $LISTBRICKS ; do
set_host_path "$i"
# Надо отличать, есть файл или ошибка с ним. Если файла вообще нет, надо удалять всё на томах
FD=$(opbrick 'stat -c %z' "$file")
echo $FD
if [ -n "$FD" ] ; then
......@@ -235,6 +248,7 @@ if [ "$restore" = "--restore" ] ; then
# Удаляем всё, кроме OLDFILE
if [ ! "$OLDFILE" = "$WORKDIR/$host-$COUNT" ] ; then
# FIXME: Нельзя удалять, если OLDFILE на неактивном томе
opbrick "rm -fv" "$file"
echo "$path$file ($host)" >>grf.removed.list
fi
......@@ -251,7 +265,7 @@ fi
}
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
done
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