From 84326720ec48f12afaca25d687901bd570018741 Mon Sep 17 00:00:00 2001 From: Jan Lindemann Date: Sat, 11 Feb 2017 18:56:52 +0000 Subject: [PATCH] upload.sh: Add method directory Signed-off-by: Jan Lindemann --- scripts/upload.sh | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/scripts/upload.sh b/scripts/upload.sh index 93e134d9..001768fc 100644 --- a/scripts/upload.sh +++ b/scripts/upload.sh @@ -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 ;;