From b5b8bdc016e5098dde77251462a3eb024c987bb9 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 10 Aug 2011 16:03:12 +0200 Subject: [PATCH] cleanup __cdist_dir Signed-off-by: Nico Schottelius --- core/__cdist_dir | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/core/__cdist_dir b/core/__cdist_dir index 2f08a95c..32ee0075 100755 --- a/core/__cdist_dir +++ b/core/__cdist_dir @@ -23,29 +23,24 @@ # Pull a directory from a target, both sides have the same name (i.e. explorers) # - __cdist_dir() { [ $# -eq 3 ] || __cdist_usage " " - __cdist_dir_action="$1"; shift - __cdist_dir_src="$1"; shift - __cdist_dir_dst="$1"; shift - - # This will be the destination directory, so no subdirectories + # ${3%/*} will be the destination directory, so no subdirectories # of the same name are created, if the directory is already existing - __cdist_dir_top="${__cdist_dir_dst%/*}" - if [ "$__cdist_dir_action" = "push" ]; then + if [ "$1" = "push" ]; then + # FIXME: add error handling with __cdist_run_remote_... or so ssh "${__cdist_remote_user}@${__cdist_target_host}" \ - "mkdir -p \"${__cdist_dir_dst}\"" - scp -qr "$__cdist_dir_src" \ - "${__cdist_remote_user}@${__cdist_target_host}:${__cdist_dir_top}" - elif [ "$__cdist_dir_action" = "pull" ]; then - mkdir -p "${__cdist_dir_dst}" - scp -qr "${__cdist_remote_user}@${__cdist_target_host}:${__cdist_dir_src}" \ - "${__cdist_dir_top}" + "mkdir -p \"$3\"" + scp -qr "$2" \ + "${__cdist_remote_user}@${__cdist_target_host}:${3%/*}" + elif [ "$1" = "pull" ]; then + mkdir -p "$3" + scp -qr "${__cdist_remote_user}@${__cdist_target_host}:$2" \ + "${3%/*}" else - __cdist_exit_err "Unknown action $__cdist_dir_action" + __cdist_exit_err "Unknown action $1" fi }