BUGS: trailing slash in VOYAGE_SYNC_DIRS /etc/default/voyage-util

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

BUGS: trailing slash in VOYAGE_SYNC_DIRS /etc/default/voyage-util

Andrey-2
Hello.

I lost the directory /var/lib adding in a variable VOYAGE_SYNC_DIRS  in the file /etc/default/voyage-util a directory "var/lib/exim4/" (slash in the end!)
 and run the command /etc/init.d/voyage-sync sync.
After a time, reboot the server and get result  /var/lib contains only the files from the /var/lib/exim4/*

Here's what happened:
1. execute the command /etc/init.d/voyage-sync sync
I got a backup directory /.sync/var/lib/exim4
This is the result of the command:
rsync -a -q --delete-after /$SYNC_DIR/. /.sync/$SYNC_DIR &
from  /etc/init.d/voyage-sync
2. After reboot the server (in fact, the performance of voyage-sinc stop)
I got a empty dir /var/lib exclude files from /.sync/var/lib/exim4
This is the result of the command:
rsync -a -q --delete-after /.sync/$SYNC_DIR `dirname /$SYNC_DIR` &
from  /etc/init.d/voyage-sync

All this is thanks to rsync features to recognize a trailing slash in a source directory.

In the description of /etc/default/voyage-util does not warn of the trailing slash! "var/lib/exim4/"

RESOLVE:
I add in the file /etc/init.d/voyage-sync:

if [ -f /etc/default/voyage-util ] ; then
        . /etc/default/voyage-util;
fi

+# Deleting leading and trailing slash (features of rsync)
+VOYAGE_SYNC_DIRS_WSLASH=""
+for SYNC_DIR in $VOYAGE_SYNC_DIRS ; do
+        SYNC_DIR=$(echo $SYNC_DIR | sed -e "s,/\+$,," -e "s,^/\+,,")
+        VOYAGE_SYNC_DIRS_WSLASH="$VOYAGE_SYNC_DIRS_WSLASH $SYNC_DIR"
+done
+
-SYNC_DIRS="$SYNC_DIRS $VOYAGE_SYNC_DIRS"
+SYNC_DIRS="$SYNC_DIRS $VOYAGE_SYNC_DIRS_WSLASH"
UNIONFS=${VOYAGE_UNIONFS:=tmpfs}

This cycle cleans the initial and trailing slashes in all directories variable VOYAGE_SYNC_DIRS from /etc/default/voyage-util

____________________
Андрей
mailto:[hidden email]

_______________________________________________
Voyage-linux mailing list
[hidden email]
http://list.voyage.hk/mailman/listinfo/voyage-linux
Loading...