Commit 7ce850e4 authored by Vitaly Lipatov's avatar Vitaly Lipatov

improve grf

parent e3141ed2
#!/bin/sh #!/bin/sh
LOCKFILE=$0.lock
test -r $LOCKFILE && echo "Already running..." && exit
touch $LOCKFILE
# Проверяет указанный файл на наличие в возможных местах размещения # Проверяет указанный файл на наличие в возможных местах размещения
fatal() fatal()
{ {
echo "FATAL: $@" >&2 echo "FATAL: $@" >&2
rm -f $LOCKFILE
exit 1 exit 1
} }
...@@ -28,6 +33,7 @@ umount_g() ...@@ -28,6 +33,7 @@ umount_g()
umount -v "$MOUNTDIR/$host/$path" umount -v "$MOUNTDIR/$host/$path"
rmdir "$MOUNTDIR/$host/$path" rmdir "$MOUNTDIR/$host/$path"
done done
rm -f $LOCKFILE
} }
mount_g() mount_g()
...@@ -115,6 +121,7 @@ if [ "$1" = "--list" ] ; then ...@@ -115,6 +121,7 @@ if [ "$1" = "--list" ] ; then
sfile=$(cat "$uselist" | grep ^/ | head -n1) sfile=$(cat "$uselist" | grep ^/ | head -n1)
if [ -z "$sfile" ] ; then if [ -z "$sfile" ] ; then
echo "Skip empty file $uselist" echo "Skip empty file $uselist"
rm -f $LOCKFILE
exit 0 exit 0
fi fi
fi fi
...@@ -182,7 +189,7 @@ fi ...@@ -182,7 +189,7 @@ fi
get_pgf_name() get_pgf_name()
{ {
local rfile="$1" local rfile="$1"
echo ".glusterfs/$(echo $rfile | cut -b1-2)/$(echo $rfile | cut -b3-4)/$rfile" echo ".glusterfs/$(echo "$rfile" | cut -b1-2)/$(echo "$rfile" | cut -b3-4)/$rfile"
} }
tr_gfid_to_rpath() tr_gfid_to_rpath()
...@@ -200,8 +207,8 @@ tr_gfid_to_rpath() ...@@ -200,8 +207,8 @@ tr_gfid_to_rpath()
# 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")"
rfile=$(echo $file | sed -e "s|<gfid:||g" | sed -e "s|[<>]||g") rfile=$(echo "$file" | sed -e "s|<gfid:||g" | sed -e "s|[<>]||g")
rfile=$(get_pgf_name $rfile) rfile=$(get_pgf_name "$rfile")
rpath=$path rpath=$path
rfile=$(opbrick "realpath" "$rfile") && break rfile=$(opbrick "realpath" "$rfile") && break
done done
...@@ -468,7 +475,7 @@ if [ -n "$uselist" ] ; then ...@@ -468,7 +475,7 @@ if [ -n "$uselist" ] ; then
done done
else else
# TODO: use find? # TODO: use find?
for sf in $sfile ; do for sf in "$sfile" ; do
test_file "$sf" test_file "$sf"
done done
fi fi
......
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