kas-docker: enable passing SSH configs
This commit enables passing the Docker container a directory containing SSH configuration and optionally SSH identities and list of known SSH hosts. Basically what you might expect to find in the ~/.ssh directory of the container. Signed-off-by: Silvano Cirujano Cuesta <silvano.cirujano-cuesta@siemens.com> Suggested-by: Henning Schild <henning.schild@siemens.com>
This commit is contained in:
		
				
					committed by
					
						
						Daniel Wagner
					
				
			
			
				
	
			
			
			
						parent
						
							46c7d6e38c
						
					
				
				
					commit
					49a6bbfc82
				
			
							
								
								
									
										12
									
								
								kas-docker
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								kas-docker
									
									
									
									
									
								
							@@ -40,6 +40,8 @@ usage()
 | 
				
			|||||||
	printf "%b" "--docker-args\tAdditional arguments to pass to docker for" \
 | 
						printf "%b" "--docker-args\tAdditional arguments to pass to docker for" \
 | 
				
			||||||
		"running the build.\n"
 | 
							"running the build.\n"
 | 
				
			||||||
	printf "%b" "-v\t\tPrint operations.\n"
 | 
						printf "%b" "-v\t\tPrint operations.\n"
 | 
				
			||||||
 | 
						printf "%b" "--ssh-dir\tDirectory containing SSH configurations, " \
 | 
				
			||||||
 | 
							"avoid $HOME/.ssh unless you fully trust the container.\n"
 | 
				
			||||||
	exit 1
 | 
						exit 1
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -87,6 +89,11 @@ while [ $# -gt 0 ]; do
 | 
				
			|||||||
		USER_ARGS=$2
 | 
							USER_ARGS=$2
 | 
				
			||||||
		shift 2
 | 
							shift 2
 | 
				
			||||||
		;;
 | 
							;;
 | 
				
			||||||
 | 
						--ssh-dir)
 | 
				
			||||||
 | 
							[ $# -gt 2 ] || usage
 | 
				
			||||||
 | 
							SSH_DIR=$2
 | 
				
			||||||
 | 
							shift 2
 | 
				
			||||||
 | 
							;;
 | 
				
			||||||
	-v)
 | 
						-v)
 | 
				
			||||||
		VERBOSE=1
 | 
							VERBOSE=1
 | 
				
			||||||
		shift 1
 | 
							shift 1
 | 
				
			||||||
@@ -139,6 +146,11 @@ DOCKER_ARGS="-v ${REPO_DIR}:/repo:ro \
 | 
				
			|||||||
	     -v ${KAS_WORK_DIR}:/work:rw --workdir=/work \
 | 
						     -v ${KAS_WORK_DIR}:/work:rw --workdir=/work \
 | 
				
			||||||
	     -e USER_ID=$(id -u) -e GROUP_ID=$(id -g) --rm"
 | 
						     -e USER_ID=$(id -u) -e GROUP_ID=$(id -g) --rm"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if [ -n "${SSH_DIR}" ] ; then
 | 
				
			||||||
 | 
						[ -d "${SSH_DIR}" ] || echo "Passed SSH_VALUE '${SSH_DIR' is not a directory" ; exit 1
 | 
				
			||||||
 | 
						DOCKER_ARGS="${DOCKER_ARGS} -v $(readlink -f ${SSH_DIR}):/etc/skel/.ssh:ro"
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if [ -t 1 ]; then
 | 
					if [ -t 1 ]; then
 | 
				
			||||||
	DOCKER_ARGS="${DOCKER_ARGS} -t -i"
 | 
						DOCKER_ARGS="${DOCKER_ARGS} -t -i"
 | 
				
			||||||
fi
 | 
					fi
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user