vzmigrate: fix checking rsync/vzctl exit code

Well well well... This is a nice example that shows that one
should not touch something that works, or it might stop working.

We had this code in vzmigrate:

 logexec 2 $SSH root@$host vzctl set $VEID --applyconfig_map name --save
 # vzctl return code 20 or 21 in case of unrecognized option
 if [[ $? != 20 && $? != 21 && $? != 0 ]]; then

that apparently used bash-specific [[ ]] operator. It was "fixed"
by commit ebd5fb0 and after the fix the if statement became:

 if [ $? != 20 && $? != 21 && $? != 0 ]; then

That, of course, led to the error:

 /usr/sbin/vzmigrate: line 382: [: missing `]'

which was "fixed" by commit 5783162, and the if statement became:

 if [ $? != 20 ] && [ $? != 21 ] && [ $? != 0 ]; then

It fixed the "missing `]'" error but broke the code completely. Why?

Just because after the first [ ] operator the value of $? became 0.
So, apparently, we have managed to remove the error check at all.

Later, a similar buggy code was added in commit b9d4b8c to add rsync
exit code of 24 to exclude list. Well, it broke the error check, too.

First rsync pass check was broken since July 2010 (vzctl 3.0.25).

vzctl set name check was broken since Nov 2007 (vzctl 3.0.23).

This patch fixes both places. Or so I hope.

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
1 file changed