upload.sh: Add method directory

Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
Jan Lindemann 2017-02-11 18:56:52 +00:00
commit 84326720ec

View file

@ -34,7 +34,7 @@ HOST=ftp.jannet.de
CFG_FILE=$HOME/.uploadrc
login=`whoami`
method=rsync_ssh
method=
pw_ftp=
pw_scp=$HOME/.ssh/identity
pw_rsync=
@ -149,13 +149,22 @@ parse_target()
echo pw_rsync_ssh="\"$PASSWD\";"
fi
HOST=`echo $target | sed -e 's/^.*:\/\///; s/.*@//' | cut -d: -f1`
if [ -n "$HOST" ]; then
case $METHOD in
rsync_ssh)
if [ -z "$HOST" ]; then
PARSE_TARGET=FALSE
return
fi
echo host="\"$HOST\";"
else
;;
"")
;;
*)
PARSE_TARGET=FALSE
return
fi
TARGET_FILE=`echo $target | sed -e 's/^.*:\/\///; s/.*@//; /:/ !d' | cut -d: -f2`
;;
esac
TARGET_FILE=`echo $target | sed -e 's/^.*:\/\///; s/.*@//' | cut -d: -f2`
if [ -n "$TARGET_FILE" ]; then
echo target_file="\"$TARGET_FILE\";"
else
@ -287,6 +296,8 @@ rsync_ssh)
fi
fi
;;
"")
;;
*)
fatal "Support for method \"$method\" is not implemented." >&2
;;
@ -334,6 +345,16 @@ rsync_ssh)
ssh_chown $target_path $file_owner $file_group
ssh_chmod $target_path $file_mode $dir_mode
;;
"")
#[ "$file_owner" ] || file_owner=`stat -c %u $source | head -1`
#[ "$file_group" ] || file_group=`stat -c %g $source | head -1`
#[ "$file_mode" ] || file_mode=`stat -c %a $source | head -1`
#install -m $file_mode -o $file_owner -g $file_group $source $target
$do_sudo cp $source $target
if [ "$file_owner" ] ; then $do_sudo chown $file_owner $target; fi
if [ "$file_group" ] ; then $do_sudo chgrp $file_group $target; fi
if [ "$file_mode" ] ; then $do_sudo chmod $file_mode $target; fi
;;
*)
fatal "Internal error: \"$method\" is not implemented." >&2
;;