-
Notifications
You must be signed in to change notification settings - Fork 3
/
ssh.sh
executable file
·40 lines (34 loc) · 874 Bytes
/
ssh.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/env bash
set -o errexit -o nounset -o pipefail
source "$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/scripts/common-functions.sh"
function usage {
echo "Usage: $0 <env> <machine> [ssh-args...]"
echo "Examples:"
echo " $0 qa ci"
echo " $0 prod app"
exit 1
}
function main {
if [ "${1:-}" = "" ]; then usage; fi
if [ "${2:-}" = "" ]; then usage; fi
local env="$1"
local server_name="$2"
local -r ssh_args="-F $repo/servers/ssh.config"
case "$env-$server_name" in
qa-ci)
ssh $ssh_args oph-va-ci-test01 "${@:3}"
;;
qa-app)
ssh $ssh_args oph-va-app-test01 "${@:3}"
;;
prod-app)
ssh $ssh_args oph-va-app-prod01 "${@:3}"
;;
prod-lb)
ssh $ssh_args oph-va-lb-prod01 "${@:3}"
;;
*)
fatal "error: Invalid environment or host ($env, $server_name)"
esac
}
main "$@"