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\";" test -n "$FILE_GROUP" && echo file_group="\"$FILE_GROUP\";"
if is_dir "$target_file" ; then 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 else
echo target_path=\"$TARGET_FILE\" # TODO: this is bullshit echo target_path=\"$TARGET_FILE\" # TODO: this is bullshit
fi fi
@ -237,36 +237,39 @@ shift
test -z "$VARIABLE" && test $# -lt 2 && usage 1 test -z "$VARIABLE" && test $# -lt 2 && usage 1
# -- get parameters from command line # -- get parameters from command line
source=$1 n_targets=`expr $# - 1`
shift target="`echo $* | cut -d' ' -f$#`"
source="`echo $* | cut -d' ' -f1-$n_targets`"
#echo target=$target
#echo source=$source
# -- check run # -- check run
for t in $*; do for s in $source; do
# parse_target $t if [ ! -d "$s" -a ! -f "$s" -a ! -L "$s" ]; then
eval `parse_target $t` echo \"$s\" is neither a regular file, nor a directory, nor a link. Exiting. >&2
if [ "$PARSE_TARGET" != OK ]; then exit 1
echo "Failed to parse target \"$t\"; exiting."
parse_target $t
exit 2
fi 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 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 # -- real run
if [ -n "$VARIABLE" ]; then if [ -n "$VARIABLE" ]; then
eval `parse_target` eval `parse_target`
@ -298,18 +301,16 @@ if [ "$PARSE" = 1 ]; then
test "$EXIT" = 1 && exit 0 test "$EXIT" = 1 && exit 0
fi fi
for t in $*; do eval `parse_target $target`
eval `parse_target $t` case $method in
case $method in rsync_ssh)
rsync_ssh) ssh_mkdir $target_file $file_owner $file_group $dir_mode || break
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
/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_chown $target_path $file_owner $file_group ssh_chmod $target_path $file_mode $dir_mode
ssh_chmod $target_path $file_mode $dir_mode ;;
;; *)
*) echo "Internal error: \"$method\" is not implemented." >&2
echo "Internal error: \"$method\" is not implemented." >&2 exit 1;;
exit 1;; esac
esac
done