finished migration of cdist-dir to __cdist_dir
Signed-off-by: Nico Schottelius <nico@kr.ethz.ch>
This commit is contained in:
		
					parent
					
						
							
								6a500d5570
							
						
					
				
			
			
				commit
				
					
						cf88f9cacb
					
				
			
		
					 3 changed files with 23 additions and 18 deletions
				
			
		| 
						 | 
				
			
			@ -26,28 +26,26 @@
 | 
			
		|||
 | 
			
		||||
__cdist_dir()
 | 
			
		||||
{
 | 
			
		||||
   [ $# -eq 4 ] || __cdist_usage "<push|pull> <target host> <src dir> <dst dir>"
 | 
			
		||||
   set -ue
 | 
			
		||||
   [ $# -eq 3 ] || __cdist_usage "<push|pull> <src dir> <dst dir>"
 | 
			
		||||
 | 
			
		||||
   __cdist_action="$1"; shift
 | 
			
		||||
   __cdist_target_host="$1"; shift
 | 
			
		||||
   __cdist_src_dir="$1"; shift
 | 
			
		||||
   __cdist_dst_dir="$1"; shift
 | 
			
		||||
   __cdist_dir_action="$1"; shift
 | 
			
		||||
   __cdist_dir_src="$1"; shift
 | 
			
		||||
   __cdist_dir_dst="$1"; shift
 | 
			
		||||
 | 
			
		||||
   # This will be the destination directory, so no subdirectories
 | 
			
		||||
   # of the same name are created, if the directory is already existing
 | 
			
		||||
   __cdist_top_dir="${__cdist_dst_dir%/*}"
 | 
			
		||||
   __cdist_dir_top="${__cdist_dir_dst%/*}"
 | 
			
		||||
 | 
			
		||||
   if [ "$__cdist_action" = "push" ]; then
 | 
			
		||||
   if [ "$__cdist_dir_action" = "push" ]; then
 | 
			
		||||
      ssh "${__cdist_remote_user}@${__cdist_target_host}" \
 | 
			
		||||
         "mkdir -p \"${__cdist_dst_dir}\""
 | 
			
		||||
      scp -qr "$__cdist_src_dir" \
 | 
			
		||||
         "${__cdist_remote_user}@${__cdist_target_host}:${__cdist_top_dir}"
 | 
			
		||||
   elif [ "$__cdist_action" = "pull" ]; then
 | 
			
		||||
      mkdir -p "${__cdist_dst_dir}"
 | 
			
		||||
      scp -qr "${__cdist_remote_user}@${__cdist_target_host}:${__cdist_src_dir}" \
 | 
			
		||||
         "${__cdist_top_dir}"
 | 
			
		||||
         "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}"
 | 
			
		||||
   else
 | 
			
		||||
      __cdist_exit_err "Unknown action $__cdist_action"
 | 
			
		||||
      __cdist_exit_err "Unknown action $__cdist_dir_action"
 | 
			
		||||
   fi
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue