mirror of
https://github.com/DictXiong/dotfiles.git
synced 2024-11-24 16:27:02 +08:00
riot: ob->ebd, swap option $1 and $2 and $2 is default to ssh
This commit is contained in:
parent
db79720354
commit
d560368861
32
scripts/riot
32
scripts/riot
|
@ -17,16 +17,11 @@ get_server_meta()
|
||||||
domain=""
|
domain=""
|
||||||
fi
|
fi
|
||||||
case $domain in
|
case $domain in
|
||||||
ibd )
|
ibd|ebd )
|
||||||
SERVER=$host.ibd.ink
|
SERVER=$host.$domain.ink
|
||||||
PORT=12022
|
PORT=12022
|
||||||
SSH_USERNAME=root
|
SSH_USERNAME=root
|
||||||
;;
|
;;
|
||||||
ob )
|
|
||||||
SERVER=$host.ob.ac.cn
|
|
||||||
PORT=24022
|
|
||||||
SSH_USERNAME=root
|
|
||||||
;;
|
|
||||||
nasp )
|
nasp )
|
||||||
SERVER=$host
|
SERVER=$host
|
||||||
PORT=22
|
PORT=22
|
||||||
|
@ -46,9 +41,8 @@ get_server_meta()
|
||||||
}
|
}
|
||||||
|
|
||||||
# ssh
|
# ssh
|
||||||
_ssh()
|
run_ssh()
|
||||||
{
|
{
|
||||||
get_server_meta "$1"
|
|
||||||
fmt_note "--> ssh to $SERVER:$PORT"
|
fmt_note "--> ssh to $SERVER:$PORT"
|
||||||
eval ssh -p $PORT $SSH_OPTIONS $SSH_USERNAME@$SERVER
|
eval ssh -p $PORT $SSH_OPTIONS $SSH_USERNAME@$SERVER
|
||||||
}
|
}
|
||||||
|
@ -56,23 +50,29 @@ _ssh()
|
||||||
# main
|
# main
|
||||||
print_help()
|
print_help()
|
||||||
{
|
{
|
||||||
fmt_info "usage: $0 <command> <service> [options]"
|
fmt_info "usage: $0 <service> [command] [options]"
|
||||||
echo "available commands: ssh"
|
echo "available commands: ssh (default)"
|
||||||
}
|
}
|
||||||
|
|
||||||
router()
|
router()
|
||||||
{
|
{
|
||||||
test $# -eq 2 || (print_help && fmt_fatal "invalid arguments")
|
test -n "$1" || (print_help && fmt_fatal "invalid arguments")
|
||||||
case $1 in
|
if [[ "$1" == "-h" || "$1" == "--help" ]]; then
|
||||||
|
print_help
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
get_server_meta "$1"
|
||||||
|
case $2 in
|
||||||
-h|--help)
|
-h|--help)
|
||||||
print_help
|
print_help
|
||||||
|
exit
|
||||||
;;
|
;;
|
||||||
ssh )
|
ssh|"" )
|
||||||
_ssh "$2"
|
run_ssh
|
||||||
;;
|
;;
|
||||||
* )
|
* )
|
||||||
print_help
|
print_help
|
||||||
fmt_fatal "unknown command: $1"
|
fmt_fatal "unknown command: $2"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user