mirror of
https://github.com/DictXiong/dotfiles.git
synced 2024-11-24 13:47:01 +08:00
Compare commits
2 Commits
37abe68d1f
...
4e5dfce9fb
Author | SHA1 | Date | |
---|---|---|---|
|
4e5dfce9fb | ||
|
c5841e4aaa |
88
scripts/riot
88
scripts/riot
|
@ -91,24 +91,25 @@ 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
|
||||||
while [[ -n $remote ]]; do
|
while [[ -n $remote ]]; do
|
||||||
local server=${remote%%,*}
|
local server=${remote%%/*}
|
||||||
remote=${remote#*,}
|
remote=${remote#*/}
|
||||||
get_server_meta "$server"
|
get_server_meta "$server"
|
||||||
if [[ -n "$RET_JUMP_SERVER" ]]; then
|
if [[ -n "$RET_JUMP_SERVER" ]]; then
|
||||||
jump_servers="$jump_servers${jump_servers:+,}$RET_JUMP_SERVER"
|
jump_servers="$jump_servers${jump_servers:+,}$RET_JUMP_SERVER"
|
||||||
|
@ -212,35 +213,38 @@ router() {
|
||||||
print_help
|
print_help
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
parse_remote "$1"
|
|
||||||
case $2 in
|
IFS=',' read -ra remotes <<< "$1"
|
||||||
-h|--help)
|
for remote in "${remotes[@]}"; do
|
||||||
print_help
|
if [[ -z "$remote" ]]; then
|
||||||
exit
|
continue
|
||||||
;;
|
fi
|
||||||
ssh|"" )
|
parse_remote "$remote"
|
||||||
run_ssh ssh "${@:3}"
|
case $2 in
|
||||||
;;
|
ssh|"" )
|
||||||
zssh )
|
run_ssh ssh "${@:3}"
|
||||||
run_ssh zssh
|
;;
|
||||||
;;
|
zssh )
|
||||||
sftp )
|
run_ssh zssh
|
||||||
run_ssh sftp
|
;;
|
||||||
;;
|
sftp )
|
||||||
sshl )
|
run_ssh sftp
|
||||||
test -n "$3" || fmt_fatal "no target address provided"
|
;;
|
||||||
run_sshl "$3"
|
sshl )
|
||||||
;;
|
test -n "$3" || fmt_fatal "no target address provided"
|
||||||
scp )
|
run_sshl "$3"
|
||||||
test -n "$3" || fmt_fatal "no source path specified"
|
;;
|
||||||
test -n "$4" || fmt_fatal "no destination path specified"
|
scp )
|
||||||
run_scp "$3" "$4"
|
test -n "$3" || fmt_fatal "no source path specified"
|
||||||
;;
|
test -n "$4" || fmt_fatal "no destination path specified"
|
||||||
* )
|
run_scp "$3" "$4"
|
||||||
print_help
|
;;
|
||||||
fmt_fatal "unknown command: $2"
|
* )
|
||||||
;;
|
print_help
|
||||||
esac
|
fmt_fatal "unknown command: $2"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
router "${GOT_OPTS[@]}"
|
router "${GOT_OPTS[@]}"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user