From d5603688616d215448e4c8eff702ee901226e6c0 Mon Sep 17 00:00:00 2001 From: Dict Xiong Date: Sat, 25 Feb 2023 00:00:44 +0800 Subject: [PATCH] riot: ob->ebd, swap option $1 and $2 and $2 is default to ssh --- scripts/riot | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/scripts/riot b/scripts/riot index dd392f6..09f2efe 100755 --- a/scripts/riot +++ b/scripts/riot @@ -17,16 +17,11 @@ get_server_meta() domain="" fi case $domain in - ibd ) - SERVER=$host.ibd.ink + ibd|ebd ) + SERVER=$host.$domain.ink PORT=12022 SSH_USERNAME=root ;; - ob ) - SERVER=$host.ob.ac.cn - PORT=24022 - SSH_USERNAME=root - ;; nasp ) SERVER=$host PORT=22 @@ -46,9 +41,8 @@ get_server_meta() } # ssh -_ssh() +run_ssh() { - get_server_meta "$1" fmt_note "--> ssh to $SERVER:$PORT" eval ssh -p $PORT $SSH_OPTIONS $SSH_USERNAME@$SERVER } @@ -56,23 +50,29 @@ _ssh() # main print_help() { - fmt_info "usage: $0 [options]" - echo "available commands: ssh" + fmt_info "usage: $0 [command] [options]" + echo "available commands: ssh (default)" } router() { - test $# -eq 2 || (print_help && fmt_fatal "invalid arguments") - case $1 in + test -n "$1" || (print_help && fmt_fatal "invalid arguments") + if [[ "$1" == "-h" || "$1" == "--help" ]]; then + print_help + exit + fi + get_server_meta "$1" + case $2 in -h|--help) print_help + exit ;; - ssh ) - _ssh "$2" + ssh|"" ) + run_ssh ;; * ) print_help - fmt_fatal "unknown command: $1" + fmt_fatal "unknown command: $2" ;; esac }