21 Commits

Author SHA1 Message Date
xiongdian.me
4e5dfce9fb riot: support multiple remotes, delimiter=comma (,) 2023-11-03 18:55:24 +08:00
xiongdian.me
c5841e4aaa riot: proxy delimiter from comma (,) to slash (/) 2023-11-03 18:34:55 +08:00
xiongdian.me
37abe68d1f riot: ssh support instant command 2023-08-21 18:36:44 +08:00
deec5c9b05 riot use get_free_port to fix issue on windows 2023-08-17 18:05:51 +08:00
xiongdian.me
2ffc0e38f4 common.sh: is_port_free and get_free_port 2023-08-08 18:05:14 +08:00
xiongdian.me
fb43df06f4 sagt: import ssh-agent -P paths 2023-08-07 15:48:33 +08:00
xiongdian.me
34b2a2a5ad sagt: reset agent so paths 2023-08-03 19:45:27 +08:00
xiongdian.me
41f910e31d .zshrc: warn if not in main channel 2023-08-02 00:00:10 +08:00
xiongdian.me
dbba66ccd0 riot: shortcuts i,x,j 2023-08-01 23:51:29 +08:00
xiongdian.me
2ecdf945a9 riot: add domain box[0-9] 2023-08-01 23:38:49 +08:00
xiongdian.me
5938ca8d22 try to fix ci for macos 2023-07-29 16:21:10 +08:00
xiongdian.me
aafafda412 zshrc: try to use gnu-ls 2023-07-29 16:10:52 +08:00
xiongdian.me
e57ec2dc5d zshrc: use gnu ls on mac 2023-07-29 15:59:53 +08:00
xiongdian.me
fe938f113b to-install: nix 2023-07-29 03:59:09 +08:00
xiongdian.me
9f3c55a5f7 .zshrc: alias sl for sudo zsh -l 2023-07-29 03:35:23 +08:00
8e3f069c6d auth: add .eid/authorized_certificates for pam pkcs11 auth 2023-07-27 02:46:28 +08:00
5fb7ff0833 [debug] support nixos; fix ci (#41)
* support for nixos

* fix ci
2023-07-26 21:18:24 +08:00
39b8dfce82 [debug/dev] loosen riot username check; autoload zcalc (#40)
* riot: loosen username check as sometimes it's not a unix username

* Revert "riot: loosen username check as sometimes it's not a unix username"

This reverts commit bdb64ce1f2.

* riot: loosen username check as sometimes it's not a unix username

* zshrc: autoload zcalc

---------

Co-authored-by: xiongdian.me <xiongdian.me@bytedance.com>
2023-07-03 16:52:06 +08:00
1a62ffe74b [debug+dev] riot checks and fix ipv6 support, fix crontab installation; antigen use F-Sy-H (#39)
* format: remove space

* sry but..., riot: 'i' for 'ibd', and remove support for ebd

* fix ipv6 support

* validate port and username

* install.sh: failed to add to crontab when there's no crontab

* sync zdharma-continuum/fast-syntax-highlighting

* use fast-syntax-highlighting instead

---------

Co-authored-by: xiongdian.me <xiongdian.me@bytedance.com>
2023-06-20 15:10:59 +08:00
2cc2ab48b8 [dev] enhance riot; ddns avoid burst (#38)
* riot: add . for .ibd and non for proxied

* riot: 'user@..' to overwrite username, '...:22' to overwrite port, treat the arg as server name if it doesn't match any preset, sshl can accept only a port number and default to use localhost

* update.sh: ddns sleep for random seconds to avoid burst

* riot: support zssh and sftp, and set ssh options according to trust settings

* riot: add scp

* riot: support jump servers, sep by commas

* common.sh: argparser supports -d/--dev and -D/--dry-run

* install.sh: remove -s/--secure because of no use

* riot: if remote ends with dot, treat it as a full-hostname; add tests

* sagent.sh: refuse to work on windows

---------

Co-authored-by: xiongdian.me <xiongdian.me@bytedance.com>
2023-05-30 13:43:25 +08:00
37bf1fa1f0 [keys] remove pc{0,1}/old,sk0/fido,ph0/sep, update pc1/windows (#37)
keys: remove pc{0,1}/old,sk0/fido,ph0/sep, update pc1/windows
2023-04-29 17:46:01 +08:00
23 changed files with 446 additions and 201 deletions

View File

@@ -0,0 +1,30 @@
-----BEGIN CERTIFICATE-----
MIIFIDCCAwigAwIBAgIUK1zXH5UosBim7i+kIZyPGpowU9cwDQYJKoZIhvcNAQEL
BQAwgZUxCzAJBgNVBAYTAkNOMRAwDgYDVQQIDAdCRUlKSU5HMRAwDgYDVQQHDAdC
RUlKSU5HMRIwEAYDVQQKDAlEaWN0IFRlY2gxEDAOBgNVBAsMB1Jvb3QgQ0ExHjAc
BgNVBAMMFURpY3QgVGVjaCBSb290IENBIC0gMDEcMBoGCSqGSIb3DQEJARYNbWVA
YmVhcmRpYy5jbjAeFw0yMjA3MjIxNzU5MjNaFw0yNTA3MjExNzU5MjNaMEkxEjAQ
BgNVBAoMCURpY3QgVGVjaDEQMA4GA1UECAwHQkVJSklORzELMAkGA1UEBhMCQ04x
FDASBgNVBAMMC3NrMC5pYmQuaW5rMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIB
CgKCAQEAlDeyFxeJ5RXFX4B3rIIpNyyAIl5VTGCT5t8g9dxFWq0MeY6nQYJPA8IJ
IH+KzzujBabyKYpzshDvMzkuhx0Kwi2VL+ckxWg5FLge3kNBJqYnBm5pPWx6o9R5
DmcWqG5KRH0FJhSmL5KeBHsVcOurDtKn174x2eB+sggCSyuWlJyn4KxPLTg8z/Nr
FP5qSY1vj6t7mpzau+eIGh8IcQiFxteN/86fKswQHint/MVaqg6vX05BuIb8xb5E
XUvPIupdc/vtD959BxnTo7UoOz+3zu/u2cj2K9IDubwe9tDpv88aj6xnfXInFouD
/mlSmvtLo1h/6arn1hurgoylh5wbOwIDAQABo4GyMIGvMAkGA1UdEwQCMAAwCwYD
VR0PBAQDAgTwMB0GA1UdDgQWBBR9DxLqtR0+zUWoPyFoDRrnyJyDBTAfBgNVHSME
GDAWgBRsprmVI/Tjey+sw4qoZpLd7PT0gTBVBgNVHSUETjBMBggrBgEFBQcDAgYI
KwYBBQUHAwMGCCsGAQUFBwMEBggrBgEFBQcDCAYKKwYBBAGCN0MBAQYKKwYBBAGC
N0MBAgYKKwYBBAGCNxQCAjANBgkqhkiG9w0BAQsFAAOCAgEA7BJXiRg32shmZWyY
gPjq52ffN9RDNe58KadajJ1PnVP1yNJySgsOG3eSxONQX3ITr36Ihsfb3fZneBfX
/IcXgjyvy1CDcvBBAyee91hdR8orMCePqMpeOSNP9CUp9Ctd4V+an0DE8Z1yrezA
ieaYgBZCDxuZdloYSmj9Z/Rqn2dy4dcUAxKrEwW/6VPqQNrJETTtadS1SF0EsDxV
XZpDqNYaS/N7/ciSm7TaQJud62A4m+FWWHNnttTp9IjLESr3U80+qtRY8yDNpulb
/eNL8KK9aORiFUz9789l6M62HPi6vCsMflI0iHUeoi69GKX8mKf0WFR1KxoDsJiN
DG9/1gCfj6whFCrT6fJTKAGl8Hp5toWMOeDprbsE5gf4Ik3p+sKMV9t43zNm3gvA
1zNPtgQUffPU0kONlavIxUNfCmD8qVwK5ECT7wh0hrB8fRYfxTZHgN6Yvu7M9HNz
SNt5JZCLBT4nLt0uQp9O/xctdHElZw+/W8OfnP5vxnPdccIeVOxpGIyzErwjD0+E
9mNiqOa5JV9OMAJ+0I9cbOnuMaXm4mvHZadnetUzq2ZUw1Jba7z62zIJTciNRq9i
ZJc6v5e+iqbE1ECZLco5LjWqqfvFfYCrkqeOhCRsRkVPsXnGPo2QDDYdTm4EGCmg
dVZ6R452SZsrE4V+3LR011BxzEg=
-----END CERTIFICATE-----

View File

@@ -8,17 +8,17 @@ jobs:
dotfiles: dotfiles:
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
steps: steps:
- name: DictXiong/dotfiles # 名字随便起 - name: DictXiong/dotfiles
uses: Yikun/hub-mirror-action@v1.2 # 使用Yikun/hub-mirror-action uses: Yikun/hub-mirror-action@v1.3
with: with:
src: github/DictXiong # 源端账户名(github) src: github/DictXiong
dst: gitee/dictxiong # 目的端账户名(gitee) dst: gitee/dictxiong
dst_key: ${{ secrets.GITEE_PRIVATE_KEY }} # SSH密钥对中的私钥 dst_key: ${{ secrets.GITEE_PRIVATE_KEY }}
dst_token: ${{ secrets.GITEE_TOKEN }} # Gitee账户的私人令牌 dst_token: ${{ secrets.GITEE_TOKEN }}
src_account_type: user src_account_type: user
dst_account_type: user # 账户类型 dst_account_type: user
clone_style: "https" # 使用https方式进行clone,也可以使用ssh clone_style: "https"
debug: true # 启用后会显示所有执行命令 debug: true
force_update: true # 启用后,强制同步,即强制覆盖目的端仓库 force_update: true
static_list: "dotfiles" # 静态同步列表,在此填写需要同步的仓库名称,可填写多个 static_list: "dotfiles"
timeout: '600s' # git超时设置,超时后会自动重试git操作 timeout: '600s'

View File

@@ -7,119 +7,136 @@ jobs:
ohmyzsh: ohmyzsh:
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
steps: steps:
- name: ohmyzsh repo # 名字随便起 - name: ohmyzsh repo
uses: Yikun/hub-mirror-action@v1.2 # 使用Yikun/hub-mirror-action uses: Yikun/hub-mirror-action@v1.3
with: with:
src: github/ohmyzsh # 源端账户名(github) src: github/ohmyzsh
dst: gitee/dictxiong # 目的端账户名(gitee) dst: gitee/dictxiong
dst_key: ${{ secrets.GITEE_PRIVATE_KEY }} # SSH密钥对中的私钥 dst_key: ${{ secrets.GITEE_PRIVATE_KEY }}
dst_token: ${{ secrets.GITEE_TOKEN }} # Gitee账户的私人令牌 dst_token: ${{ secrets.GITEE_TOKEN }}
src_account_type: org src_account_type: org
dst_account_type: user # 账户类型 dst_account_type: user
clone_style: "https" # 使用https方式进行clone,也可以使用ssh clone_style: "https" # https/ssh
debug: true # 启用后会显示所有执行命令 debug: true # print all commands
force_update: true # 启用后,强制同步,即强制覆盖目的端仓库 force_update: true
static_list: "ohmyzsh" # 静态同步列表,在此填写需要同步的仓库名称,可填写多个 static_list: "ohmyzsh"
timeout: '600s' # git超时设置,超时后会自动重试git操作 timeout: '600s'
zsh-users: zsh-users:
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
steps: steps:
- name: zsh-users repos # 名字随便起 - name: zsh-users repos
uses: Yikun/hub-mirror-action@v1.2 # 使用Yikun/hub-mirror-action uses: Yikun/hub-mirror-action@v1.3
with: with:
src: github/zsh-users # 源端账户名(github) src: github/zsh-users
dst: gitee/dictxiong # 目的端账户名(gitee) dst: gitee/dictxiong
dst_key: ${{ secrets.GITEE_PRIVATE_KEY }} # SSH密钥对中的私钥 dst_key: ${{ secrets.GITEE_PRIVATE_KEY }}
dst_token: ${{ secrets.GITEE_TOKEN }} # Gitee账户的私人令牌 dst_token: ${{ secrets.GITEE_TOKEN }}
src_account_type: org src_account_type: org
dst_account_type: user # 账户类型 dst_account_type: user
clone_style: "https" # 使用https方式进行clone,也可以使用ssh clone_style: "https"
debug: true # 启用后会显示所有执行命令 debug: true
force_update: true # 启用后,强制同步,即强制覆盖目的端仓库 force_update: true
static_list: "antigen,zsh-syntax-highlighting,zsh-autosuggestions,zsh-completions" # 静态同步列表,在此填写需要同步的仓库名称,可填写多个 static_list: "antigen,zsh-syntax-highlighting,zsh-autosuggestions,zsh-completions"
timeout: '600s' # git超时设置,超时后会自动重试git操作 timeout: '600s'
zdharma-continuum:
runs-on: ubuntu-20.04
steps:
- name: zdharma-continuum repos
uses: Yikun/hub-mirror-action@v1.3
with:
src: github/zdharma-continuum
dst: gitee/dictxiong
dst_key: ${{ secrets.GITEE_PRIVATE_KEY }}
dst_token: ${{ secrets.GITEE_TOKEN }}
src_account_type: org
dst_account_type: user
clone_style: "https"
debug: true
force_update: true
static_list: "fast-syntax-highlighting"
timeout: '600s'
tmux-mem-cpu-load: tmux-mem-cpu-load:
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
steps: steps:
- name: thewtex/tmux-mem-cpu-load # 名字随便起 - name: thewtex/tmux-mem-cpu-load
uses: Yikun/hub-mirror-action@v1.2 # 使用Yikun/hub-mirror-action uses: Yikun/hub-mirror-action@v1.3
with: with:
src: github/thewtex # 源端账户名(github) src: github/thewtex
dst: gitee/dictxiong # 目的端账户名(gitee) dst: gitee/dictxiong
dst_key: ${{ secrets.GITEE_PRIVATE_KEY }} # SSH密钥对中的私钥 dst_key: ${{ secrets.GITEE_PRIVATE_KEY }}
dst_token: ${{ secrets.GITEE_TOKEN }} # Gitee账户的私人令牌 dst_token: ${{ secrets.GITEE_TOKEN }}
src_account_type: user src_account_type: user
dst_account_type: user # 账户类型 dst_account_type: user
clone_style: "https" # 使用https方式进行clone,也可以使用ssh clone_style: "https"
debug: true # 启用后会显示所有执行命令 debug: true
force_update: true # 启用后,强制同步,即强制覆盖目的端仓库 force_update: true
static_list: "tmux-mem-cpu-load" # 静态同步列表,在此填写需要同步的仓库名称,可填写多个 static_list: "tmux-mem-cpu-load"
timeout: '600s' # git超时设置,超时后会自动重试git操作 timeout: '600s'
tmux-plugins: tmux-plugins:
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
steps: steps:
- name: tmux-plugins # 名字随便起 - name: tmux-plugins
uses: Yikun/hub-mirror-action@v1.2 # 使用Yikun/hub-mirror-action uses: Yikun/hub-mirror-action@v1.3
with: with:
src: github/tmux-plugins # 源端账户名(github) src: github/tmux-plugins
dst: gitee/dictxiong # 目的端账户名(gitee) dst: gitee/dictxiong
dst_key: ${{ secrets.GITEE_PRIVATE_KEY }} # SSH密钥对中的私钥 dst_key: ${{ secrets.GITEE_PRIVATE_KEY }}
dst_token: ${{ secrets.GITEE_TOKEN }} # Gitee账户的私人令牌 dst_token: ${{ secrets.GITEE_TOKEN }}
src_account_type: org src_account_type: org
dst_account_type: user # 账户类型 dst_account_type: user
clone_style: "https" # 使用https方式进行clone,也可以使用ssh clone_style: "https"
debug: true # 启用后会显示所有执行命令 debug: true
force_update: true # 启用后,强制同步,即强制覆盖目的端仓库 force_update: true
static_list: "tpm,tmux-resurrect" # 静态同步列表,在此填写需要同步的仓库名称,可填写多个 static_list: "tpm,tmux-resurrect"
timeout: '600s' # git超时设置,超时后会自动重试git操作 timeout: '600s'
vundle-vim: vundle-vim:
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
steps: steps:
- name: VundleVim/Vundle-vim # 名字随便起 - name: VundleVim/Vundle-vim
uses: Yikun/hub-mirror-action@v1.2 # 使用Yikun/hub-mirror-action uses: Yikun/hub-mirror-action@v1.3
with: with:
src: github/VundleVim # 源端账户名(github) src: github/VundleVim
dst: gitee/dictxiong # 目的端账户名(gitee) dst: gitee/dictxiong
dst_key: ${{ secrets.GITEE_PRIVATE_KEY }} # SSH密钥对中的私钥 dst_key: ${{ secrets.GITEE_PRIVATE_KEY }}
dst_token: ${{ secrets.GITEE_TOKEN }} # Gitee账户的私人令牌 dst_token: ${{ secrets.GITEE_TOKEN }}
src_account_type: org src_account_type: org
dst_account_type: user # 账户类型 dst_account_type: user
clone_style: "https" # 使用https方式进行clone,也可以使用ssh clone_style: "https"
debug: true # 启用后会显示所有执行命令 debug: true
force_update: true # 启用后,强制同步,即强制覆盖目的端仓库 force_update: true
static_list: "Vundle.vim" # 静态同步列表,在此填写需要同步的仓库名称,可填写多个 static_list: "Vundle.vim"
timeout: '600s' # git超时设置,超时后会自动重试git操作 timeout: '600s'
onedark-vim: onedark-vim:
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
steps: steps:
- name: joshdick/onedark-vim # 名字随便起 - name: joshdick/onedark-vim
uses: Yikun/hub-mirror-action@v1.2 # 使用Yikun/hub-mirror-action uses: Yikun/hub-mirror-action@v1.3
with: with:
src: github/joshdick # 源端账户名(github) src: github/joshdick
dst: gitee/dictxiong # 目的端账户名(gitee) dst: gitee/dictxiong
dst_key: ${{ secrets.GITEE_PRIVATE_KEY }} # SSH密钥对中的私钥 dst_key: ${{ secrets.GITEE_PRIVATE_KEY }}
dst_token: ${{ secrets.GITEE_TOKEN }} # Gitee账户的私人令牌 dst_token: ${{ secrets.GITEE_TOKEN }}
src_account_type: user src_account_type: user
dst_account_type: user # 账户类型 dst_account_type: user
clone_style: "https" # 使用https方式进行clone,也可以使用ssh clone_style: "https"
debug: true # 启用后会显示所有执行命令 debug: true
force_update: true # 启用后,强制同步,即强制覆盖目的端仓库 force_update: true
static_list: "onedark.vim" # 静态同步列表,在此填写需要同步的仓库名称,可填写多个 static_list: "onedark.vim"
timeout: '600s' # git超时设置,超时后会自动重试git操作 timeout: '600s'
fzf: fzf:
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
steps: steps:
- name: junegunn/fzf # 名字随便起 - name: junegunn/fzf
uses: Yikun/hub-mirror-action@v1.2 # 使用Yikun/hub-mirror-action uses: Yikun/hub-mirror-action@v1.3
with: with:
src: github/junegunn # 源端账户名(github) src: github/junegunn
dst: gitee/dictxiong # 目的端账户名(gitee) dst: gitee/dictxiong
dst_key: ${{ secrets.GITEE_PRIVATE_KEY }} # SSH密钥对中的私钥 dst_key: ${{ secrets.GITEE_PRIVATE_KEY }}
dst_token: ${{ secrets.GITEE_TOKEN }} # Gitee账户的私人令牌 dst_token: ${{ secrets.GITEE_TOKEN }}
src_account_type: user src_account_type: user
dst_account_type: user # 账户类型 dst_account_type: user
clone_style: "https" # 使用https方式进行clone,也可以使用ssh clone_style: "https"
debug: true # 启用后会显示所有执行命令 debug: true
force_update: true # 启用后,强制同步,即强制覆盖目的端仓库 force_update: true
static_list: "fzf" # 静态同步列表,在此填写需要同步的仓库名称,可填写多个 static_list: "fzf"
timeout: '600s' # git超时设置,超时后会自动重试git操作 timeout: '600s'

View File

@@ -1,13 +1,8 @@
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIPmMImRSAhksHUfCwNpcj61izGn0Xkv1KRIuxb0OSdJl pc0/old
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIO4K5S3zDYbxlw7B45zOdmKud95nXU1V6kSxEvbTOsy2 pc1/old
# keys below are the new security system starting from 2022-07 # keys below are the new security system starting from 2022-07
sk-ssh-ed25519@openssh.com AAAAGnNrLXNzaC1lZDI1NTE5QG9wZW5zc2guY29tAAAAIGdLJYOrBhWERmkQ+sNM8tGzJ37UBEKkEuhbtE9B65mOAAAABHNzaDo= sk0/fido
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGakUcSuNhuH7tk+Nj9gDfRtxYfGPL9yb8toQ/EpSJAM openpgp:0xD9271B01 ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGakUcSuNhuH7tk+Nj9gDfRtxYfGPL9yb8toQ/EpSJAM openpgp:0xD9271B01
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCUN7IXF4nlFcVfgHesgik3LIAiXlVMYJPm3yD13EVarQx5jqdBgk8Dwgkgf4rPO6MFpvIpinOyEO8zOS6HHQrCLZUv5yTFaDkUuB7eQ0EmpicGbmk9bHqj1HkOZxaobkpEfQUmFKYvkp4EexVw66sO0qfXvjHZ4H6yCAJLK5aUnKfgrE8tODzP82sU/mpJjW+Pq3uanNq754gaHwhxCIXG143/zp8qzBAeKe38xVqqDq9fTkG4hvzFvkRdS88i6l1z++0P3n0HGdOjtSg7P7fO7+7ZyPYr0gO5vB720Om/zxqPrGd9cicWi4P+aVKa+0ujWH/pqufWG6uCjKWHnBs7 sk0.ibd.ink/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 AAAAC3NzaC1lZDI1NTE5AAAAIGV/6cLUGA5YWVI6uPhIBOBZvlNBlZLkehHQN0Gxnc+B ltp0/ubuntu
@@ -21,9 +16,7 @@ ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIBN24pvN1RMN+iSZyHPdyExA1Rvt8pdr3e6ih6iX+KrQ
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGZFTyR+R86fUpZBDkDR9yYzJpmeNsIv2CMHTh6EuEeq pc0/windows ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGZFTyR+R86fUpZBDkDR9yYzJpmeNsIv2CMHTh6EuEeq pc0/windows
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAID8WHIpwdZl7+HIZfQpwIAhpxT1huI9sd6Ydeokilg5l pc1/windows ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHLYgVj+NPino6sOmahULN7SbAMaVAgzqPfDjz2S8zDv pc1/windows
ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBJ/+BWSTv3w1Ru9ksfse3EUbu4ukJruUU94fCG7Sk+5g3+F80KqJGykP9tHueU07iZfAuaYj7Zcy+IWx9Ih+eYA= ph0/sep
ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBNvHya5i3GNniGww9Yx5ikos4Z5jevu8zz8hCQi05++SgejFPnbw9UjbHFjODK2M+ZHuhRF5mdf996r4/BxWyP8= pad0/sep ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBNvHya5i3GNniGww9Yx5ikos4Z5jevu8zz8hCQi05++SgejFPnbw9UjbHFjODK2M+ZHuhRF5mdf996r4/BxWyP8= pad0/sep
@@ -32,3 +25,4 @@ ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBC5gu+U4
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIF52mPmbLEriZ+DfmrMHFtvg2kiO2JpRpitvs7PbJowh home0 ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIF52mPmbLEriZ+DfmrMHFtvg2kiO2JpRpitvs7PbJowh home0
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKhS4voo3K/Dvzqckr0bouO1WkCI5XxswstHWnuuyKBz ltp1-bd ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKhS4voo3K/Dvzqckr0bouO1WkCI5XxswstHWnuuyKBz ltp1-bd

View File

@@ -1,4 +1,4 @@
#!/bin/bash #!/usr/bin/env bash
THIS_DIR=$( cd "$( dirname "${BASH_SOURCE[0]:-${(%):-%x}}" )" && pwd ) THIS_DIR=$( cd "$( dirname "${BASH_SOURCE[0]:-${(%):-%x}}" )" && pwd )
THIS_FILE=$(basename "${BASH_SOURCE}") THIS_FILE=$(basename "${BASH_SOURCE}")
@@ -13,6 +13,11 @@ apost_beacon "sys.online"
# update dns # update dns
if [[ "$DFS_DDNS_ENABLE" == "1" ]]; then if [[ "$DFS_DDNS_ENABLE" == "1" ]]; then
fmt_info "updating dns ..." fmt_info "updating dns ..."
if ! is_tty; then
time_to_sleep=$((RANDOM%600))
fmt_note "sleep for $time_to_sleep seconds"
sleep $time_to_sleep
fi
"$THIS_DIR/tools/frigg-client.sh" ddns || (fmt_error "failed to update dns" && apost_beacon "dfs.ddns.fail") "$THIS_DIR/tools/frigg-client.sh" ddns || (fmt_error "failed to update dns" && apost_beacon "dfs.ddns.fail")
fi fi

19
.zshrc2
View File

@@ -22,7 +22,7 @@ if [[ "$DFS_NO_WALL" == "1" ]]; then
ANTIGEN_URL="https://raw.githubusercontent.com/zsh-users/antigen/develop/bin/antigen.zsh" ANTIGEN_URL="https://raw.githubusercontent.com/zsh-users/antigen/develop/bin/antigen.zsh"
ANTIGEN_OMZ_REPO_URL="https://github.com/ohmyzsh/ohmyzsh.git" ANTIGEN_OMZ_REPO_URL="https://github.com/ohmyzsh/ohmyzsh.git"
ANTIGEN_PLUGINS=( ANTIGEN_PLUGINS=(
"https://github.com/zsh-users/zsh-syntax-highlighting" "https://github.com/zdharma-continuum/fast-syntax-highlighting"
"https://github.com/zsh-users/zsh-completions" "https://github.com/zsh-users/zsh-completions"
"https://github.com/zsh-users/zsh-autosuggestions" "https://github.com/zsh-users/zsh-autosuggestions"
) )
@@ -30,7 +30,7 @@ else
ANTIGEN_URL="https://gitee.com/dictxiong/antigen/raw/develop/bin/antigen.zsh" ANTIGEN_URL="https://gitee.com/dictxiong/antigen/raw/develop/bin/antigen.zsh"
ANTIGEN_OMZ_REPO_URL="https://gitee.com/dictxiong/ohmyzsh.git" ANTIGEN_OMZ_REPO_URL="https://gitee.com/dictxiong/ohmyzsh.git"
ANTIGEN_PLUGINS=( ANTIGEN_PLUGINS=(
"https://gitee.com/dictxiong/zsh-syntax-highlighting" "https://gitee.com/dictxiong/fast-syntax-highlighting"
"https://gitee.com/dictxiong/zsh-completions" "https://gitee.com/dictxiong/zsh-completions"
"https://gitee.com/dictxiong/zsh-autosuggestions" "https://gitee.com/dictxiong/zsh-autosuggestions"
) )
@@ -101,16 +101,15 @@ fi
# alias # alias
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 "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 2001:da8::666'
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))"'
case $(bash "$DOTFILES/tools/common.sh" get_os_type) in alias "ls"='ls --color=tty'
macos ) alias l='ls -lAGh -D "%y-%m-%d %H:%M"' ;; alias "l"='ls -lAGh --time-style="+%y-%m-%d %H:%M"'
* ) alias l='ls -lAGh --time-style="+%y-%m-%d %H:%M"' ;;
esac
if [[ -x $(command -v trash) ]]; then if [[ -x $(command -v trash) ]]; then
alias "rm"="echo use the full path i.e. '/bin/rm'\; consider using trash" alias "rm"="echo use the full path i.e. '/bin/rm'\; consider using trash"
fi fi
@@ -140,6 +139,9 @@ bindkey "\e[1;5D" backward-word # alt+left_arrow; termius
bindkey "\ed" delete-char # alt+d bindkey "\ed" delete-char # alt+d
# mods
autoload zcalc
# dfs # dfs
dfs() dfs()
{ {
@@ -174,6 +176,11 @@ dfs()
esac esac
} }
# motd
if [[ "$DFS_INITED" != "1" && -n "$DFS_UPDATE_CHANNEL" && "$DFS_UPDATE_CHANNEL" != "main" ]]; then
echo dotfiles not in the main channel. use with caution.
fi
# clean # clean
unset i unset i
export DFS_INITED=1 export DFS_INITED=1

View File

@@ -1,4 +1,4 @@
#!/bin/bash #!/usr/bin/env bash
set -e set -e
THIS_DIR=$( cd "$( dirname "${BASH_SOURCE[0]:-${(%):-%x}}" )" && pwd ) THIS_DIR=$( cd "$( dirname "${BASH_SOURCE[0]:-${(%):-%x}}" )" && pwd )
source "$THIS_DIR/tools/common.sh" source "$THIS_DIR/tools/common.sh"
@@ -26,6 +26,8 @@ declare -a HOME_SYMLINKS_SRC
declare -a HOME_SYMLINKS_DST declare -a HOME_SYMLINKS_DST
HOME_SYMLINKS_SRC[0]=".ssh/authorized_keys2" HOME_SYMLINKS_SRC[0]=".ssh/authorized_keys2"
HOME_SYMLINKS_DST[0]=".ssh/authorized_keys2" HOME_SYMLINKS_DST[0]=".ssh/authorized_keys2"
HOME_SYMLINKS_SRC[1]=".eid/authorized_certificates"
HOME_SYMLINKS_DST[1]=".eid/authorized_certificates"
install_dependencies() install_dependencies()
{ {
@@ -197,6 +199,9 @@ install_crontab()
{ {
if [[ -x $(command -v crontab) ]]; then if [[ -x $(command -v crontab) ]]; then
fmt_note "installing \"$CRON_JOB\" to crontab ..." fmt_note "installing \"$CRON_JOB\" to crontab ..."
if ! crontab -l 1>/dev/null 2>&1; then
echo -n | crontab -
fi
( crontab -l | grep -vxF "${CRON_JOB}" | grep -v "no crontab for"; echo "$CRON_JOB" ) | crontab - ( crontab -l | grep -vxF "${CRON_JOB}" | grep -v "no crontab for"; echo "$CRON_JOB" ) | crontab -
else else
fmt_warning "crontab does not exist. skipping ..." fmt_warning "crontab does not exist. skipping ..."
@@ -319,9 +324,7 @@ for i in ${GOT_OPTS[@]}; do
case $i in case $i in
-i ) FUNC=install ;; -i ) FUNC=install ;;
-r ) FUNC=uninstall ;; -r ) FUNC=uninstall ;;
-d|--dev ) export DFS_DEV=1; set -x ;;
-a|--auto ) INSTALL_DEP=1 ;; -a|--auto ) INSTALL_DEP=1 ;;
-s|--secure ) export DFS_DEV=0 ;;
-H|--hist|--history ) store_hist=1 ;; -H|--hist|--history ) store_hist=1 ;;
-x ) store_config=1 ;; -x ) store_config=1 ;;
* ) fmt_fatal "unknown option \"$i\"" ;; * ) fmt_fatal "unknown option \"$i\"" ;;

View File

@@ -1,4 +1,4 @@
#!/bin/bash #!/usr/bin/env bash
THIS_DIR=$( cd "$( dirname "${BASH_SOURCE[0]:-${(%):-%x}}" )" && pwd ) THIS_DIR=$( cd "$( dirname "${BASH_SOURCE[0]:-${(%):-%x}}" )" && pwd )
source "$THIS_DIR/../tools/common.sh" source "$THIS_DIR/../tools/common.sh"

View File

@@ -1,4 +1,4 @@
#!/bin/bash #!/usr/bin/env bash
THIS_DIR=$( cd "$( dirname "${BASH_SOURCE[0]:-${(%):-%x}}" )" && pwd ) THIS_DIR=$( cd "$( dirname "${BASH_SOURCE[0]:-${(%):-%x}}" )" && pwd )
source "$THIS_DIR/../tools/common.sh" source "$THIS_DIR/../tools/common.sh"

View File

@@ -1,4 +1,4 @@
#!/bin/bash #!/usr/bin/env bash
set -e set -e
THIS_DIR=$( cd "$( dirname "${BASH_SOURCE[0]:-${(%):-%x}}" )" && pwd ) THIS_DIR=$( cd "$( dirname "${BASH_SOURCE[0]:-${(%):-%x}}" )" && pwd )
source "$THIS_DIR/../tools/common.sh" source "$THIS_DIR/../tools/common.sh"

View File

@@ -1,101 +1,250 @@
#!/bin/bash #!/usr/bin/env bash
# connect to iot services # connect to iot services
THIS_DIR=$( cd "$( dirname "${BASH_SOURCE[0]:-${(%):-%x}}" )" && pwd ) 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_SERVER=${RIOT_TRUST_SERVER:-0}
# get target settings # check if port number valid
# provides: check_port() {
SERVER="" ( echo $1 | grep -qxE "[1-9][0-9]{0,4}" ) || return 1
PORT="" test $1 -lt 65536 -a $1 -gt 0 || return 1
SSH_USERNAME="" return 0
SSH_OPTIONS="" }
get_server_meta()
{ # check if username valid
local domain=${1##*.} check_username() {
local host=${1%.*} ( echo $1 | grep -qxE "^[a-z][-a-z0-9_]*\$" ) || return 1
if [[ "$host" == "$domain" ]]; then return 0
domain="" }
# get single server setting
# may be called more than once
get_server_meta() {
# returns:
RET_HOSTNAME=""
RET_TRUST_SERVER=0
RET_PORT="" # optional
RET_USERNAME="" # optional
RET_JUMP_SERVER="" # optional
# body
local remote="$1"
# shortcuts
if [[ "$remote" == "i" ]]; then
remote="sir0.ibd"
elif [[ "$remote" == "x" ]]; then
remote="bj1.ibd"
elif [[ "$remote" == "j" ]]; then
remote="sir0.ibd:36122"
fi
# if in the form user@...
if [[ "$remote" == *@* ]]; then
RET_USERNAME=${remote%%@*}
remote=${remote#*@}
check_username $RET_USERNAME || fmt_warning \"$RET_USERNAME\" is not a valid unix username
fi
# if in the form ...:22
if [[ "$remote" == "["*"]":* || ( "$remote" != "["*"]" && "$remote" == *:* ) ]]; then
RET_PORT=${remote##*:}
remote=${remote%:*}
check_port $RET_PORT || fmt_fatal invalid port number \"$RET_PORT\"
fi
# presets -- match domain
local domain=${remote##*.}
local host=${remote%.*}
# if there's no dot
if [[ "$host" == "$domain" && "$host" != "["*"]" ]]; then
domain="ibd"
fi fi
case $domain in case $domain in
ibd|ebd ) i|ibd )
SERVER=$host.$domain.ink RET_HOSTNAME=$host.ibd.ink
PORT=12022 RET_PORT=${RET_PORT:-12022}
SSH_USERNAME=root RET_USERNAME=${RET_USERNAME:-root}
RET_TRUST_SERVER=1
;; ;;
nasp ) nasp )
SERVER=$host RET_HOSTNAME=$host
PORT=12022 RET_PORT=${RET_PORT:-12022}
SSH_USERNAME=dictxiong RET_USERNAME=${RET_USERNAME:-dictxiong}
SSH_OPTIONS='-o ProxyJump="ssh@nasp.ob.ac.cn:36022"' RET_JUMP_SERVER="ssh@nasp.ob.ac.cn:36022"
RET_TRUST_SERVER=1
;; ;;
"" ) x|proxied )
SERVER=proxy.beardic.cn RET_HOSTNAME=proxy.beardic.cn
local tmp=$(sha256sum <<< "$host" | tr -cd "[:digit:]") local tmp=$(sha256sum <<< "$host" | tr -cd "[:digit:]")
tmp=${tmp:0:4} tmp=${tmp:0:4}
PORT=$((10#$tmp+36000)) RET_PORT=$((10#$tmp+36000))
SSH_USERNAME=root RET_USERNAME=root
RET_TRUST_SERVER=1
;;
box[0-9] )
RET_HOSTNAME=$host
RET_PORT=${RET_PORT:-12022}
RET_USERNAME=${RET_USERNAME:-root}
RET_JUMP_SERVER="root@$domain.ibd.ink:12022"
RET_TRUST_SERVER=1
;; ;;
* ) * )
fmt_fatal "unknown domain: $domain" test -z "$domain" || fmt_warning "unknown domain: \"$domain\". will try as host name"
RET_HOSTNAME="$remote"
esac esac
} }
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 jump_servers=""
# loop for jump servers
while [[ -n $remote ]]; do
local server=${remote%%/*}
remote=${remote#*/}
get_server_meta "$server"
if [[ -n "$RET_JUMP_SERVER" ]]; then
jump_servers="$jump_servers${jump_servers:+,}$RET_JUMP_SERVER"
fi
# only if all servers are trusted
TRUST_SERVER=$((TRUST_SERVER*RET_TRUST_SERVER))
if [[ "$server" == "$remote" || -z "$remote" ]]; then
SERVER="$RET_HOSTNAME"
PORT="$RET_PORT"
USERNAME="$RET_USERNAME"
remote=""
else
jump_servers="$jump_servers${jump_servers:+,}$RET_USERNAME${RET_USERNAME:+@}$RET_HOSTNAME${RET_PORT:+:}$RET_PORT"
fi
done
# construct cmd
if [[ "$RIOT_TRUST_SERVER" == "1" || "$TRUST_SERVER" == "1" ]]; then
SSH_OPTIONS="$SSH_OPTIONS -o ForwardX11=yes -o ForwardAgent=yes"
fi
if [[ -n "$jump_servers" ]]; then
SSH_OPTIONS="$SSH_OPTIONS -o ProxyJump=$jump_servers"
fi
}
eval_or_echo() {
if [[ "$DFS_DRY_RUN" == "1" ]]; then
echo $@
else
eval $@
fi
}
# ssh series
prepare_ssh_cmd() {
local ssh_bin="${1:-ssh}"
if [[ "$ssh_bin" == "scp" || "$ssh_bin" == "sftp" ]]; then
local port_param='-P'
else
local port_param='-p'
fi
echo "$ssh_bin ${PORT:+$port_param} $PORT $SSH_OPTIONS $SCP_SRC $USERNAME${USERNAME:+@}$SERVER $SCP_DST ${@:2}"
}
# ssh # ssh
run_ssh() run_ssh()
{ {
CMD="ssh -p $PORT $SSH_OPTIONS $SSH_USERNAME@$SERVER" local cmd="$(prepare_ssh_cmd $@)"
fmt_note "-->" $CMD fmt_note "-->" $cmd
eval $CMD eval_or_echo $cmd
} }
# sshl # sshl
run_sshl() run_sshl()
{ {
if [[ -z "$1" || "$1" != *":"* ]]; then local arg="$1"
fmt_fatal "invalid remote address: $1" if [[ "$arg" != *":"* ]]; then
# treat as a port number
arg=localhost:$arg
fi fi
while local port=$(get_free_port)
local port=$(shuf -n 1 -i 49152-65535)
netstat -atun | grep -q "$port" SSH_OPTIONS="$SSH_OPTIONS -NC -L $port:$arg"
do local cmd="$(prepare_ssh_cmd ssh)"
continue fmt_note "-->" $cmd
done
CMD="ssh -p $PORT $SSH_OPTIONS -NC -L $port:$1 $SSH_USERNAME@$SERVER"
fmt_note "-->" $CMD
fmt_note " > please access localhost:$port" fmt_note " > please access localhost:$port"
eval $CMD eval_or_echo $cmd
}
# scp
run_scp() {
local src="$1"
local dst="$2"
local dst_is_remote=1
# whoever is ./*, it can't be the remote; whoever not exists on local, it's possible the remote.
# it is suggested to use ./* for local files.
if [[ "$src" != "./"* && ( "$dst" == "./"* || ( ! -e "$src" && -e "$dst" ) ) ]]; then
dst_is_remote=0
fi
if [[ "$dst_is_remote" == "1" ]]; then
SCP_SRC=\""$src"\"
SERVER="$SERVER":\""$dst"\"
else
SERVER="$SERVER":\""$src"\"
SCP_DST=\""$dst"\"
fi
SSH_OPTIONS="$SSH_OPTIONS -r"
local cmd="$(prepare_ssh_cmd scp)"
fmt_note "-->" $cmd
eval_or_echo $cmd
} }
# main # main
print_help() print_help()
{ {
fmt_info "usage: $0 <service> [command] [options]" fmt_info "usage: $0 <service> [command] [options]"
echo "available commands: ssh (default), sshl (ssh -L)" echo "available commands: ssh (default), sshl (ssh -L), zssh, sftp"
} }
router() router() {
{
if [[ -z "$1" || "$1" == "-h" || "$1" == "--help" ]]; then if [[ -z "$1" || "$1" == "-h" || "$1" == "--help" ]]; then
print_help print_help
exit exit
fi fi
get_server_meta "$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 case $2 in
;; ssh|"" )
sshl ) run_ssh ssh "${@:3}"
run_sshl "$3" ;;
;; zssh )
* ) run_ssh zssh
print_help ;;
fmt_fatal "unknown command: $2" sftp )
;; run_ssh sftp
esac ;;
sshl )
test -n "$3" || fmt_fatal "no target address provided"
run_sshl "$3"
;;
scp )
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"
;;
esac
done
} }
router "${GOT_OPTS[@]}" router "${GOT_OPTS[@]}"

View File

@@ -1,4 +1,4 @@
#!/bin/bash #!/usr/bin/env bash
set -e set -e
THIS_DIR=$( cd "$( dirname "${BASH_SOURCE[0]:-${(%):-%x}}" )" && pwd ) THIS_DIR=$( cd "$( dirname "${BASH_SOURCE[0]:-${(%):-%x}}" )" && pwd )
source "$THIS_DIR/common.sh" source "$THIS_DIR/common.sh"

View File

@@ -1,4 +1,4 @@
#!/bin/bash #!/usr/bin/env bash
set -e set -e
THIS_DIR=$( cd "$( dirname "${BASH_SOURCE[0]:-${(%):-%x}}" )" && pwd ) THIS_DIR=$( cd "$( dirname "${BASH_SOURCE[0]:-${(%):-%x}}" )" && pwd )
source "$THIS_DIR/common.sh" source "$THIS_DIR/common.sh"

View File

@@ -1,9 +1,9 @@
#!/bin/bash #!/usr/bin/env bash
set -e set -e
THIS_DIR_COMMON_SH=$( cd "$( dirname "${BASH_SOURCE[0]:-${(%):-%x}}" )" && pwd ) THIS_DIR_COMMON_SH=$( cd "$( dirname "${BASH_SOURCE[0]:-${(%):-%x}}" )" && pwd )
export DOTFILES=$( cd "$THIS_DIR_COMMON_SH/.." && pwd ) export DOTFILES=$( cd "$THIS_DIR_COMMON_SH/.." && pwd )
if [[ -f ~/.config/dotfiles/env ]]; then set -a; source ~/.config/dotfiles/env; set +a; fi if [[ -f ~/.config/dotfiles/env ]]; then set -a; source ~/.config/dotfiles/env; set +a; fi
if [[ "$DFS_DEBUG" == "1" ]]; then set -x; fi if [[ "$DFS_DEV" == "1" ]]; then set -x; fi
DFS_CURL_OPTIONS="--retry 2 --max-time 20" DFS_CURL_OPTIONS="--retry 2 --max-time 20"
# parse args and set env, when it is sourced # parse args and set env, when it is sourced
@@ -17,8 +17,9 @@ if [[ "${BASH_SOURCE[0]}" != "${0}" ]]; then
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 ;;
-d*|--dev ) export DFS_DEV=1; set -x ;;
-D*|--dry-run ) export DFS_DRY_RUN=1 ;;
--color ) export DFS_COLOR=1 ;; --color ) export DFS_COLOR=1 ;;
--dry-run ) export DFS_DRY_RUN=1 ;; # TODO!!!
--*=* ) GOT_OPTS+=("${ARG%%=*}" "${ARG#*=}") ;; --*=* ) GOT_OPTS+=("${ARG%%=*}" "${ARG#*=}") ;;
--* ) GOT_OPTS+=("$ARG") ;; --* ) GOT_OPTS+=("$ARG") ;;
-* ) GOT_OPTS+=("${ARG:0:2}") ;; -* ) GOT_OPTS+=("${ARG:0:2}") ;;
@@ -232,6 +233,31 @@ get_os_name()
echo $ans echo $ans
} }
is_port_free() {
( echo $1 | grep -qxE "[1-9][0-9]{0,4}" ) || false
local cmd
case $(get_os_type) in
macos ) cmd="netstat -van | grep -q \".$1\"" ;;
cygwin|msys ) cmd="netstat -ano | grep -q \":$1\"" ;;
*) cmd="netstat -tuanp | grep -q \":$1\"" ;;
esac
if eval $cmd; then
return 2
else
return 0
fi
}
get_free_port() {
while
local port=$(shuf -n 1 -i 49152-65535)
! is_port_free $port
do
continue
done
echo $port
}
# if bash-ed, else source-d # if bash-ed, else source-d
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
$1 "${@:2}" $1 "${@:2}"

View File

@@ -1,4 +1,4 @@
#!/bin/bash #!/usr/bin/env bash
set -e set -e
THIS_DIR=$( cd "$( dirname "${BASH_SOURCE[0]:-${(%):-%x}}" )" && pwd ) THIS_DIR=$( cd "$( dirname "${BASH_SOURCE[0]:-${(%):-%x}}" )" && pwd )

View File

@@ -1,4 +1,4 @@
#!/bin/bash #!/usr/bin/env bash
set -e set -e
ARG="" ARG=""
GOT_OPTS=() GOT_OPTS=()

View File

@@ -1,4 +1,4 @@
#!/bin/bash #!/usr/bin/env bash
set -e set -e
THIS_DIR=$( cd "$( dirname "${BASH_SOURCE[0]:-${(%):-%x}}" )" && pwd ) THIS_DIR=$( cd "$( dirname "${BASH_SOURCE[0]:-${(%):-%x}}" )" && pwd )
source "$THIS_DIR/common.sh" source "$THIS_DIR/common.sh"
@@ -6,7 +6,7 @@ source "$THIS_DIR/common.sh"
brew_install() brew_install()
{ {
# brew update # brew update
brew install git zsh curl tmux vim util-linux brew install git zsh curl tmux vim util-linux coreutils
} }
router() router()

View File

@@ -1,4 +1,4 @@
#!/bin/bash #!/usr/bin/env bash
set -e set -e
THIS_DIR=$( cd "$( dirname "${BASH_SOURCE[0]:-${(%):-%x}}" )" && pwd ) THIS_DIR=$( cd "$( dirname "${BASH_SOURCE[0]:-${(%):-%x}}" )" && pwd )
source "$THIS_DIR/common.sh" source "$THIS_DIR/common.sh"

View File

@@ -1,13 +1,18 @@
#!/bin/bash #!/usr/bin/env bash
set -e set -e
THIS_DIR=$( cd "$( dirname "${BASH_SOURCE[0]:-${(%):-%x}}" )" && pwd ) THIS_DIR=$( cd "$( dirname "${BASH_SOURCE[0]:-${(%):-%x}}" )" && pwd )
export DFS_COLOR=1 export DFS_COLOR=1
source "$THIS_DIR/common.sh" source "$THIS_DIR/common.sh"
SO_PATHS=(
"/usr/lib/x86_64-linux-gnu/opensc-pkcs11.so" # ubuntu 22.04
"/run/current-system/sw/lib/opensc-pkcs11.so" # nixos 23.05
"/Library/OpenSC/lib/opensc-pkcs11.so" # macos 13.4
)
find_so_file() find_so_file()
{ {
local SO_PATHS=( "/usr/lib64/opensc-pkcs11.so" "/usr/local/lib/opensc-pkcs11.so" )
local SO_FILE local SO_FILE
for SO_FILE in ${SO_PATHS[*]}; do for SO_FILE in ${SO_PATHS[*]}; do
if [[ -f "$SO_FILE" ]]; then if [[ -f "$SO_FILE" ]]; then
@@ -19,12 +24,8 @@ find_so_file()
create_agent() create_agent()
{ {
local SO_FILE=$(find_so_file) local IFS=","
if [[ -n "$SO_FILE" ]]; then ssh-agent -P "${SO_PATHS[*]}"
fmt_note "opensc-pkcs11.so found"
SO_FILE="-P $SO_FILE"
fi
ssh-agent $SO_FILE
} }
kill_agent() kill_agent()
@@ -79,6 +80,10 @@ all()
route() route()
{ {
os_type="$(get_os_type)"
if [[ "$os_type" == "msys" || "$os_type" == "cygwin" ]]; then
fmt_fatal "unsupported platform: $os_type. you may use WinCryptSSHAgent."
fi
if [[ $# -eq 0 ]]; then if [[ $# -eq 0 ]]; then
all all
return return

View File

@@ -1,4 +1,4 @@
#!/bin/bash #!/usr/bin/env bash
set -ex set -ex
OPTS='-a -bcl --color --arg1=1 --arg2 2 " 1 2" yes' OPTS='-a -bcl --color --arg1=1 --arg2 2 " 1 2" yes'
TARGET_OPTS='-a -b -c --arg1 1 --arg2 2 1 2 yes' TARGET_OPTS='-a -b -c --arg1 1 --arg2 2 1 2 yes'

View File

@@ -3,6 +3,12 @@
set -ex set -ex
trap "dfs beacon gh.ci.fail" ERR trap "dfs beacon gh.ci.fail" ERR
# fix for macos
dfs cd
if [[ $(./tools/common.sh get_os_type) == "macos" ]]; then
export PATH="/usr/local/opt/coreutils/libexec/gnubin:/opt/homebrew/opt/coreutils/libexec/gnubin:${PATH}"
fi
# check files # check files
cd / cd /
l l
@@ -13,6 +19,7 @@ l
pwd pwd
test -f .zshrc2 test -f .zshrc2
diff -q ./.ssh/authorized_keys2 ~/.ssh/authorized_keys2 diff -q ./.ssh/authorized_keys2 ~/.ssh/authorized_keys2
diff -q ./.eid/authorized_certificates ~/.eid/authorized_certificates
grep -q ".zshrc2" ~/.zshrc grep -q ".zshrc2" ~/.zshrc
# check scripts and functions # check scripts and functions
@@ -31,6 +38,7 @@ 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 scp /tmp/ ./tmp -D 2>/dev/null)" = 'scp -P 12022 -o ControlMaster=auto -o ControlPath=/tmp/sshcm-%C -o PermitLocalCommand=yes -o ProxyJump=time@is.impt:2222,yes@you-r.right,you@are.really.recht.,ibd. -r try@it.ibd.ink:"/tmp/" "./tmp"'
# check alias # check alias
alias p114 alias p114

View File

@@ -1,4 +1,4 @@
#!/bin/bash #!/usr/bin/env bash
declare -A INSTALL_COMMANDS declare -A INSTALL_COMMANDS
INSTALL_COMMANDS=(\ INSTALL_COMMANDS=(\
@@ -11,6 +11,7 @@ INSTALL_COMMANDS=(\
[zerotier-one]='curl -s https://install.zerotier.com | sudo bash' \ [zerotier-one]='curl -s https://install.zerotier.com | sudo bash' \
[docker-ce]='curl -fsSL https://get.docker.com | sudo bash -s - --mirror Aliyun #--dry-run' \ [docker-ce]='curl -fsSL https://get.docker.com | sudo bash -s - --mirror Aliyun #--dry-run' \
[lemonbench]='curl -fsSL https://ilemonra.in/LemonBenchIntl | bash -s fast # or full' \ [lemonbench]='curl -fsSL https://ilemonra.in/LemonBenchIntl | bash -s fast # or full' \
[nix]='sh <(curl -L https://nixos.org/nix/install) #--daemon' \
) )
install() install()

View File

@@ -1,4 +1,4 @@
#!/bin/bash #!/usr/bin/env bash
set -e set -e
THIS_DIR=$( cd "$( dirname "${BASH_SOURCE[0]:-${(%):-%x}}" )" && pwd ) THIS_DIR=$( cd "$( dirname "${BASH_SOURCE[0]:-${(%):-%x}}" )" && pwd )
source "$THIS_DIR/common.sh" source "$THIS_DIR/common.sh"