-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8b8ae01
commit bce19ae
Showing
2 changed files
with
40 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/bin/bash | ||
|
||
# shellcheck source=./bin/sr3_utils | ||
source "${BASH_SOURCE%/*}/sr3_utils" | ||
|
||
if [[ $# == 0 ]]; then | ||
echo '[ERROR] no destination given' | ||
echo 'Usage: sr3_scp destination_server:remotepath localpath' | ||
exit 2 | ||
fi | ||
|
||
# sets git_tld and pump_name | ||
sr3_get_git_path_pump_name | ||
|
||
echo "Data Pump Name: ${pump_name}." | ||
|
||
# Use ssh user config file (pumpname_ssh_config) if present | ||
ssh_user_config="${git_tld}/_dsh_config/${pump_name}_ssh_config" | ||
ssh_args="" | ||
if [ -e "${ssh_user_config}" ]; then | ||
ssh_args="${ssh_args} -F${ssh_user_config}" | ||
else | ||
echo "[WARNING] ${ssh_user_config} doesn't exist, sr3_scp will not do anything different than normal scp." | ||
fi | ||
|
||
# ssh-agent environment variables are required when proxying the SSH connection through a jump server using `ssh-add` | ||
unset_ssh_agent=false | ||
if [ -e "${ssh_user_config}" ] && { [ -z "${SSH_AUTH_SOCK}" ] || [ -z "${SSH_AGENT_PID}" ]; } && grep -q "ssh-add" "${ssh_user_config}"; then | ||
eval "$(ssh-agent -s)" > /dev/null | ||
unset_ssh_agent=true | ||
fi | ||
|
||
# shellcheck disable=SC2086,SC2029 | ||
scp ${ssh_args} "$@" | ||
|
||
# Clean up ssh-agent | ||
if [ "${unset_ssh_agent}" = "true" ] && [ -n "${SSH_AGENT_PID}" ]; then | ||
eval "$(ssh-agent -k)" > /dev/null | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters