dotfiles/scripts/riot

130 lines
2.8 KiB
Plaintext
Raw Normal View History

#!/bin/bash
# connect to iot services
THIS_DIR=$( cd "$( dirname "${BASH_SOURCE[0]:-${(%):-%x}}" )" && pwd )
source "$THIS_DIR/../tools/common.sh"
# get target settings
# provides:
SERVER=""
PORT="" # optional
USERNAME="" # optional
SSH_OPTIONS="" # optional
get_server_meta()
{
arg="$1"
# overwrite
if [[ "$arg" == *@* ]]; then
USERNAME=${arg%%@*}
arg=${arg#*@}
fi
if [[ "$arg" == *:* ]]; then
PORT=${arg##*:}
arg=${arg%:*}
fi
# presets
local domain=${arg##*.}
local host=${arg%.*}
if [[ -z "$domain" ]]; then
domain="ibd"
fi
if [[ "$host" == "$domain" ]]; then
domain="proxied"
fi
case $domain in
[dev] ddns; better ssh agent; riot sshl; sys.online; zsh hist import; DFS_DEBUG; cbd/cbds (#36) * riot: bj1 -> proxy * ci: test ask_for_yn * --wip-- [skip ci] * install.sh: will prompt version * zshrc: piv-agent now can re-use agents * zshrc: in docker use theme robbyrussell * update.sh: will send online beacon * beacon: support meta with limited len 64 * bug fix (Sat Jan 21 16:45:35 CST 2023) * well, finally add ssh key for ltp1-bd * set DFS_INITED and do not send login beacon if it was set * rewrite piv-agent to sagent; fmt_note and fmt_into will write to stderr * bug fix (Mon Jan 30 19:41:00 CST 2023) * bug fix (Mon Jan 30 19:46:27 CST 2023) * login beacon add details * $DFS_ORPHAN turns logger off * disable more beacons in CI * install.sh: prepare config earlier * init pbin * install.sh: -H|--hist|--history * install.sh: -H hint * install.sh: -H support multiple keys * fix zsh hist with no new line at the end * remove ^M in hist * bug fix (Wed Feb 1 21:11:41 CST 2023) * bug fix (Wed Feb 1 21:16:29 CST 2023) * bug fix (Wed Feb 1 21:20:21 CST 2023) * ci will send gh.ci.fail * show install opts * DFS_DEBUG to set -x * bug fix: install.sh re-start itself with no args incorrectly * bug fix (Thu Feb 2 18:43:16 CST 2023) * riot: ob->ebd, swap option $1 and $2 and $2 is default to ssh * riot: introduce sshl * logger.sh: support ddns * bug fix (Wed Mar 1 16:37:42 CST 2023) * dfs.ddns.failed -> dfs.ddns.fail * login beacon 2>/dev/null * logger.sh -> frigg-client.sh; curl add time limit 10s * to-install.sh: improve docker-ce * use $DFS_CURL_OPTIONS * ci: add ddns * bug fix (Wed Mar 15 19:37:21 CST 2023) * Revert "bug fix (Wed Mar 15 19:37:21 CST 2023)" This reverts commit 2df87ce1a8893d832e665a0429c7f9e7ae1108eb. * Revert "ci: add ddns" This reverts commit 4fe83215048b05ae3234ce801ac67856d0fea52e. * alias cbd and cbds, riot nasp port to 12022 * .zshrc: sagent -> sagt * fix ci * riot: bug fix when 'tmp' has leading zeros * add ci for cbds --------- Co-authored-by: xiongdian.me <xiongdian.me@bytedance.com>
2023-04-21 12:37:05 +08:00
ibd|ebd )
SERVER=$host.$domain.ink
PORT=${PORT:-12022}
USERNAME=${USERNAME:-root}
;;
nasp )
SERVER=$host
PORT=${PORT:-12022}
USERNAME=${USERNAME:-dictxiong}
SSH_OPTIONS='-o ProxyJump="ssh@nasp.ob.ac.cn:36022"'
;;
proxied )
[dev] ddns; better ssh agent; riot sshl; sys.online; zsh hist import; DFS_DEBUG; cbd/cbds (#36) * riot: bj1 -> proxy * ci: test ask_for_yn * --wip-- [skip ci] * install.sh: will prompt version * zshrc: piv-agent now can re-use agents * zshrc: in docker use theme robbyrussell * update.sh: will send online beacon * beacon: support meta with limited len 64 * bug fix (Sat Jan 21 16:45:35 CST 2023) * well, finally add ssh key for ltp1-bd * set DFS_INITED and do not send login beacon if it was set * rewrite piv-agent to sagent; fmt_note and fmt_into will write to stderr * bug fix (Mon Jan 30 19:41:00 CST 2023) * bug fix (Mon Jan 30 19:46:27 CST 2023) * login beacon add details * $DFS_ORPHAN turns logger off * disable more beacons in CI * install.sh: prepare config earlier * init pbin * install.sh: -H|--hist|--history * install.sh: -H hint * install.sh: -H support multiple keys * fix zsh hist with no new line at the end * remove ^M in hist * bug fix (Wed Feb 1 21:11:41 CST 2023) * bug fix (Wed Feb 1 21:16:29 CST 2023) * bug fix (Wed Feb 1 21:20:21 CST 2023) * ci will send gh.ci.fail * show install opts * DFS_DEBUG to set -x * bug fix: install.sh re-start itself with no args incorrectly * bug fix (Thu Feb 2 18:43:16 CST 2023) * riot: ob->ebd, swap option $1 and $2 and $2 is default to ssh * riot: introduce sshl * logger.sh: support ddns * bug fix (Wed Mar 1 16:37:42 CST 2023) * dfs.ddns.failed -> dfs.ddns.fail * login beacon 2>/dev/null * logger.sh -> frigg-client.sh; curl add time limit 10s * to-install.sh: improve docker-ce * use $DFS_CURL_OPTIONS * ci: add ddns * bug fix (Wed Mar 15 19:37:21 CST 2023) * Revert "bug fix (Wed Mar 15 19:37:21 CST 2023)" This reverts commit 2df87ce1a8893d832e665a0429c7f9e7ae1108eb. * Revert "ci: add ddns" This reverts commit 4fe83215048b05ae3234ce801ac67856d0fea52e. * alias cbd and cbds, riot nasp port to 12022 * .zshrc: sagent -> sagt * fix ci * riot: bug fix when 'tmp' has leading zeros * add ci for cbds --------- Co-authored-by: xiongdian.me <xiongdian.me@bytedance.com>
2023-04-21 12:37:05 +08:00
SERVER=proxy.beardic.cn
local tmp=$(sha256sum <<< "$host" | tr -cd "[:digit:]")
tmp=${tmp:0:4}
[dev] ddns; better ssh agent; riot sshl; sys.online; zsh hist import; DFS_DEBUG; cbd/cbds (#36) * riot: bj1 -> proxy * ci: test ask_for_yn * --wip-- [skip ci] * install.sh: will prompt version * zshrc: piv-agent now can re-use agents * zshrc: in docker use theme robbyrussell * update.sh: will send online beacon * beacon: support meta with limited len 64 * bug fix (Sat Jan 21 16:45:35 CST 2023) * well, finally add ssh key for ltp1-bd * set DFS_INITED and do not send login beacon if it was set * rewrite piv-agent to sagent; fmt_note and fmt_into will write to stderr * bug fix (Mon Jan 30 19:41:00 CST 2023) * bug fix (Mon Jan 30 19:46:27 CST 2023) * login beacon add details * $DFS_ORPHAN turns logger off * disable more beacons in CI * install.sh: prepare config earlier * init pbin * install.sh: -H|--hist|--history * install.sh: -H hint * install.sh: -H support multiple keys * fix zsh hist with no new line at the end * remove ^M in hist * bug fix (Wed Feb 1 21:11:41 CST 2023) * bug fix (Wed Feb 1 21:16:29 CST 2023) * bug fix (Wed Feb 1 21:20:21 CST 2023) * ci will send gh.ci.fail * show install opts * DFS_DEBUG to set -x * bug fix: install.sh re-start itself with no args incorrectly * bug fix (Thu Feb 2 18:43:16 CST 2023) * riot: ob->ebd, swap option $1 and $2 and $2 is default to ssh * riot: introduce sshl * logger.sh: support ddns * bug fix (Wed Mar 1 16:37:42 CST 2023) * dfs.ddns.failed -> dfs.ddns.fail * login beacon 2>/dev/null * logger.sh -> frigg-client.sh; curl add time limit 10s * to-install.sh: improve docker-ce * use $DFS_CURL_OPTIONS * ci: add ddns * bug fix (Wed Mar 15 19:37:21 CST 2023) * Revert "bug fix (Wed Mar 15 19:37:21 CST 2023)" This reverts commit 2df87ce1a8893d832e665a0429c7f9e7ae1108eb. * Revert "ci: add ddns" This reverts commit 4fe83215048b05ae3234ce801ac67856d0fea52e. * alias cbd and cbds, riot nasp port to 12022 * .zshrc: sagent -> sagt * fix ci * riot: bug fix when 'tmp' has leading zeros * add ci for cbds --------- Co-authored-by: xiongdian.me <xiongdian.me@bytedance.com>
2023-04-21 12:37:05 +08:00
PORT=$((10#$tmp+36000))
USERNAME=root
;;
* )
fmt_warning "unknown domain: $domain. will try as server name"
SERVER="$arg"
esac
}
# ssh
[dev] ddns; better ssh agent; riot sshl; sys.online; zsh hist import; DFS_DEBUG; cbd/cbds (#36) * riot: bj1 -> proxy * ci: test ask_for_yn * --wip-- [skip ci] * install.sh: will prompt version * zshrc: piv-agent now can re-use agents * zshrc: in docker use theme robbyrussell * update.sh: will send online beacon * beacon: support meta with limited len 64 * bug fix (Sat Jan 21 16:45:35 CST 2023) * well, finally add ssh key for ltp1-bd * set DFS_INITED and do not send login beacon if it was set * rewrite piv-agent to sagent; fmt_note and fmt_into will write to stderr * bug fix (Mon Jan 30 19:41:00 CST 2023) * bug fix (Mon Jan 30 19:46:27 CST 2023) * login beacon add details * $DFS_ORPHAN turns logger off * disable more beacons in CI * install.sh: prepare config earlier * init pbin * install.sh: -H|--hist|--history * install.sh: -H hint * install.sh: -H support multiple keys * fix zsh hist with no new line at the end * remove ^M in hist * bug fix (Wed Feb 1 21:11:41 CST 2023) * bug fix (Wed Feb 1 21:16:29 CST 2023) * bug fix (Wed Feb 1 21:20:21 CST 2023) * ci will send gh.ci.fail * show install opts * DFS_DEBUG to set -x * bug fix: install.sh re-start itself with no args incorrectly * bug fix (Thu Feb 2 18:43:16 CST 2023) * riot: ob->ebd, swap option $1 and $2 and $2 is default to ssh * riot: introduce sshl * logger.sh: support ddns * bug fix (Wed Mar 1 16:37:42 CST 2023) * dfs.ddns.failed -> dfs.ddns.fail * login beacon 2>/dev/null * logger.sh -> frigg-client.sh; curl add time limit 10s * to-install.sh: improve docker-ce * use $DFS_CURL_OPTIONS * ci: add ddns * bug fix (Wed Mar 15 19:37:21 CST 2023) * Revert "bug fix (Wed Mar 15 19:37:21 CST 2023)" This reverts commit 2df87ce1a8893d832e665a0429c7f9e7ae1108eb. * Revert "ci: add ddns" This reverts commit 4fe83215048b05ae3234ce801ac67856d0fea52e. * alias cbd and cbds, riot nasp port to 12022 * .zshrc: sagent -> sagt * fix ci * riot: bug fix when 'tmp' has leading zeros * add ci for cbds --------- Co-authored-by: xiongdian.me <xiongdian.me@bytedance.com>
2023-04-21 12:37:05 +08:00
run_ssh()
{
CMD="ssh ${PORT:+-p} $PORT $SSH_OPTIONS $USERNAME${USERNAME:+@}$SERVER"
[dev] ddns; better ssh agent; riot sshl; sys.online; zsh hist import; DFS_DEBUG; cbd/cbds (#36) * riot: bj1 -> proxy * ci: test ask_for_yn * --wip-- [skip ci] * install.sh: will prompt version * zshrc: piv-agent now can re-use agents * zshrc: in docker use theme robbyrussell * update.sh: will send online beacon * beacon: support meta with limited len 64 * bug fix (Sat Jan 21 16:45:35 CST 2023) * well, finally add ssh key for ltp1-bd * set DFS_INITED and do not send login beacon if it was set * rewrite piv-agent to sagent; fmt_note and fmt_into will write to stderr * bug fix (Mon Jan 30 19:41:00 CST 2023) * bug fix (Mon Jan 30 19:46:27 CST 2023) * login beacon add details * $DFS_ORPHAN turns logger off * disable more beacons in CI * install.sh: prepare config earlier * init pbin * install.sh: -H|--hist|--history * install.sh: -H hint * install.sh: -H support multiple keys * fix zsh hist with no new line at the end * remove ^M in hist * bug fix (Wed Feb 1 21:11:41 CST 2023) * bug fix (Wed Feb 1 21:16:29 CST 2023) * bug fix (Wed Feb 1 21:20:21 CST 2023) * ci will send gh.ci.fail * show install opts * DFS_DEBUG to set -x * bug fix: install.sh re-start itself with no args incorrectly * bug fix (Thu Feb 2 18:43:16 CST 2023) * riot: ob->ebd, swap option $1 and $2 and $2 is default to ssh * riot: introduce sshl * logger.sh: support ddns * bug fix (Wed Mar 1 16:37:42 CST 2023) * dfs.ddns.failed -> dfs.ddns.fail * login beacon 2>/dev/null * logger.sh -> frigg-client.sh; curl add time limit 10s * to-install.sh: improve docker-ce * use $DFS_CURL_OPTIONS * ci: add ddns * bug fix (Wed Mar 15 19:37:21 CST 2023) * Revert "bug fix (Wed Mar 15 19:37:21 CST 2023)" This reverts commit 2df87ce1a8893d832e665a0429c7f9e7ae1108eb. * Revert "ci: add ddns" This reverts commit 4fe83215048b05ae3234ce801ac67856d0fea52e. * alias cbd and cbds, riot nasp port to 12022 * .zshrc: sagent -> sagt * fix ci * riot: bug fix when 'tmp' has leading zeros * add ci for cbds --------- Co-authored-by: xiongdian.me <xiongdian.me@bytedance.com>
2023-04-21 12:37:05 +08:00
fmt_note "-->" $CMD
if [[ "$DFS_DRY_RUN" == "1" ]]; then
echo $CMD
else
eval $CMD
fi
[dev] ddns; better ssh agent; riot sshl; sys.online; zsh hist import; DFS_DEBUG; cbd/cbds (#36) * riot: bj1 -> proxy * ci: test ask_for_yn * --wip-- [skip ci] * install.sh: will prompt version * zshrc: piv-agent now can re-use agents * zshrc: in docker use theme robbyrussell * update.sh: will send online beacon * beacon: support meta with limited len 64 * bug fix (Sat Jan 21 16:45:35 CST 2023) * well, finally add ssh key for ltp1-bd * set DFS_INITED and do not send login beacon if it was set * rewrite piv-agent to sagent; fmt_note and fmt_into will write to stderr * bug fix (Mon Jan 30 19:41:00 CST 2023) * bug fix (Mon Jan 30 19:46:27 CST 2023) * login beacon add details * $DFS_ORPHAN turns logger off * disable more beacons in CI * install.sh: prepare config earlier * init pbin * install.sh: -H|--hist|--history * install.sh: -H hint * install.sh: -H support multiple keys * fix zsh hist with no new line at the end * remove ^M in hist * bug fix (Wed Feb 1 21:11:41 CST 2023) * bug fix (Wed Feb 1 21:16:29 CST 2023) * bug fix (Wed Feb 1 21:20:21 CST 2023) * ci will send gh.ci.fail * show install opts * DFS_DEBUG to set -x * bug fix: install.sh re-start itself with no args incorrectly * bug fix (Thu Feb 2 18:43:16 CST 2023) * riot: ob->ebd, swap option $1 and $2 and $2 is default to ssh * riot: introduce sshl * logger.sh: support ddns * bug fix (Wed Mar 1 16:37:42 CST 2023) * dfs.ddns.failed -> dfs.ddns.fail * login beacon 2>/dev/null * logger.sh -> frigg-client.sh; curl add time limit 10s * to-install.sh: improve docker-ce * use $DFS_CURL_OPTIONS * ci: add ddns * bug fix (Wed Mar 15 19:37:21 CST 2023) * Revert "bug fix (Wed Mar 15 19:37:21 CST 2023)" This reverts commit 2df87ce1a8893d832e665a0429c7f9e7ae1108eb. * Revert "ci: add ddns" This reverts commit 4fe83215048b05ae3234ce801ac67856d0fea52e. * alias cbd and cbds, riot nasp port to 12022 * .zshrc: sagent -> sagt * fix ci * riot: bug fix when 'tmp' has leading zeros * add ci for cbds --------- Co-authored-by: xiongdian.me <xiongdian.me@bytedance.com>
2023-04-21 12:37:05 +08:00
}
# sshl
run_sshl()
{
if [[ -z "$1" ]]; then
[dev] ddns; better ssh agent; riot sshl; sys.online; zsh hist import; DFS_DEBUG; cbd/cbds (#36) * riot: bj1 -> proxy * ci: test ask_for_yn * --wip-- [skip ci] * install.sh: will prompt version * zshrc: piv-agent now can re-use agents * zshrc: in docker use theme robbyrussell * update.sh: will send online beacon * beacon: support meta with limited len 64 * bug fix (Sat Jan 21 16:45:35 CST 2023) * well, finally add ssh key for ltp1-bd * set DFS_INITED and do not send login beacon if it was set * rewrite piv-agent to sagent; fmt_note and fmt_into will write to stderr * bug fix (Mon Jan 30 19:41:00 CST 2023) * bug fix (Mon Jan 30 19:46:27 CST 2023) * login beacon add details * $DFS_ORPHAN turns logger off * disable more beacons in CI * install.sh: prepare config earlier * init pbin * install.sh: -H|--hist|--history * install.sh: -H hint * install.sh: -H support multiple keys * fix zsh hist with no new line at the end * remove ^M in hist * bug fix (Wed Feb 1 21:11:41 CST 2023) * bug fix (Wed Feb 1 21:16:29 CST 2023) * bug fix (Wed Feb 1 21:20:21 CST 2023) * ci will send gh.ci.fail * show install opts * DFS_DEBUG to set -x * bug fix: install.sh re-start itself with no args incorrectly * bug fix (Thu Feb 2 18:43:16 CST 2023) * riot: ob->ebd, swap option $1 and $2 and $2 is default to ssh * riot: introduce sshl * logger.sh: support ddns * bug fix (Wed Mar 1 16:37:42 CST 2023) * dfs.ddns.failed -> dfs.ddns.fail * login beacon 2>/dev/null * logger.sh -> frigg-client.sh; curl add time limit 10s * to-install.sh: improve docker-ce * use $DFS_CURL_OPTIONS * ci: add ddns * bug fix (Wed Mar 15 19:37:21 CST 2023) * Revert "bug fix (Wed Mar 15 19:37:21 CST 2023)" This reverts commit 2df87ce1a8893d832e665a0429c7f9e7ae1108eb. * Revert "ci: add ddns" This reverts commit 4fe83215048b05ae3234ce801ac67856d0fea52e. * alias cbd and cbds, riot nasp port to 12022 * .zshrc: sagent -> sagt * fix ci * riot: bug fix when 'tmp' has leading zeros * add ci for cbds --------- Co-authored-by: xiongdian.me <xiongdian.me@bytedance.com>
2023-04-21 12:37:05 +08:00
fmt_fatal "invalid remote address: $1"
fi
arg="$1"
if [[ "$arg" != *":"* ]]; then
# treat as a port number
arg=localhost:$arg
fi
[dev] ddns; better ssh agent; riot sshl; sys.online; zsh hist import; DFS_DEBUG; cbd/cbds (#36) * riot: bj1 -> proxy * ci: test ask_for_yn * --wip-- [skip ci] * install.sh: will prompt version * zshrc: piv-agent now can re-use agents * zshrc: in docker use theme robbyrussell * update.sh: will send online beacon * beacon: support meta with limited len 64 * bug fix (Sat Jan 21 16:45:35 CST 2023) * well, finally add ssh key for ltp1-bd * set DFS_INITED and do not send login beacon if it was set * rewrite piv-agent to sagent; fmt_note and fmt_into will write to stderr * bug fix (Mon Jan 30 19:41:00 CST 2023) * bug fix (Mon Jan 30 19:46:27 CST 2023) * login beacon add details * $DFS_ORPHAN turns logger off * disable more beacons in CI * install.sh: prepare config earlier * init pbin * install.sh: -H|--hist|--history * install.sh: -H hint * install.sh: -H support multiple keys * fix zsh hist with no new line at the end * remove ^M in hist * bug fix (Wed Feb 1 21:11:41 CST 2023) * bug fix (Wed Feb 1 21:16:29 CST 2023) * bug fix (Wed Feb 1 21:20:21 CST 2023) * ci will send gh.ci.fail * show install opts * DFS_DEBUG to set -x * bug fix: install.sh re-start itself with no args incorrectly * bug fix (Thu Feb 2 18:43:16 CST 2023) * riot: ob->ebd, swap option $1 and $2 and $2 is default to ssh * riot: introduce sshl * logger.sh: support ddns * bug fix (Wed Mar 1 16:37:42 CST 2023) * dfs.ddns.failed -> dfs.ddns.fail * login beacon 2>/dev/null * logger.sh -> frigg-client.sh; curl add time limit 10s * to-install.sh: improve docker-ce * use $DFS_CURL_OPTIONS * ci: add ddns * bug fix (Wed Mar 15 19:37:21 CST 2023) * Revert "bug fix (Wed Mar 15 19:37:21 CST 2023)" This reverts commit 2df87ce1a8893d832e665a0429c7f9e7ae1108eb. * Revert "ci: add ddns" This reverts commit 4fe83215048b05ae3234ce801ac67856d0fea52e. * alias cbd and cbds, riot nasp port to 12022 * .zshrc: sagent -> sagt * fix ci * riot: bug fix when 'tmp' has leading zeros * add ci for cbds --------- Co-authored-by: xiongdian.me <xiongdian.me@bytedance.com>
2023-04-21 12:37:05 +08:00
while
local port=$(shuf -n 1 -i 49152-65535)
netstat -atun | grep -q "$port"
do
continue
done
CMD="ssh ${PORT:+-p} $PORT $SSH_OPTIONS -NC -L $port:$arg $USERNAME${USERNAME:+@}$SERVER"
[dev] ddns; better ssh agent; riot sshl; sys.online; zsh hist import; DFS_DEBUG; cbd/cbds (#36) * riot: bj1 -> proxy * ci: test ask_for_yn * --wip-- [skip ci] * install.sh: will prompt version * zshrc: piv-agent now can re-use agents * zshrc: in docker use theme robbyrussell * update.sh: will send online beacon * beacon: support meta with limited len 64 * bug fix (Sat Jan 21 16:45:35 CST 2023) * well, finally add ssh key for ltp1-bd * set DFS_INITED and do not send login beacon if it was set * rewrite piv-agent to sagent; fmt_note and fmt_into will write to stderr * bug fix (Mon Jan 30 19:41:00 CST 2023) * bug fix (Mon Jan 30 19:46:27 CST 2023) * login beacon add details * $DFS_ORPHAN turns logger off * disable more beacons in CI * install.sh: prepare config earlier * init pbin * install.sh: -H|--hist|--history * install.sh: -H hint * install.sh: -H support multiple keys * fix zsh hist with no new line at the end * remove ^M in hist * bug fix (Wed Feb 1 21:11:41 CST 2023) * bug fix (Wed Feb 1 21:16:29 CST 2023) * bug fix (Wed Feb 1 21:20:21 CST 2023) * ci will send gh.ci.fail * show install opts * DFS_DEBUG to set -x * bug fix: install.sh re-start itself with no args incorrectly * bug fix (Thu Feb 2 18:43:16 CST 2023) * riot: ob->ebd, swap option $1 and $2 and $2 is default to ssh * riot: introduce sshl * logger.sh: support ddns * bug fix (Wed Mar 1 16:37:42 CST 2023) * dfs.ddns.failed -> dfs.ddns.fail * login beacon 2>/dev/null * logger.sh -> frigg-client.sh; curl add time limit 10s * to-install.sh: improve docker-ce * use $DFS_CURL_OPTIONS * ci: add ddns * bug fix (Wed Mar 15 19:37:21 CST 2023) * Revert "bug fix (Wed Mar 15 19:37:21 CST 2023)" This reverts commit 2df87ce1a8893d832e665a0429c7f9e7ae1108eb. * Revert "ci: add ddns" This reverts commit 4fe83215048b05ae3234ce801ac67856d0fea52e. * alias cbd and cbds, riot nasp port to 12022 * .zshrc: sagent -> sagt * fix ci * riot: bug fix when 'tmp' has leading zeros * add ci for cbds --------- Co-authored-by: xiongdian.me <xiongdian.me@bytedance.com>
2023-04-21 12:37:05 +08:00
fmt_note "-->" $CMD
fmt_note " > please access localhost:$port"
if [[ "$DFS_DRY_RUN" == "1" ]]; then
echo $CMD
else
eval $CMD
fi
}
# main
print_help()
{
[dev] ddns; better ssh agent; riot sshl; sys.online; zsh hist import; DFS_DEBUG; cbd/cbds (#36) * riot: bj1 -> proxy * ci: test ask_for_yn * --wip-- [skip ci] * install.sh: will prompt version * zshrc: piv-agent now can re-use agents * zshrc: in docker use theme robbyrussell * update.sh: will send online beacon * beacon: support meta with limited len 64 * bug fix (Sat Jan 21 16:45:35 CST 2023) * well, finally add ssh key for ltp1-bd * set DFS_INITED and do not send login beacon if it was set * rewrite piv-agent to sagent; fmt_note and fmt_into will write to stderr * bug fix (Mon Jan 30 19:41:00 CST 2023) * bug fix (Mon Jan 30 19:46:27 CST 2023) * login beacon add details * $DFS_ORPHAN turns logger off * disable more beacons in CI * install.sh: prepare config earlier * init pbin * install.sh: -H|--hist|--history * install.sh: -H hint * install.sh: -H support multiple keys * fix zsh hist with no new line at the end * remove ^M in hist * bug fix (Wed Feb 1 21:11:41 CST 2023) * bug fix (Wed Feb 1 21:16:29 CST 2023) * bug fix (Wed Feb 1 21:20:21 CST 2023) * ci will send gh.ci.fail * show install opts * DFS_DEBUG to set -x * bug fix: install.sh re-start itself with no args incorrectly * bug fix (Thu Feb 2 18:43:16 CST 2023) * riot: ob->ebd, swap option $1 and $2 and $2 is default to ssh * riot: introduce sshl * logger.sh: support ddns * bug fix (Wed Mar 1 16:37:42 CST 2023) * dfs.ddns.failed -> dfs.ddns.fail * login beacon 2>/dev/null * logger.sh -> frigg-client.sh; curl add time limit 10s * to-install.sh: improve docker-ce * use $DFS_CURL_OPTIONS * ci: add ddns * bug fix (Wed Mar 15 19:37:21 CST 2023) * Revert "bug fix (Wed Mar 15 19:37:21 CST 2023)" This reverts commit 2df87ce1a8893d832e665a0429c7f9e7ae1108eb. * Revert "ci: add ddns" This reverts commit 4fe83215048b05ae3234ce801ac67856d0fea52e. * alias cbd and cbds, riot nasp port to 12022 * .zshrc: sagent -> sagt * fix ci * riot: bug fix when 'tmp' has leading zeros * add ci for cbds --------- Co-authored-by: xiongdian.me <xiongdian.me@bytedance.com>
2023-04-21 12:37:05 +08:00
fmt_info "usage: $0 <service> [command] [options]"
echo "available commands: ssh (default), sshl (ssh -L)"
}
router()
{
[dev] ddns; better ssh agent; riot sshl; sys.online; zsh hist import; DFS_DEBUG; cbd/cbds (#36) * riot: bj1 -> proxy * ci: test ask_for_yn * --wip-- [skip ci] * install.sh: will prompt version * zshrc: piv-agent now can re-use agents * zshrc: in docker use theme robbyrussell * update.sh: will send online beacon * beacon: support meta with limited len 64 * bug fix (Sat Jan 21 16:45:35 CST 2023) * well, finally add ssh key for ltp1-bd * set DFS_INITED and do not send login beacon if it was set * rewrite piv-agent to sagent; fmt_note and fmt_into will write to stderr * bug fix (Mon Jan 30 19:41:00 CST 2023) * bug fix (Mon Jan 30 19:46:27 CST 2023) * login beacon add details * $DFS_ORPHAN turns logger off * disable more beacons in CI * install.sh: prepare config earlier * init pbin * install.sh: -H|--hist|--history * install.sh: -H hint * install.sh: -H support multiple keys * fix zsh hist with no new line at the end * remove ^M in hist * bug fix (Wed Feb 1 21:11:41 CST 2023) * bug fix (Wed Feb 1 21:16:29 CST 2023) * bug fix (Wed Feb 1 21:20:21 CST 2023) * ci will send gh.ci.fail * show install opts * DFS_DEBUG to set -x * bug fix: install.sh re-start itself with no args incorrectly * bug fix (Thu Feb 2 18:43:16 CST 2023) * riot: ob->ebd, swap option $1 and $2 and $2 is default to ssh * riot: introduce sshl * logger.sh: support ddns * bug fix (Wed Mar 1 16:37:42 CST 2023) * dfs.ddns.failed -> dfs.ddns.fail * login beacon 2>/dev/null * logger.sh -> frigg-client.sh; curl add time limit 10s * to-install.sh: improve docker-ce * use $DFS_CURL_OPTIONS * ci: add ddns * bug fix (Wed Mar 15 19:37:21 CST 2023) * Revert "bug fix (Wed Mar 15 19:37:21 CST 2023)" This reverts commit 2df87ce1a8893d832e665a0429c7f9e7ae1108eb. * Revert "ci: add ddns" This reverts commit 4fe83215048b05ae3234ce801ac67856d0fea52e. * alias cbd and cbds, riot nasp port to 12022 * .zshrc: sagent -> sagt * fix ci * riot: bug fix when 'tmp' has leading zeros * add ci for cbds --------- Co-authored-by: xiongdian.me <xiongdian.me@bytedance.com>
2023-04-21 12:37:05 +08:00
if [[ -z "$1" || "$1" == "-h" || "$1" == "--help" ]]; then
print_help
exit
fi
get_server_meta "$1"
case $2 in
-h|--help)
print_help
[dev] ddns; better ssh agent; riot sshl; sys.online; zsh hist import; DFS_DEBUG; cbd/cbds (#36) * riot: bj1 -> proxy * ci: test ask_for_yn * --wip-- [skip ci] * install.sh: will prompt version * zshrc: piv-agent now can re-use agents * zshrc: in docker use theme robbyrussell * update.sh: will send online beacon * beacon: support meta with limited len 64 * bug fix (Sat Jan 21 16:45:35 CST 2023) * well, finally add ssh key for ltp1-bd * set DFS_INITED and do not send login beacon if it was set * rewrite piv-agent to sagent; fmt_note and fmt_into will write to stderr * bug fix (Mon Jan 30 19:41:00 CST 2023) * bug fix (Mon Jan 30 19:46:27 CST 2023) * login beacon add details * $DFS_ORPHAN turns logger off * disable more beacons in CI * install.sh: prepare config earlier * init pbin * install.sh: -H|--hist|--history * install.sh: -H hint * install.sh: -H support multiple keys * fix zsh hist with no new line at the end * remove ^M in hist * bug fix (Wed Feb 1 21:11:41 CST 2023) * bug fix (Wed Feb 1 21:16:29 CST 2023) * bug fix (Wed Feb 1 21:20:21 CST 2023) * ci will send gh.ci.fail * show install opts * DFS_DEBUG to set -x * bug fix: install.sh re-start itself with no args incorrectly * bug fix (Thu Feb 2 18:43:16 CST 2023) * riot: ob->ebd, swap option $1 and $2 and $2 is default to ssh * riot: introduce sshl * logger.sh: support ddns * bug fix (Wed Mar 1 16:37:42 CST 2023) * dfs.ddns.failed -> dfs.ddns.fail * login beacon 2>/dev/null * logger.sh -> frigg-client.sh; curl add time limit 10s * to-install.sh: improve docker-ce * use $DFS_CURL_OPTIONS * ci: add ddns * bug fix (Wed Mar 15 19:37:21 CST 2023) * Revert "bug fix (Wed Mar 15 19:37:21 CST 2023)" This reverts commit 2df87ce1a8893d832e665a0429c7f9e7ae1108eb. * Revert "ci: add ddns" This reverts commit 4fe83215048b05ae3234ce801ac67856d0fea52e. * alias cbd and cbds, riot nasp port to 12022 * .zshrc: sagent -> sagt * fix ci * riot: bug fix when 'tmp' has leading zeros * add ci for cbds --------- Co-authored-by: xiongdian.me <xiongdian.me@bytedance.com>
2023-04-21 12:37:05 +08:00
exit
;;
ssh|"" )
run_ssh
;;
[dev] ddns; better ssh agent; riot sshl; sys.online; zsh hist import; DFS_DEBUG; cbd/cbds (#36) * riot: bj1 -> proxy * ci: test ask_for_yn * --wip-- [skip ci] * install.sh: will prompt version * zshrc: piv-agent now can re-use agents * zshrc: in docker use theme robbyrussell * update.sh: will send online beacon * beacon: support meta with limited len 64 * bug fix (Sat Jan 21 16:45:35 CST 2023) * well, finally add ssh key for ltp1-bd * set DFS_INITED and do not send login beacon if it was set * rewrite piv-agent to sagent; fmt_note and fmt_into will write to stderr * bug fix (Mon Jan 30 19:41:00 CST 2023) * bug fix (Mon Jan 30 19:46:27 CST 2023) * login beacon add details * $DFS_ORPHAN turns logger off * disable more beacons in CI * install.sh: prepare config earlier * init pbin * install.sh: -H|--hist|--history * install.sh: -H hint * install.sh: -H support multiple keys * fix zsh hist with no new line at the end * remove ^M in hist * bug fix (Wed Feb 1 21:11:41 CST 2023) * bug fix (Wed Feb 1 21:16:29 CST 2023) * bug fix (Wed Feb 1 21:20:21 CST 2023) * ci will send gh.ci.fail * show install opts * DFS_DEBUG to set -x * bug fix: install.sh re-start itself with no args incorrectly * bug fix (Thu Feb 2 18:43:16 CST 2023) * riot: ob->ebd, swap option $1 and $2 and $2 is default to ssh * riot: introduce sshl * logger.sh: support ddns * bug fix (Wed Mar 1 16:37:42 CST 2023) * dfs.ddns.failed -> dfs.ddns.fail * login beacon 2>/dev/null * logger.sh -> frigg-client.sh; curl add time limit 10s * to-install.sh: improve docker-ce * use $DFS_CURL_OPTIONS * ci: add ddns * bug fix (Wed Mar 15 19:37:21 CST 2023) * Revert "bug fix (Wed Mar 15 19:37:21 CST 2023)" This reverts commit 2df87ce1a8893d832e665a0429c7f9e7ae1108eb. * Revert "ci: add ddns" This reverts commit 4fe83215048b05ae3234ce801ac67856d0fea52e. * alias cbd and cbds, riot nasp port to 12022 * .zshrc: sagent -> sagt * fix ci * riot: bug fix when 'tmp' has leading zeros * add ci for cbds --------- Co-authored-by: xiongdian.me <xiongdian.me@bytedance.com>
2023-04-21 12:37:05 +08:00
sshl )
run_sshl "$3"
;;
* )
print_help
[dev] ddns; better ssh agent; riot sshl; sys.online; zsh hist import; DFS_DEBUG; cbd/cbds (#36) * riot: bj1 -> proxy * ci: test ask_for_yn * --wip-- [skip ci] * install.sh: will prompt version * zshrc: piv-agent now can re-use agents * zshrc: in docker use theme robbyrussell * update.sh: will send online beacon * beacon: support meta with limited len 64 * bug fix (Sat Jan 21 16:45:35 CST 2023) * well, finally add ssh key for ltp1-bd * set DFS_INITED and do not send login beacon if it was set * rewrite piv-agent to sagent; fmt_note and fmt_into will write to stderr * bug fix (Mon Jan 30 19:41:00 CST 2023) * bug fix (Mon Jan 30 19:46:27 CST 2023) * login beacon add details * $DFS_ORPHAN turns logger off * disable more beacons in CI * install.sh: prepare config earlier * init pbin * install.sh: -H|--hist|--history * install.sh: -H hint * install.sh: -H support multiple keys * fix zsh hist with no new line at the end * remove ^M in hist * bug fix (Wed Feb 1 21:11:41 CST 2023) * bug fix (Wed Feb 1 21:16:29 CST 2023) * bug fix (Wed Feb 1 21:20:21 CST 2023) * ci will send gh.ci.fail * show install opts * DFS_DEBUG to set -x * bug fix: install.sh re-start itself with no args incorrectly * bug fix (Thu Feb 2 18:43:16 CST 2023) * riot: ob->ebd, swap option $1 and $2 and $2 is default to ssh * riot: introduce sshl * logger.sh: support ddns * bug fix (Wed Mar 1 16:37:42 CST 2023) * dfs.ddns.failed -> dfs.ddns.fail * login beacon 2>/dev/null * logger.sh -> frigg-client.sh; curl add time limit 10s * to-install.sh: improve docker-ce * use $DFS_CURL_OPTIONS * ci: add ddns * bug fix (Wed Mar 15 19:37:21 CST 2023) * Revert "bug fix (Wed Mar 15 19:37:21 CST 2023)" This reverts commit 2df87ce1a8893d832e665a0429c7f9e7ae1108eb. * Revert "ci: add ddns" This reverts commit 4fe83215048b05ae3234ce801ac67856d0fea52e. * alias cbd and cbds, riot nasp port to 12022 * .zshrc: sagent -> sagt * fix ci * riot: bug fix when 'tmp' has leading zeros * add ci for cbds --------- Co-authored-by: xiongdian.me <xiongdian.me@bytedance.com>
2023-04-21 12:37:05 +08:00
fmt_fatal "unknown command: $2"
;;
esac
}
router "${GOT_OPTS[@]}"