mirror of
https://github.com/DictXiong/dotfiles.git
synced 2025-07-01 21:00:29 +08:00
[dev] refactor riot; use
command; remove log
; sagt op
(#45)
* feat(riot-config): default port 12022 * fix(ci) * feat(riot-config): remove tailing dot from .domain; remove j.remote and x.domain * feat(riot): *.batch * feat(riot): run command in tmux window(s) note that spaces in ssh commands are still not supported * feat(riot): -o RequestTTY=yes * fix(riot): SSH_OPTIONS * fix(riot): tmux use bash * feat(zshrc): use() * fix(riot): scp, and ci note that riot still has problems with spaces. we should use array to handle parameters. * fix(ci): update macos image * feat: update email * feat: revert git email * feat(ssh): update keys * feat(sagent): sagt op * fix(sagent): error note * fix(ci): test of auto-dep * feat(ssh): remove keys ltp1-bd and ltp1 * feat(riot): rm - remove host keys * build(ci): update to ubuntu-latest and Yikun/hub-mirror-action@v1.5 * feat: remove frigg-client.log * feat(riot): -t or --trust to set RIOT_TRUST_SERVER * feat(zshrc/alias): add sc and t, remove cps and mvs feat(zshrc/plugins): add man and web-search, remove ufw * feat(riot): refactor argparse feat(riot): add `--password` and `--` feat(common.sh): argparse supports `--` feat(riot): refactor ping to ping remote * feat(riot): sshd can specify the local port * feat(riot): print help when no argument or no remote * fix(riot): ci * feat(riot): better print_cmd with escape * feat(riot-config): support sed* * fix(frigg): hostname converted into lower case
This commit is contained in:
parent
055d44886b
commit
891bbcacff
4
.github/workflows/gitee_sync.yml
vendored
4
.github/workflows/gitee_sync.yml
vendored
@ -4,10 +4,10 @@ on:
|
|||||||
workflow_dispatch: ~
|
workflow_dispatch: ~
|
||||||
jobs:
|
jobs:
|
||||||
dotfiles:
|
dotfiles:
|
||||||
runs-on: ubuntu-20.04
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: DictXiong/dotfiles
|
- name: DictXiong/dotfiles
|
||||||
uses: Yikun/hub-mirror-action@v1.4
|
uses: Yikun/hub-mirror-action@v1.5
|
||||||
with:
|
with:
|
||||||
src: github/DictXiong
|
src: github/DictXiong
|
||||||
dst: gitee/dictxiong
|
dst: gitee/dictxiong
|
||||||
|
32
.github/workflows/gitee_sync_dependencies.yml
vendored
32
.github/workflows/gitee_sync_dependencies.yml
vendored
@ -5,10 +5,10 @@ on:
|
|||||||
workflow_dispatch: ~
|
workflow_dispatch: ~
|
||||||
jobs:
|
jobs:
|
||||||
ohmyzsh:
|
ohmyzsh:
|
||||||
runs-on: ubuntu-20.04
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: ohmyzsh repo
|
- name: ohmyzsh repo
|
||||||
uses: Yikun/hub-mirror-action@v1.4
|
uses: Yikun/hub-mirror-action@v1.5
|
||||||
with:
|
with:
|
||||||
src: github/ohmyzsh
|
src: github/ohmyzsh
|
||||||
dst: gitee/dictxiong
|
dst: gitee/dictxiong
|
||||||
@ -22,10 +22,10 @@ jobs:
|
|||||||
static_list: "ohmyzsh"
|
static_list: "ohmyzsh"
|
||||||
timeout: '600s'
|
timeout: '600s'
|
||||||
zsh-users:
|
zsh-users:
|
||||||
runs-on: ubuntu-20.04
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: zsh-users repos
|
- name: zsh-users repos
|
||||||
uses: Yikun/hub-mirror-action@v1.4
|
uses: Yikun/hub-mirror-action@v1.5
|
||||||
with:
|
with:
|
||||||
src: github/zsh-users
|
src: github/zsh-users
|
||||||
dst: gitee/dictxiong
|
dst: gitee/dictxiong
|
||||||
@ -39,10 +39,10 @@ jobs:
|
|||||||
static_list: "antigen,zsh-syntax-highlighting,zsh-autosuggestions,zsh-completions"
|
static_list: "antigen,zsh-syntax-highlighting,zsh-autosuggestions,zsh-completions"
|
||||||
timeout: '600s'
|
timeout: '600s'
|
||||||
zdharma-continuum:
|
zdharma-continuum:
|
||||||
runs-on: ubuntu-20.04
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: zdharma-continuum repos
|
- name: zdharma-continuum repos
|
||||||
uses: Yikun/hub-mirror-action@v1.4
|
uses: Yikun/hub-mirror-action@v1.5
|
||||||
with:
|
with:
|
||||||
src: github/zdharma-continuum
|
src: github/zdharma-continuum
|
||||||
dst: gitee/dictxiong
|
dst: gitee/dictxiong
|
||||||
@ -56,10 +56,10 @@ jobs:
|
|||||||
static_list: "fast-syntax-highlighting"
|
static_list: "fast-syntax-highlighting"
|
||||||
timeout: '600s'
|
timeout: '600s'
|
||||||
tmux-mem-cpu-load:
|
tmux-mem-cpu-load:
|
||||||
runs-on: ubuntu-20.04
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: thewtex/tmux-mem-cpu-load
|
- name: thewtex/tmux-mem-cpu-load
|
||||||
uses: Yikun/hub-mirror-action@v1.4
|
uses: Yikun/hub-mirror-action@v1.5
|
||||||
with:
|
with:
|
||||||
src: github/thewtex
|
src: github/thewtex
|
||||||
dst: gitee/dictxiong
|
dst: gitee/dictxiong
|
||||||
@ -73,10 +73,10 @@ jobs:
|
|||||||
static_list: "tmux-mem-cpu-load"
|
static_list: "tmux-mem-cpu-load"
|
||||||
timeout: '600s'
|
timeout: '600s'
|
||||||
tmux-plugins:
|
tmux-plugins:
|
||||||
runs-on: ubuntu-20.04
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: tmux-plugins
|
- name: tmux-plugins
|
||||||
uses: Yikun/hub-mirror-action@v1.4
|
uses: Yikun/hub-mirror-action@v1.5
|
||||||
with:
|
with:
|
||||||
src: github/tmux-plugins
|
src: github/tmux-plugins
|
||||||
dst: gitee/dictxiong
|
dst: gitee/dictxiong
|
||||||
@ -90,10 +90,10 @@ jobs:
|
|||||||
static_list: "tpm,tmux-resurrect,tmux-yank"
|
static_list: "tpm,tmux-resurrect,tmux-yank"
|
||||||
timeout: '600s'
|
timeout: '600s'
|
||||||
vundle-vim:
|
vundle-vim:
|
||||||
runs-on: ubuntu-20.04
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: VundleVim/Vundle-vim
|
- name: VundleVim/Vundle-vim
|
||||||
uses: Yikun/hub-mirror-action@v1.4
|
uses: Yikun/hub-mirror-action@v1.5
|
||||||
with:
|
with:
|
||||||
src: github/VundleVim
|
src: github/VundleVim
|
||||||
dst: gitee/dictxiong
|
dst: gitee/dictxiong
|
||||||
@ -107,10 +107,10 @@ jobs:
|
|||||||
static_list: "Vundle.vim"
|
static_list: "Vundle.vim"
|
||||||
timeout: '600s'
|
timeout: '600s'
|
||||||
onedark-vim:
|
onedark-vim:
|
||||||
runs-on: ubuntu-20.04
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: joshdick/onedark-vim
|
- name: joshdick/onedark-vim
|
||||||
uses: Yikun/hub-mirror-action@v1.4
|
uses: Yikun/hub-mirror-action@v1.5
|
||||||
with:
|
with:
|
||||||
src: github/joshdick
|
src: github/joshdick
|
||||||
dst: gitee/dictxiong
|
dst: gitee/dictxiong
|
||||||
@ -124,10 +124,10 @@ jobs:
|
|||||||
static_list: "onedark.vim"
|
static_list: "onedark.vim"
|
||||||
timeout: '600s'
|
timeout: '600s'
|
||||||
fzf:
|
fzf:
|
||||||
runs-on: ubuntu-20.04
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: junegunn/fzf
|
- name: junegunn/fzf
|
||||||
uses: Yikun/hub-mirror-action@v1.4
|
uses: Yikun/hub-mirror-action@v1.5
|
||||||
with:
|
with:
|
||||||
src: github/junegunn
|
src: github/junegunn
|
||||||
dst: gitee/dictxiong
|
dst: gitee/dictxiong
|
||||||
|
4
.github/workflows/test.yml
vendored
4
.github/workflows/test.yml
vendored
@ -46,7 +46,7 @@ jobs:
|
|||||||
|
|
||||||
test-macos:
|
test-macos:
|
||||||
name: test on macos
|
name: test on macos
|
||||||
runs-on: macos-12
|
runs-on: macos-latest
|
||||||
steps:
|
steps:
|
||||||
- name: checkout repo
|
- name: checkout repo
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
@ -91,7 +91,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: remove dependencies
|
- name: remove dependencies
|
||||||
run: |
|
run: |
|
||||||
sudo apt-get -y remove curl vim python3
|
sudo apt-get -y remove curl vim
|
||||||
|
|
||||||
- name: checkout repo
|
- name: checkout repo
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
@ -4,25 +4,17 @@ ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGakUcSuNhuH7tk+Nj9gDfRtxYfGPL9yb8toQ/EpSJAM
|
|||||||
|
|
||||||
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCUN7IXF4nlFcVfgHesgik3LIAiXlVMYJPm3yD13EVarQx5jqdBgk8Dwgkgf4rPO6MFpvIpinOyEO8zOS6HHQrCLZUv5yTFaDkUuB7eQ0EmpicGbmk9bHqj1HkOZxaobkpEfQUmFKYvkp4EexVw66sO0qfXvjHZ4H6yCAJLK5aUnKfgrE8tODzP82sU/mpJjW+Pq3uanNq754gaHwhxCIXG143/zp8qzBAeKe38xVqqDq9fTkG4hvzFvkRdS88i6l1z++0P3n0HGdOjtSg7P7fO7+7ZyPYr0gO5vB720Om/zxqPrGd9cicWi4P+aVKa+0ujWH/pqufWG6uCjKWHnBs7 sk0/piv/9a
|
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCUN7IXF4nlFcVfgHesgik3LIAiXlVMYJPm3yD13EVarQx5jqdBgk8Dwgkgf4rPO6MFpvIpinOyEO8zOS6HHQrCLZUv5yTFaDkUuB7eQ0EmpicGbmk9bHqj1HkOZxaobkpEfQUmFKYvkp4EexVw66sO0qfXvjHZ4H6yCAJLK5aUnKfgrE8tODzP82sU/mpJjW+Pq3uanNq754gaHwhxCIXG143/zp8qzBAeKe38xVqqDq9fTkG4hvzFvkRdS88i6l1z++0P3n0HGdOjtSg7P7fO7+7ZyPYr0gO5vB720Om/zxqPrGd9cicWi4P+aVKa+0ujWH/pqufWG6uCjKWHnBs7 sk0/piv/9a
|
||||||
|
|
||||||
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGV/6cLUGA5YWVI6uPhIBOBZvlNBlZLkehHQN0Gxnc+B ltp0/ubuntu
|
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMyZILj+GxTUhdCgz2w1TxQ+aTcggnOJIb84qA4u271S ltp0
|
||||||
|
|
||||||
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILqRfdez8IAOf6m9Ysi3uSNKEG0Xi6GPuhA6R2fci2yB ltp0/windows
|
|
||||||
|
|
||||||
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFO4k0tJ+Bfu95Uavg/5P3EXMKNcq+bMqaTqzkvRZ7ji ltp1/ubuntu
|
|
||||||
|
|
||||||
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIN8g34WHLEix6Qt0J/ClYbZeb9wh+p1IOcZkz/vNbZrv ltp1/windows
|
|
||||||
|
|
||||||
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIBN24pvN1RMN+iSZyHPdyExA1Rvt8pdr3e6ih6iX+KrQ ltp2
|
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIBN24pvN1RMN+iSZyHPdyExA1Rvt8pdr3e6ih6iX+KrQ ltp2
|
||||||
|
|
||||||
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGZFTyR+R86fUpZBDkDR9yYzJpmeNsIv2CMHTh6EuEeq pc0/windows
|
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGZFTyR+R86fUpZBDkDR9yYzJpmeNsIv2CMHTh6EuEeq pc0
|
||||||
|
|
||||||
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHLYgVj+NPino6sOmahULN7SbAMaVAgzqPfDjz2S8zDv pc1/windows
|
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHLYgVj+NPino6sOmahULN7SbAMaVAgzqPfDjz2S8zDv pc1
|
||||||
|
|
||||||
|
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIF52mPmbLEriZ+DfmrMHFtvg2kiO2JpRpitvs7PbJowh home0
|
||||||
|
|
||||||
ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBNvHya5i3GNniGww9Yx5ikos4Z5jevu8zz8hCQi05++SgejFPnbw9UjbHFjODK2M+ZHuhRF5mdf996r4/BxWyP8= pad0/sep
|
ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBNvHya5i3GNniGww9Yx5ikos4Z5jevu8zz8hCQi05++SgejFPnbw9UjbHFjODK2M+ZHuhRF5mdf996r4/BxWyP8= pad0/sep
|
||||||
|
|
||||||
ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBC5gu+U4picxVvCNYjLlmxGLpJl7svj3LklO7jSpwqdrNxlE+/xkx07PJx76AbA77dDM1Dxmm/VOvVQCKTRLTgk= ip14/sep
|
ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBC5gu+U4picxVvCNYjLlmxGLpJl7svj3LklO7jSpwqdrNxlE+/xkx07PJx76AbA77dDM1Dxmm/VOvVQCKTRLTgk= ip14/sep
|
||||||
|
|
||||||
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIF52mPmbLEriZ+DfmrMHFtvg2kiO2JpRpitvs7PbJowh home0
|
|
||||||
|
|
||||||
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKhS4voo3K/Dvzqckr0bouO1WkCI5XxswstHWnuuyKBz ltp1-bd
|
|
||||||
|
|
||||||
|
@ -39,8 +39,7 @@ case $DFS_UPDATE_CHANNEL in
|
|||||||
esac
|
esac
|
||||||
if [[ ${#DFS_COMMIT} != 40 ]]; then
|
if [[ ${#DFS_COMMIT} != 40 ]]; then
|
||||||
fmt_error "invalid commit id"
|
fmt_error "invalid commit id"
|
||||||
apost_beacon "dfs.invalid-commit"
|
apost_beacon "dfs.invalid-commit" "invalid commit id: ${DFS_COMMIT}"
|
||||||
apost_log "ERROR" "$THIS_FILE" "invalid commit id: ${DFS_COMMIT}"
|
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
11
.zshrc2
11
.zshrc2
@ -69,6 +69,7 @@ ANTIGEN_PLUGINS+=(
|
|||||||
"fzf"
|
"fzf"
|
||||||
"git"
|
"git"
|
||||||
"magic-enter"
|
"magic-enter"
|
||||||
|
"man"
|
||||||
"per-directory-history"
|
"per-directory-history"
|
||||||
"pip"
|
"pip"
|
||||||
"podman"
|
"podman"
|
||||||
@ -78,7 +79,7 @@ ANTIGEN_PLUGINS+=(
|
|||||||
"systemd"
|
"systemd"
|
||||||
"timer"
|
"timer"
|
||||||
"tmux"
|
"tmux"
|
||||||
"ufw"
|
"web-search"
|
||||||
"z"
|
"z"
|
||||||
)
|
)
|
||||||
for i in ${ANTIGEN_PLUGINS[*]}; do
|
for i in ${ANTIGEN_PLUGINS[*]}; do
|
||||||
@ -112,13 +113,11 @@ fi
|
|||||||
alias "pls"='sudo $(fc -ln -1)'
|
alias "pls"='sudo $(fc -ln -1)'
|
||||||
alias "se"='sudo -sE'
|
alias "se"='sudo -sE'
|
||||||
alias "sl"='sudo zsh -l'
|
alias "sl"='sudo zsh -l'
|
||||||
alias "cps"='rsync -avh --info=progress2'
|
|
||||||
alias "mvs"='rsync -avh --info=progress2 --remove-source-files'
|
|
||||||
if [[ "$DFS_OS_TYPE" == "linux" ]]; then alias "ping"='ping -n'; alias "ping6"='ping6 -n'; fi
|
if [[ "$DFS_OS_TYPE" == "linux" ]]; then alias "ping"='ping -n'; alias "ping6"='ping6 -n'; fi
|
||||||
if [[ "$DFS_OS_TYPE" == "msys" ]]; then alias "tmux"='script -qO /dev/null -c "tmux -u"'; fi
|
if [[ "$DFS_OS_TYPE" == "msys" ]]; then alias "tmux"='script -qO /dev/null -c "tmux -u"'; fi
|
||||||
alias "pbd"='ping baidu.com'
|
alias "pbd"='ping baidu.com'
|
||||||
alias "p114"='ping 114.114.114.114'
|
alias "p114"='ping 114.114.114.114'
|
||||||
alias "p666"='ping6 2001:da8::666'
|
alias "p666"='ping6 240c::6666'
|
||||||
alias "cbd"='curl http://www.baidu.com'
|
alias "cbd"='curl http://www.baidu.com'
|
||||||
alias "cbds"='curl https://www.baidu.com'
|
alias "cbds"='curl https://www.baidu.com'
|
||||||
alias "gdebug"='git add -A; git commit --allow-empty -m "bug fix ($(date))"'
|
alias "gdebug"='git add -A; git commit --allow-empty -m "bug fix ($(date))"'
|
||||||
@ -129,8 +128,11 @@ alias "jce"='jc -e'
|
|||||||
alias "jceu"='jc -eu'
|
alias "jceu"='jc -eu'
|
||||||
alias "jcf"='jc -f'
|
alias "jcf"='jc -f'
|
||||||
alias "jcfu"='jc -fu'
|
alias "jcfu"='jc -fu'
|
||||||
|
alias "sc"='systemctl'
|
||||||
|
alias "t"='tmux'
|
||||||
gbes() { git for-each-ref --sort=-committerdate refs/heads refs/remotes --format="%(authordate:format:%y-%m-%d.%a %H:%M %z)|%(color:red)%(objectname:short)|%(color:yellow)%(refname:short)%(color:reset)|%(color:reset)%(authorname): %(color:green)%(subject)" --color=always | column -ts"|" | less -FX }
|
gbes() { git for-each-ref --sort=-committerdate refs/heads refs/remotes --format="%(authordate:format:%y-%m-%d.%a %H:%M %z)|%(color:red)%(objectname:short)|%(color:yellow)%(refname:short)%(color:reset)|%(color:reset)%(authorname): %(color:green)%(subject)" --color=always | column -ts"|" | less -FX }
|
||||||
sagt() { eval "$($DOTFILES/tools/sagent.sh $@)" }
|
sagt() { eval "$($DOTFILES/tools/sagent.sh $@)" }
|
||||||
|
use() { nix --experimental-features nix-command --extra-experimental-features flakes shell "${(*)@/#%(#b)([^#]#)/nixpkgs#$match}" }
|
||||||
|
|
||||||
# key bindings
|
# key bindings
|
||||||
bindkey "^b" beginning-of-line # ctrl+b
|
bindkey "^b" beginning-of-line # ctrl+b
|
||||||
@ -186,7 +188,6 @@ dfs()
|
|||||||
"$DOTFILES/install.sh" -i
|
"$DOTFILES/install.sh" -i
|
||||||
echo 'Done. Please open a new shell to see the changes.'
|
echo 'Done. Please open a new shell to see the changes.'
|
||||||
;;
|
;;
|
||||||
log ) "$DOTFILES/tools/common.sh" "post_log" "INFO" "dfs" "$2" ;;
|
|
||||||
beacon ) "$DOTFILES/tools/common.sh" "post_beacon" "$2" "$3" ;;
|
beacon ) "$DOTFILES/tools/common.sh" "post_beacon" "$2" "$3" ;;
|
||||||
* ) echo "unknown command \"$1\". available: update, force-update, version, reset, cd, log" ;;
|
* ) echo "unknown command \"$1\". available: update, force-update, version, reset, cd, log" ;;
|
||||||
esac
|
esac
|
||||||
|
@ -1,13 +1,29 @@
|
|||||||
#!/bin/false
|
#!/bin/false
|
||||||
|
|
||||||
# remotes
|
# batches
|
||||||
j.remote() {
|
nasps.batch() {
|
||||||
remote=ssh.beardic.cn
|
remotes+=(
|
||||||
RET_PORT=${RET_PORT:-24022}
|
g1.nasp
|
||||||
RET_USERNAME=${RET_USERNAME:-root}
|
g2.nasp
|
||||||
RET_TRUST_SERVER=1
|
g3.nasp
|
||||||
|
g4.nasp
|
||||||
|
g5.nasp
|
||||||
|
g6.nasp
|
||||||
|
g7.nasp
|
||||||
|
g8.nasp
|
||||||
|
g9.nasp
|
||||||
|
g10.nasp
|
||||||
|
g11.nasp
|
||||||
|
g12.nasp
|
||||||
|
g13.nasp
|
||||||
|
g14.nasp
|
||||||
|
dictxiong@g15.nasp
|
||||||
|
dictxiong@g16.nasp
|
||||||
|
g17.nasp
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# remotes
|
||||||
nasp.remote() {
|
nasp.remote() {
|
||||||
remote=nasp.fit
|
remote=nasp.fit
|
||||||
RET_PORT=${RET_PORT:-36022}
|
RET_PORT=${RET_PORT:-36022}
|
||||||
@ -18,17 +34,16 @@ nasp.remote() {
|
|||||||
# domains
|
# domains
|
||||||
.domain() {
|
.domain() {
|
||||||
RET_USERNAME=${RET_USERNAME:-root}
|
RET_USERNAME=${RET_USERNAME:-root}
|
||||||
|
RET_PORT=${RET_PORT:-12022}
|
||||||
|
RET_HOSTNAME=${remote%.}
|
||||||
}
|
}
|
||||||
|
|
||||||
dxng.domain() {
|
dxng.domain() {
|
||||||
|
if [[ "$host" =~ ^sed([0-9]{1,2})$ ]]; then
|
||||||
|
RET_HOSTNAME=192.168.98.$((100+BASH_REMATCH[1]))
|
||||||
|
else
|
||||||
RET_HOSTNAME=$host.dxng.net
|
RET_HOSTNAME=$host.dxng.net
|
||||||
RET_PORT=${RET_PORT:-12022}
|
fi
|
||||||
RET_USERNAME=${RET_USERNAME:-root}
|
|
||||||
RET_TRUST_SERVER=1
|
|
||||||
}
|
|
||||||
|
|
||||||
i.domain() {
|
|
||||||
RET_HOSTNAME=$host.ibd.ink
|
|
||||||
RET_PORT=${RET_PORT:-12022}
|
RET_PORT=${RET_PORT:-12022}
|
||||||
RET_USERNAME=${RET_USERNAME:-root}
|
RET_USERNAME=${RET_USERNAME:-root}
|
||||||
RET_TRUST_SERVER=1
|
RET_TRUST_SERVER=1
|
||||||
@ -41,15 +56,6 @@ i.domain() {
|
|||||||
RET_TRUST_SERVER=1
|
RET_TRUST_SERVER=1
|
||||||
}
|
}
|
||||||
|
|
||||||
x.domain() {
|
|
||||||
RET_HOSTNAME=ssh.beardic.cn
|
|
||||||
local tmp=$(sha256sum <<< "$host" | tr -cd "[:digit:]")
|
|
||||||
tmp=${tmp:0:4}
|
|
||||||
RET_PORT=$((10#$tmp+36000))
|
|
||||||
RET_USERNAME=root
|
|
||||||
RET_TRUST_SERVER=1
|
|
||||||
}
|
|
||||||
|
|
||||||
nasp.domain() {
|
nasp.domain() {
|
||||||
RET_HOSTNAME=$host
|
RET_HOSTNAME=$host
|
||||||
RET_PORT=${RET_PORT:-12022}
|
RET_PORT=${RET_PORT:-12022}
|
||||||
|
230
scripts/riot
230
scripts/riot
@ -4,7 +4,7 @@ THIS_DIR=$( cd "$( dirname "${BASH_SOURCE[0]:-${(%):-%x}}" )" && pwd )
|
|||||||
source "$THIS_DIR/../tools/common.sh"
|
source "$THIS_DIR/../tools/common.sh"
|
||||||
RIOT_TRUST_CLIENT=${RIOT_TRUST_CLIENT:-${DFS_TRUST:-0}}
|
RIOT_TRUST_CLIENT=${RIOT_TRUST_CLIENT:-${DFS_TRUST:-0}}
|
||||||
RIOT_TRUST_SERVER=${RIOT_TRUST_SERVER:-0}
|
RIOT_TRUST_SERVER=${RIOT_TRUST_SERVER:-0}
|
||||||
RIOT_EXTRA_OPTIONS=""
|
EXTRA_SSH_OPTIONS=()
|
||||||
|
|
||||||
# config
|
# config
|
||||||
RIOT_CONFIG_FILES=(
|
RIOT_CONFIG_FILES=(
|
||||||
@ -83,12 +83,12 @@ parse_remote() {
|
|||||||
TRUST_SERVER=1
|
TRUST_SERVER=1
|
||||||
PORT="" # optional
|
PORT="" # optional
|
||||||
USERNAME="" # optional
|
USERNAME="" # optional
|
||||||
SSH_OPTIONS="" # optional
|
SSH_OPTIONS=("-o" "RequestTTY=yes")
|
||||||
if [[ "$RIOT_TRUST_CLIENT" == "1" ]]; then
|
if [[ "$RIOT_TRUST_CLIENT" == "1" ]]; then
|
||||||
SSH_OPTIONS='-o PermitLocalCommand=yes'
|
SSH_OPTIONS+=("-o" "PermitLocalCommand=yes")
|
||||||
if [[ "$(get_os_type)" != "msys" ]]; then
|
if [[ "$(get_os_type)" != "msys" ]]; then
|
||||||
test "$DFS_DRY_RUN" = "1" || mkdir -p ~/.ssh/master-socket
|
test "$DFS_DRY_RUN" = "1" || mkdir -p ~/.ssh/master-socket
|
||||||
SSH_OPTIONS="$SSH_OPTIONS -o ControlMaster=auto -o ControlPath=~/.ssh/master-socket/%C"
|
SSH_OPTIONS+=("-o" "ControlMaster=auto" "-o" "ControlPath=~/.ssh/master-socket/%C")
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
# handle input
|
# handle input
|
||||||
@ -115,18 +115,41 @@ parse_remote() {
|
|||||||
done
|
done
|
||||||
# construct cmd
|
# construct cmd
|
||||||
if [[ "$RIOT_TRUST_SERVER" == "1" || "$TRUST_SERVER" == "1" ]]; then
|
if [[ "$RIOT_TRUST_SERVER" == "1" || "$TRUST_SERVER" == "1" ]]; then
|
||||||
SSH_OPTIONS="$SSH_OPTIONS -o ForwardX11=yes -o ForwardAgent=yes"
|
SSH_OPTIONS+=("-o" "ForwardX11=yes" "-o" "ForwardAgent=yes")
|
||||||
fi
|
fi
|
||||||
if [[ -n "$jump_servers" ]]; then
|
if [[ -n "$jump_servers" ]]; then
|
||||||
SSH_OPTIONS="$SSH_OPTIONS -o ProxyJump=$jump_servers"
|
SSH_OPTIONS+=("-o" "ProxyJump=$jump_servers")
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
print_cmd() {
|
||||||
|
local output=""
|
||||||
|
for s in "${CMD[@]}"; do
|
||||||
|
if [[ "$s" =~ [\ \\\'\"] ]]; then
|
||||||
|
s="${s@Q}"
|
||||||
|
fi
|
||||||
|
output+="$s "
|
||||||
|
done
|
||||||
|
fmt_note "--> ${output% }"
|
||||||
|
}
|
||||||
|
|
||||||
eval_or_echo() {
|
eval_or_echo() {
|
||||||
|
local DO=""
|
||||||
|
local tmux_win=0
|
||||||
if [[ "$DFS_DRY_RUN" == "1" ]]; then
|
if [[ "$DFS_DRY_RUN" == "1" ]]; then
|
||||||
echo $@
|
DO=echo
|
||||||
|
fi
|
||||||
|
if [[ "$USE_TMUX" == "1" ]]; then
|
||||||
|
if [[ -z "$TMUX_SESS" ]]; then
|
||||||
|
TMUX_SESS=riot-$(date +%s)
|
||||||
|
$DO tmux new-session -d -s $TMUX_SESS bash -l
|
||||||
else
|
else
|
||||||
eval $@
|
tmux_win=$((tmux_win+1))
|
||||||
|
$DO tmux new-window -t $TMUX_SESS:$tmux_win -d bash -l
|
||||||
|
fi
|
||||||
|
$DO tmux send-keys -t $TMUX_SESS:$tmux_win "${CMD[@]}" Enter
|
||||||
|
else
|
||||||
|
$DO "${CMD[@]}"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -138,15 +161,25 @@ prepare_ssh_cmd() {
|
|||||||
else
|
else
|
||||||
local port_param='-p'
|
local port_param='-p'
|
||||||
fi
|
fi
|
||||||
echo "$ssh_bin ${PORT:+$port_param} $PORT $SSH_OPTIONS $RIOT_EXTRA_OPTIONS $SCP_SRC $USERNAME${USERNAME:+@}$SERVER $SCP_DST ${@:2}"
|
CMD=(
|
||||||
|
"$ssh_bin"
|
||||||
|
"${PORT:+$port_param}" "$PORT"
|
||||||
|
"${SSH_OPTIONS[@]}"
|
||||||
|
"${EXTRA_SSH_OPTIONS[@]}"
|
||||||
|
"$SCP_SRC"
|
||||||
|
"$USERNAME${USERNAME:+@}$SERVER"
|
||||||
|
"$SCP_DST"
|
||||||
|
"${@:2}"
|
||||||
|
)
|
||||||
|
for i in ${!CMD[@]}; do if [[ -z "${CMD[i]}" ]]; then unset CMD[i]; fi; done
|
||||||
}
|
}
|
||||||
|
|
||||||
# ssh
|
# ssh
|
||||||
run_ssh()
|
run_ssh()
|
||||||
{
|
{
|
||||||
local cmd="$(prepare_ssh_cmd $@)"
|
prepare_ssh_cmd "$@"
|
||||||
fmt_note "-->" $cmd
|
print_cmd
|
||||||
eval_or_echo $cmd
|
eval_or_echo
|
||||||
}
|
}
|
||||||
|
|
||||||
# sshl
|
# sshl
|
||||||
@ -158,24 +191,22 @@ run_sshl()
|
|||||||
arg=localhost:$arg
|
arg=localhost:$arg
|
||||||
fi
|
fi
|
||||||
local port=$(get_free_port)
|
local port=$(get_free_port)
|
||||||
|
SSH_OPTIONS+=("-NC" "-L" "$port:$arg")
|
||||||
SSH_OPTIONS="$SSH_OPTIONS -NC -L $port:$arg"
|
prepare_ssh_cmd ssh
|
||||||
local cmd="$(prepare_ssh_cmd ssh)"
|
print_cmd
|
||||||
fmt_note "-->" $cmd
|
|
||||||
fmt_note " > please access localhost:$port"
|
fmt_note " > please access localhost:$port"
|
||||||
eval_or_echo $cmd
|
eval_or_echo
|
||||||
}
|
}
|
||||||
|
|
||||||
# sshd
|
# sshd
|
||||||
run_sshd()
|
run_sshd()
|
||||||
{
|
{
|
||||||
local port=$(get_free_port)
|
local port=${1:-$(get_free_port)}
|
||||||
|
SSH_OPTIONS+=("-NC" "-D" "$port")
|
||||||
SSH_OPTIONS="$SSH_OPTIONS -NC -D $port"
|
prepare_ssh_cmd ssh
|
||||||
local cmd="$(prepare_ssh_cmd ssh)"
|
print_cmd
|
||||||
fmt_note "-->" $cmd
|
|
||||||
fmt_note " > please access localhost:$port"
|
fmt_note " > please access localhost:$port"
|
||||||
eval_or_echo $cmd
|
eval_or_echo
|
||||||
}
|
}
|
||||||
|
|
||||||
# scp
|
# scp
|
||||||
@ -189,77 +220,158 @@ run_scp() {
|
|||||||
dst_is_remote=0
|
dst_is_remote=0
|
||||||
fi
|
fi
|
||||||
if [[ "$dst_is_remote" == "1" ]]; then
|
if [[ "$dst_is_remote" == "1" ]]; then
|
||||||
SCP_SRC=\""$src"\"
|
SCP_SRC="$src"
|
||||||
SERVER="$SERVER":\""$dst"\"
|
SERVER="$SERVER":"$dst"
|
||||||
else
|
else
|
||||||
SERVER="$SERVER":\""$src"\"
|
SERVER="$SERVER":"$src"
|
||||||
SCP_DST=\""$dst"\"
|
SCP_DST="$dst"
|
||||||
fi
|
fi
|
||||||
SSH_OPTIONS="$SSH_OPTIONS -r"
|
SSH_OPTIONS+=("-r")
|
||||||
local cmd="$(prepare_ssh_cmd scp)"
|
prepare_ssh_cmd scp
|
||||||
fmt_note "-->" $cmd
|
print_cmd
|
||||||
eval_or_echo $cmd
|
eval_or_echo
|
||||||
|
}
|
||||||
|
|
||||||
|
# ping
|
||||||
|
run_ping() {
|
||||||
|
CMD=(ping)
|
||||||
|
if [[ "$1" == "ping4" ]]; then
|
||||||
|
CMD+=(-4)
|
||||||
|
elif [[ "$1" == "ping6" ]]; then
|
||||||
|
CMD+=(-6)
|
||||||
|
fi
|
||||||
|
CMD+=(-c 4 "$SERVER")
|
||||||
|
print_cmd
|
||||||
|
eval_or_echo
|
||||||
|
}
|
||||||
|
|
||||||
|
# remove host keys
|
||||||
|
remove_hostkey() {
|
||||||
|
local key
|
||||||
|
if [[ -z "$PORT" || "$PORT" == "22" ]]; then
|
||||||
|
key=$SERVER
|
||||||
|
else
|
||||||
|
key="[$SERVER]:$PORT"
|
||||||
|
fi
|
||||||
|
ssh-keygen -R "$key"
|
||||||
}
|
}
|
||||||
|
|
||||||
# main
|
# main
|
||||||
print_help()
|
print_help()
|
||||||
{
|
{
|
||||||
fmt_info "usage: $0 <service> [command] [options]"
|
fmt_info "usage: $0 [-Ddhlqt] [--dry-run] [--dev] [--help] [--lite] [--quite] [--trust] [--tmux] [--password] [[-o ssh-option]...] remote [command] [--] [ssh-command-args]"
|
||||||
echo "available commands: ssh (default), sshl (ssh -L), zssh, sftp"
|
cat <<EOF
|
||||||
|
available commands:
|
||||||
|
- ssh [ssh-command-args] (default)
|
||||||
|
- tmux [ssh-command-args] (run ssh in multiple tmux windows)
|
||||||
|
- sshl [local-port:remote-host:]remote-port (ssh -L)
|
||||||
|
- sshd [local-port] (ssh -D)
|
||||||
|
- zssh [ssh-command-args]
|
||||||
|
- sftp
|
||||||
|
- scp source destination
|
||||||
|
- rm (remove host keys)
|
||||||
|
- ping/ping4/ping6 (ping the remote servers)
|
||||||
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
router() {
|
router() {
|
||||||
if [[ -z "$1" || "$1" == "-h" || "$1" == "--help" ]]; then
|
local positional=()
|
||||||
|
while [[ $# > 0 ]]; do
|
||||||
|
case "$1" in
|
||||||
|
-h|--help )
|
||||||
print_help
|
print_help
|
||||||
exit
|
exit 0
|
||||||
fi
|
;;
|
||||||
|
-t|--trust )
|
||||||
while [[ "$1" == -* ]]; do
|
RIOT_TRUST_SERVER=1
|
||||||
RIOT_EXTRA_OPTIONS="$RIOT_EXTRA_OPTIONS $1"
|
;;
|
||||||
if [[ "$1" == "-o" ]]; then
|
--tmux )
|
||||||
RIOT_EXTRA_OPTIONS="$RIOT_EXTRA_OPTIONS $2"
|
USE_TMUX=1
|
||||||
|
;;
|
||||||
|
--password )
|
||||||
|
EXTRA_SSH_OPTIONS+=("-o" "PasswordAuthentication=yes" "-o" "PubkeyAuthentication=no")
|
||||||
|
;;
|
||||||
|
-o )
|
||||||
|
EXTRA_SSH_OPTIONS+=("-o" "$2")
|
||||||
shift
|
shift
|
||||||
fi
|
;;
|
||||||
|
-- )
|
||||||
|
shift
|
||||||
|
positional+=("$@")
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
-* )
|
||||||
|
fmt_fatal "unknown option: $1"
|
||||||
|
;;
|
||||||
|
* )
|
||||||
|
positional+=("$1")
|
||||||
|
;;
|
||||||
|
esac
|
||||||
shift
|
shift
|
||||||
done
|
done
|
||||||
|
IFS=',' read -ra remotes <<< "${positional[0]}"
|
||||||
IFS=',' read -ra remotes <<< "$1"
|
for i in ${!remotes[@]}; do if [[ -z "${remotes[i]}" ]]; then unset remotes[i]; fi; done
|
||||||
for remote in "${remotes[@]}"; do
|
if [[ "${#positional[@]}" == "0" || "${#remotes[@]}" == "0" ]]; then
|
||||||
if [[ -z "$remote" ]]; then
|
print_help
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
for i in ${!remotes[@]}; do
|
||||||
|
remote="${remotes[i]}"
|
||||||
|
local batch_func="${remote}.batch"
|
||||||
|
if is_function "$batch_func"; then
|
||||||
|
"$batch_func"
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
parse_remote "$remote"
|
parse_remote "$remote"
|
||||||
case $2 in
|
case "${positional[1]}" in
|
||||||
ssh|"" )
|
ssh|tmux|"" )
|
||||||
run_ssh ssh "${@:3}"
|
[[ "${positional[1]}" == tmux ]] && USE_TMUX=1
|
||||||
|
run_ssh ssh "${positional[@]:2}"
|
||||||
;;
|
;;
|
||||||
ping|ping6 )
|
ping|ping4|ping6 )
|
||||||
run_ssh ssh "${@:2}"
|
test "${#positional[@]}" -eq 2 || fmt_fatal "ping requires no arguments"
|
||||||
|
run_ping "${positional[1]}"
|
||||||
;;
|
;;
|
||||||
zssh )
|
zssh )
|
||||||
run_ssh zssh
|
run_ssh zssh "${positional[@]:2}"
|
||||||
;;
|
;;
|
||||||
sftp )
|
sftp )
|
||||||
run_ssh sftp
|
run_ssh sftp "${positional[@]:2}"
|
||||||
;;
|
;;
|
||||||
sshl )
|
sshl )
|
||||||
test -n "$3" || fmt_fatal "no target address provided"
|
test -n "${positional[2]}" || fmt_fatal "no target address provided"
|
||||||
run_sshl "$3"
|
test "${#positional[@]}" -eq 3 || fmt_fatal "sshl requires exactly one argument"
|
||||||
|
run_sshl "${positional[2]}"
|
||||||
;;
|
;;
|
||||||
sshd )
|
sshd )
|
||||||
|
test "${#positional[@]}" -le 3 || fmt_fatal "sshd requires one or no arguments"
|
||||||
|
if [[ "${#positional[@]}" -eq 3 ]]; then
|
||||||
|
check_port "${positional[2]}" || fmt_fatal "invalid port number: ${positional[2]}"
|
||||||
|
run_sshd "${positional[2]}"
|
||||||
|
else
|
||||||
run_sshd
|
run_sshd
|
||||||
|
fi
|
||||||
;;
|
;;
|
||||||
scp )
|
scp )
|
||||||
test -n "$3" || fmt_fatal "no source path specified"
|
test "${#positional[@]}" -eq 4 || fmt_fatal "scp requires exactly two arguments: source and destination"
|
||||||
test -n "$4" || fmt_fatal "no destination path specified"
|
test -n "${positional[2]}" || fmt_fatal "no source path specified"
|
||||||
run_scp "$3" "$4"
|
test -n "${positional[3]}" || fmt_fatal "no destination path specified"
|
||||||
|
run_scp "${positional[2]}" "${positional[3]}"
|
||||||
|
;;
|
||||||
|
rm )
|
||||||
|
test "${#positional[@]}" -eq 2 || fmt_fatal "rm requires no arguments"
|
||||||
|
remove_hostkey
|
||||||
;;
|
;;
|
||||||
* )
|
* )
|
||||||
print_help
|
print_help
|
||||||
fmt_fatal "unknown command: $2"
|
fmt_fatal "unknown command: ${positional[1]}"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
|
if [[ -n "$TMUX_SESS" && "$DFS_DRY_RUN" != "1" ]]; then
|
||||||
|
tmux attach-session -t $TMUX_SESS
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
router "${GOT_OPTS[@]}"
|
router "${GOT_OPTS[@]}"
|
||||||
|
@ -13,7 +13,10 @@ if [[ "${BASH_SOURCE[0]}" != "${0}" ]]; then
|
|||||||
ARG=""
|
ARG=""
|
||||||
GOT_OPTS=()
|
GOT_OPTS=()
|
||||||
while [[ $# > 0 || -n "$ARG" ]]; do
|
while [[ $# > 0 || -n "$ARG" ]]; do
|
||||||
if [[ -z "$ARG" ]]; then ARG=$1; shift; fi
|
if [[ -z "$ARG" ]]; then
|
||||||
|
if [[ "$1" == "--" ]]; then GOT_OPTS+=("$@"); break; fi
|
||||||
|
ARG="$1"; shift;
|
||||||
|
fi
|
||||||
case $ARG in
|
case $ARG in
|
||||||
-q*|--quite ) export DFS_QUIET=1 ;;
|
-q*|--quite ) export DFS_QUIET=1 ;;
|
||||||
-l*|--lite ) export DFS_LITE=1 ;;
|
-l*|--lite ) export DFS_LITE=1 ;;
|
||||||
@ -162,19 +165,6 @@ ask_for_Yn()
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
post_log()
|
|
||||||
{
|
|
||||||
if [[ $# != 3 || -z "$1" || -z "$2" || -z "$3" ]]; then
|
|
||||||
fmt_fatal "usage: post_log <level> <section> <content>"
|
|
||||||
fi
|
|
||||||
"${DOTFILES}/tools/frigg-client.sh" "log" "[$1][$2] $3"
|
|
||||||
}
|
|
||||||
|
|
||||||
apost_log()
|
|
||||||
{
|
|
||||||
post_log "$@" 1>/dev/null &
|
|
||||||
}
|
|
||||||
|
|
||||||
post_beacon()
|
post_beacon()
|
||||||
{
|
{
|
||||||
if [[ $# < 1 || -z "$1" ]]; then
|
if [[ $# < 1 || -z "$1" ]]; then
|
||||||
|
@ -25,6 +25,7 @@ elif [[ -f /etc/hostname ]]; then
|
|||||||
else
|
else
|
||||||
fmt_fatal "unable to get hostname"
|
fmt_fatal "unable to get hostname"
|
||||||
fi
|
fi
|
||||||
|
hostname=$(echo $hostname | tr '[:upper:]' '[:lower:]')
|
||||||
|
|
||||||
init_uuid()
|
init_uuid()
|
||||||
{
|
{
|
||||||
@ -63,8 +64,8 @@ handle_resp()
|
|||||||
|
|
||||||
post_beacon()
|
post_beacon()
|
||||||
{
|
{
|
||||||
local beacon_type=$1
|
local beacon_type="$1"
|
||||||
local meta=$2
|
local meta="$2"
|
||||||
if [[ -n "$CI" && "$beacon_type" != "gh.ci" && "$beacon_type" != "dfs.invalid-commit" && "$beacon_type" != "dfs.dirty" ]]; then
|
if [[ -n "$CI" && "$beacon_type" != "gh.ci" && "$beacon_type" != "dfs.invalid-commit" && "$beacon_type" != "dfs.dirty" ]]; then
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
@ -75,17 +76,6 @@ post_beacon()
|
|||||||
handle_resp "$resp"
|
handle_resp "$resp"
|
||||||
}
|
}
|
||||||
|
|
||||||
post_log()
|
|
||||||
{
|
|
||||||
local log_content=$1
|
|
||||||
if [[ -z "$log_content" ]]; then
|
|
||||||
fmt_fatal "log content is required"
|
|
||||||
fi
|
|
||||||
init_uuid
|
|
||||||
resp=$(curl $DFS_CURL_OPTIONS -sSL -X POST -H "Content-Type: text/plain" -d "$log_content" "https://api.beardic.cn/post-log?hostname=$hostname&uuid=$uuid")
|
|
||||||
handle_resp "$resp"
|
|
||||||
}
|
|
||||||
|
|
||||||
update_dns()
|
update_dns()
|
||||||
{
|
{
|
||||||
if [[ -z "$DFS_DDNS_IP4$DFS_DDNS_IP6" ]]; then
|
if [[ -z "$DFS_DDNS_IP4$DFS_DDNS_IP6" ]]; then
|
||||||
@ -138,7 +128,7 @@ update_dns()
|
|||||||
|
|
||||||
print_help()
|
print_help()
|
||||||
{
|
{
|
||||||
fmt_info "usage: $0 <beacon|log|ddns> [beacon_type|log_content]"
|
fmt_info "usage: $0 <beacon|ddns> [beacon_type] [beacon_meta]"
|
||||||
}
|
}
|
||||||
|
|
||||||
router()
|
router()
|
||||||
@ -150,9 +140,6 @@ router()
|
|||||||
beacon)
|
beacon)
|
||||||
post_beacon "$2" "$3"
|
post_beacon "$2" "$3"
|
||||||
;;
|
;;
|
||||||
log)
|
|
||||||
post_log "$2"
|
|
||||||
;;
|
|
||||||
ddns)
|
ddns)
|
||||||
update_dns
|
update_dns
|
||||||
;;
|
;;
|
||||||
|
9
tools/sagent-op.sh
Executable file
9
tools/sagent-op.sh
Executable file
@ -0,0 +1,9 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
op=$(command -v op || command -v op.exe || true)
|
||||||
|
if [[ ! -x $op ]]; then
|
||||||
|
echo "1password cli not found" > /dev/stderr
|
||||||
|
exit -1
|
||||||
|
fi
|
||||||
|
"$op" read "op://Personal/id25519-passphrase/$(hostname)"
|
@ -47,6 +47,12 @@ add_piv()
|
|||||||
list
|
list
|
||||||
}
|
}
|
||||||
|
|
||||||
|
add_id25519_with_op()
|
||||||
|
{
|
||||||
|
SSH_ASKPASS_REQUIRE=force SSH_ASKPASS="$THIS_DIR/sagent-op.sh" timeout 60s ssh-add ~/.ssh/id_ed25519 || fmt_fatal "timed out when adding the key. probably the passphrase is wrong or 1password-cli is not working"
|
||||||
|
list
|
||||||
|
}
|
||||||
|
|
||||||
list()
|
list()
|
||||||
{
|
{
|
||||||
echo echo "available keys:"
|
echo echo "available keys:"
|
||||||
@ -96,6 +102,9 @@ route()
|
|||||||
piv)
|
piv)
|
||||||
add_piv
|
add_piv
|
||||||
;;
|
;;
|
||||||
|
op)
|
||||||
|
add_id25519_with_op
|
||||||
|
;;
|
||||||
reset)
|
reset)
|
||||||
reset
|
reset
|
||||||
;;
|
;;
|
||||||
|
@ -27,7 +27,6 @@ fi
|
|||||||
|
|
||||||
# check scripts and functions
|
# check scripts and functions
|
||||||
dfs version
|
dfs version
|
||||||
dfs log 1
|
|
||||||
dfs beacon gh.ci $GITHUB_SHA
|
dfs beacon gh.ci $GITHUB_SHA
|
||||||
z ~
|
z ~
|
||||||
test ~ -ef "$(pwd)"
|
test ~ -ef "$(pwd)"
|
||||||
@ -41,8 +40,9 @@ test $(echo n | tools/common.sh ask_for_yN "test") = "0"
|
|||||||
test $(echo | tools/common.sh ask_for_yN "test") = "0"
|
test $(echo | tools/common.sh ask_for_yN "test") = "0"
|
||||||
test $(echo | tools/common.sh ask_for_Yn "test") = "1"
|
test $(echo | tools/common.sh ask_for_Yn "test") = "1"
|
||||||
test $(DFS_QUIET=1 tools/common.sh ask_for_Yn "test") = "1"
|
test $(DFS_QUIET=1 tools/common.sh ask_for_Yn "test") = "1"
|
||||||
test "$(DFS_TRUST=1 riot time@is.impt:2222/yes@you-r.right/you@are.really.recht./ibd./try@it,another@host scp /tmp/ ./tmp -D 2>/dev/null)" = 'scp -P 12022 -o PermitLocalCommand=yes -o ControlMaster=auto -o ControlPath=~/.ssh/master-socket/%C -o ProxyJump=time@is.impt:2222,yes@you-r.right,you@are.really.recht.,root@ibd. -r try@it.dxng.net:"/tmp/" "./tmp"
|
test "$(DFS_TRUST=1 riot time@is.impt:2222/yes@you-r.right/you@are.really.recht./ibd./try@it,another@host scp /tmp/ ./tmp -D 2>/dev/null)" = 'scp -P 12022 -o RequestTTY=yes -o PermitLocalCommand=yes -o ControlMaster=auto -o ControlPath=~/.ssh/master-socket/%C -o ProxyJump=time@is.impt:2222,yes@you-r.right:12022,you@are.really.recht:12022,root@ibd:12022 -r try@it.dxng.net:/tmp/ ./tmp
|
||||||
scp -P 12022 -o PermitLocalCommand=yes -o ControlMaster=auto -o ControlPath=~/.ssh/master-socket/%C -o ForwardX11=yes -o ForwardAgent=yes -r another@host.dxng.net:"/tmp/" "./tmp"'
|
scp -P 12022 -o RequestTTY=yes -o PermitLocalCommand=yes -o ControlMaster=auto -o ControlPath=~/.ssh/master-socket/%C -o ForwardX11=yes -o ForwardAgent=yes -r another@host.dxng.net:/tmp/ ./tmp'
|
||||||
|
test "$(riot you@example.com:55 -tD ssh --password -- ping -c 1 2>/dev/null)" = 'ssh -p 55 -o RequestTTY=yes -o ForwardX11=yes -o ForwardAgent=yes -o PasswordAuthentication=yes -o PubkeyAuthentication=no you@example.com ping -c 1'
|
||||||
|
|
||||||
# check alias
|
# check alias
|
||||||
alias p114
|
alias p114
|
||||||
|
@ -4,7 +4,7 @@ declare -A INSTALL_COMMANDS
|
|||||||
INSTALL_COMMANDS=(\
|
INSTALL_COMMANDS=(\
|
||||||
[git]="apt update && apt install git" \
|
[git]="apt update && apt install git" \
|
||||||
[fzf]="git clone --depth 1 https://gitee.com/dictxiong/fzf.git ~/.fzf && ~/.fzf/install" \
|
[fzf]="git clone --depth 1 https://gitee.com/dictxiong/fzf.git ~/.fzf && ~/.fzf/install" \
|
||||||
[acme.sh]="curl https://get.acme.sh | sh -s email=${EMAIL:-me@beardic.cn}" \
|
[acme.sh]="curl https://get.acme.sh | sh -s email=${EMAIL:-acme@dxng.net}" \
|
||||||
[oh-my-zsh]='sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"' \
|
[oh-my-zsh]='sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"' \
|
||||||
[oh-my-tuna]='wget https://tuna.moe/oh-my-tuna/oh-my-tuna.py && sudo python oh-my-tuna.py --global' \
|
[oh-my-tuna]='wget https://tuna.moe/oh-my-tuna/oh-my-tuna.py && sudo python oh-my-tuna.py --global' \
|
||||||
[v2fly]="bash <(curl -L https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-release.sh) #--remove" \
|
[v2fly]="bash <(curl -L https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-release.sh) #--remove" \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user