upload.sh: Fix uploading multiple sources, was completely broken

This commit is contained in:
Jan Lindemann 2004-02-08 12:11:15 +00:00 committed by Jan Lindemann
commit 2e94ebe232

View file

@ -148,7 +148,7 @@ parse_target()
test -n "$FILE_GROUP" && echo file_group="\"$FILE_GROUP\";"
if is_dir "$target_file" ; then
echo target_path=\"$TARGET_FILE/`basename $source`\" # TODO: this is bullshit
echo target_path=\"$TARGET_FILE/`basename $TARGET_FILE`\" # TODO: this is bullshit
else
echo target_path=\"$TARGET_FILE\" # TODO: this is bullshit
fi
@ -237,36 +237,39 @@ shift
test -z "$VARIABLE" && test $# -lt 2 && usage 1
# -- get parameters from command line
source=$1
shift
n_targets=`expr $# - 1`
target="`echo $* | cut -d' ' -f$#`"
source="`echo $* | cut -d' ' -f1-$n_targets`"
#echo target=$target
#echo source=$source
# -- check run
for t in $*; do
# parse_target $t
eval `parse_target $t`
if [ "$PARSE_TARGET" != OK ]; then
echo "Failed to parse target \"$t\"; exiting."
parse_target $t
exit 2
for s in $source; do
if [ ! -d "$s" -a ! -f "$s" -a ! -L "$s" ]; then
echo \"$s\" is neither a regular file, nor a directory, nor a link. Exiting. >&2
exit 1
fi
case $method in
rsync_ssh)
if [ "$login" != root ]; then
if [ "$file_owner" -a "$file_owner" != "$login" ]; then
echo "File owner \"$file_owner\" is only legal, if you log in as \"$login\" or as \"root\"."
exit 1
fi
fi
if [ ! -d "$source" -a ! -f "$source" -a ! -L "$source" ]; then
echo \"$source\" is neither a regular file, nor a directory, nor a link. Exiting. >&2
exit 1
fi;;
*)
echo "Support for method \"$method\" is not implemented." >&2
exit 1;;
esac
done
eval `parse_target $target`
if [ "$PARSE_TARGET" != OK ]; then
echo "Failed to parse target \"$t\"; exiting."
parse_target $t
exit 2
fi
case $method in
rsync_ssh)
if [ "$login" != root ]; then
if [ "$file_owner" -a "$file_owner" != "$login" ]; then
echo "File owner \"$file_owner\" is only legal, if you log in as \"$login\" or as \"root\"."
exit 1
fi
fi;;
*)
echo "Support for method \"$method\" is not implemented." >&2
exit 1;;
esac
# -- real run
if [ -n "$VARIABLE" ]; then
eval `parse_target`
@ -298,18 +301,16 @@ if [ "$PARSE" = 1 ]; then
test "$EXIT" = 1 && exit 0
fi
for t in $*; do
eval `parse_target $t`
case $method in
rsync_ssh)
ssh_mkdir $target_file $file_owner $file_group $dir_mode || break
/usr/bin/rsync -az --links -e "/usr/bin/ssh -l $login $IDENTITY" $source $login@$host:$target_file
ssh_chown $target_path $file_owner $file_group
ssh_chmod $target_path $file_mode $dir_mode
;;
*)
echo "Internal error: \"$method\" is not implemented." >&2
exit 1;;
esac
done
eval `parse_target $target`
case $method in
rsync_ssh)
ssh_mkdir $target_file $file_owner $file_group $dir_mode || break
/usr/bin/rsync -az --links -e "/usr/bin/ssh -l $login $IDENTITY" $source $login@$host:$target_file
ssh_chown $target_path $file_owner $file_group
ssh_chmod $target_path $file_mode $dir_mode
;;
*)
echo "Internal error: \"$method\" is not implemented." >&2
exit 1;;
esac