mirror of
https://github.com/DictXiong/dotfiles.git
synced 2024-11-24 12:47:01 +08:00
riot: support multiple remotes, delimiter=comma (,)
This commit is contained in:
parent
c5841e4aaa
commit
4e5dfce9fb
36
scripts/riot
36
scripts/riot
|
@ -91,18 +91,19 @@ get_server_meta() {
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
# remote setting, including jump servers
|
|
||||||
# will be called only once
|
|
||||||
# provides:
|
|
||||||
SERVER=""
|
|
||||||
TRUST_SERVER=1
|
|
||||||
PORT="" # optional
|
|
||||||
USERNAME="" # optional
|
|
||||||
SSH_OPTIONS="" # optional
|
|
||||||
if [[ "$RIOT_TRUST_CLIENT" == "1" ]]; then
|
|
||||||
SSH_OPTIONS='-o ControlMaster=auto -o ControlPath=/tmp/sshcm-%C -o PermitLocalCommand=yes'
|
|
||||||
fi
|
|
||||||
parse_remote() {
|
parse_remote() {
|
||||||
|
# remote setting, including jump servers
|
||||||
|
# called for every remote
|
||||||
|
# provides:
|
||||||
|
SERVER=""
|
||||||
|
TRUST_SERVER=1
|
||||||
|
PORT="" # optional
|
||||||
|
USERNAME="" # optional
|
||||||
|
SSH_OPTIONS="" # optional
|
||||||
|
if [[ "$RIOT_TRUST_CLIENT" == "1" ]]; then
|
||||||
|
SSH_OPTIONS='-o ControlMaster=auto -o ControlPath=/tmp/sshcm-%C -o PermitLocalCommand=yes'
|
||||||
|
fi
|
||||||
|
# handle input
|
||||||
local remote="$1"
|
local remote="$1"
|
||||||
local jump_servers=""
|
local jump_servers=""
|
||||||
# loop for jump servers
|
# loop for jump servers
|
||||||
|
@ -212,12 +213,14 @@ router() {
|
||||||
print_help
|
print_help
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
parse_remote "$1"
|
|
||||||
|
IFS=',' read -ra remotes <<< "$1"
|
||||||
|
for remote in "${remotes[@]}"; do
|
||||||
|
if [[ -z "$remote" ]]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
parse_remote "$remote"
|
||||||
case $2 in
|
case $2 in
|
||||||
-h|--help)
|
|
||||||
print_help
|
|
||||||
exit
|
|
||||||
;;
|
|
||||||
ssh|"" )
|
ssh|"" )
|
||||||
run_ssh ssh "${@:3}"
|
run_ssh ssh "${@:3}"
|
||||||
;;
|
;;
|
||||||
|
@ -241,6 +244,7 @@ router() {
|
||||||
fmt_fatal "unknown command: $2"
|
fmt_fatal "unknown command: $2"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
router "${GOT_OPTS[@]}"
|
router "${GOT_OPTS[@]}"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user