[dev] refactor riot; improve tmux and vim; more plugins; more aliases (#43)

* riot: remove unknown domain warn

* install.sh: --no-ssh -> --no-auth-info

* doll: --restart=unless-stopped

* zshrc: alias cps and mvs

* riot: proxy -> ssh

* zshrc: not alias rm to trash

* (trial) riot devel: separate preset to config dir riot.d

* riot: support extra options and extra -o options

* (experimental) riot config in a single file

* riot config: add nasp remote and null domain

* gitconf: pull.ff = only

* fix ci

* riot: dynamic port forwarding

* riot: only one domain func will be exec

* to-install: update lemonbench

* to-install: alist

* [exp] riot inferred ssh: ping ping6

* sagt: fix nixos

* riot config: domain 42

* ubuntu.sh: DEBIAN_FRONTEND=noninteractive

* zshrc: ping -n

* zshrc: alias ping -n

* riot-config: jumpserver from sir0 to ssh.beardic.cn

* zshrc: alias ping before checking os type

* frigg: support api4.beardic.cn

* fix(install.sh): crontab fails on a new server

* fix(riot-conf): nasp.ob.ac.cn -> nasp.fit

* fix(install.sh): install crontab (exp)

* feat(test.zsh): test crontab

* fix(riot): secure control master

* fix(ci): riot control master

* fix(riot): not mkdir if dry-run

* feat(vimrc): set shiftwidth=4

* feat(ci): sync tmux-yank

* feat(tmux): set-clipboard on and mouse on (experimental)

* feat(zshrc): alias ping6

* build(ci): hub mirror 1.3->1.4

* fix(zshrc): tmux on msys; feat(common): better perf getting os type and linux dist

* fix(common.sh): get_os_type and get_linux_dist

* feat(zshrc): add plugin {magic-enter,per-directory-history,pip,podman,python,rsync,systemd,timer}

* feat(zshrc): journalctl alias

* feat(vimrc): tab=2 for c,cpp,nix,yaml

* build(ci): checkout v3 -> v4

---------

Co-authored-by: xiongdian.me <xiongdian.me@bytedance.com>
This commit is contained in:
Dict Xiong 2024-05-05 12:02:55 +08:00 committed by GitHub
parent 483f7fd7f3
commit 92aa5fa920
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
17 changed files with 180 additions and 76 deletions

View File

@ -9,6 +9,8 @@
quotepath = false # chinese chars quotepath = false # chinese chars
[push] [push]
autoSetupRemote = true autoSetupRemote = true
[pull]
ff = only
[branch] [branch]
# Show most recently changed branches first. # Show most recently changed branches first.
sort = -committerdate sort = -committerdate

View File

@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
steps: steps:
- name: DictXiong/dotfiles - name: DictXiong/dotfiles
uses: Yikun/hub-mirror-action@v1.3 uses: Yikun/hub-mirror-action@v1.4
with: with:
src: github/DictXiong src: github/DictXiong
dst: gitee/dictxiong dst: gitee/dictxiong

View File

@ -8,7 +8,7 @@ jobs:
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
steps: steps:
- name: ohmyzsh repo - name: ohmyzsh repo
uses: Yikun/hub-mirror-action@v1.3 uses: Yikun/hub-mirror-action@v1.4
with: with:
src: github/ohmyzsh src: github/ohmyzsh
dst: gitee/dictxiong dst: gitee/dictxiong
@ -25,7 +25,7 @@ jobs:
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.3 uses: Yikun/hub-mirror-action@v1.4
with: with:
src: github/zsh-users src: github/zsh-users
dst: gitee/dictxiong dst: gitee/dictxiong
@ -42,7 +42,7 @@ jobs:
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
steps: steps:
- name: zdharma-continuum repos - name: zdharma-continuum repos
uses: Yikun/hub-mirror-action@v1.3 uses: Yikun/hub-mirror-action@v1.4
with: with:
src: github/zdharma-continuum src: github/zdharma-continuum
dst: gitee/dictxiong dst: gitee/dictxiong
@ -59,7 +59,7 @@ jobs:
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.3 uses: Yikun/hub-mirror-action@v1.4
with: with:
src: github/thewtex src: github/thewtex
dst: gitee/dictxiong dst: gitee/dictxiong
@ -76,7 +76,7 @@ jobs:
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
steps: steps:
- name: tmux-plugins - name: tmux-plugins
uses: Yikun/hub-mirror-action@v1.3 uses: Yikun/hub-mirror-action@v1.4
with: with:
src: github/tmux-plugins src: github/tmux-plugins
dst: gitee/dictxiong dst: gitee/dictxiong
@ -87,13 +87,13 @@ jobs:
clone_style: "https" clone_style: "https"
debug: true debug: true
force_update: true force_update: true
static_list: "tpm,tmux-resurrect" static_list: "tpm,tmux-resurrect,tmux-yank"
timeout: '600s' 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.3 uses: Yikun/hub-mirror-action@v1.4
with: with:
src: github/VundleVim src: github/VundleVim
dst: gitee/dictxiong dst: gitee/dictxiong
@ -110,7 +110,7 @@ jobs:
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.3 uses: Yikun/hub-mirror-action@v1.4
with: with:
src: github/joshdick src: github/joshdick
dst: gitee/dictxiong dst: gitee/dictxiong
@ -127,7 +127,7 @@ jobs:
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
steps: steps:
- name: junegunn/fzf - name: junegunn/fzf
uses: Yikun/hub-mirror-action@v1.3 uses: Yikun/hub-mirror-action@v1.4
with: with:
src: github/junegunn src: github/junegunn
dst: gitee/dictxiong dst: gitee/dictxiong

View File

@ -8,7 +8,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: checkout repo - name: checkout repo
uses: actions/checkout@v3 uses: actions/checkout@v4
with: with:
fetch-depth: 0 fetch-depth: 0
@ -49,7 +49,7 @@ jobs:
runs-on: macos-12 runs-on: macos-12
steps: steps:
- name: checkout repo - name: checkout repo
uses: actions/checkout@v3 uses: actions/checkout@v4
with: with:
fetch-depth: 0 fetch-depth: 0
@ -94,7 +94,7 @@ jobs:
sudo apt-get -y remove curl vim python3 sudo apt-get -y remove curl vim python3
- name: checkout repo - name: checkout repo
uses: actions/checkout@v3 uses: actions/checkout@v4
with: with:
fetch-depth: 0 fetch-depth: 0
@ -116,7 +116,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: checkout repo - name: checkout repo
uses: actions/checkout@v3 uses: actions/checkout@v4
with: with:
fetch-depth: 0 fetch-depth: 0

View File

@ -1,5 +1,6 @@
set -g prefix ^a set -g prefix ^a
set -g mouse off set -g mouse on
set -g set-clipboard on
set -g default-terminal "xterm-256color" set -g default-terminal "xterm-256color"
set -g history-limit 10000 set -g history-limit 10000
@ -50,4 +51,4 @@ set -g window-style fg=colour248
set -g window-active-style fg=white set -g window-active-style fg=white
# better mouse scrolling. see: https://superuser.com/questions/1622812/mouse-scrolling-in-mobaxterm-tmux # better mouse scrolling. see: https://superuser.com/questions/1622812/mouse-scrolling-in-mobaxterm-tmux
set -g terminal-overrides 'xterm*:smcup@:rmcup@' set -g terminal-overrides 'xterm*:smcup@:rmcup@'

View File

@ -14,8 +14,9 @@ set cursorline
set syntax=on set syntax=on
set autoindent set autoindent
set smartindent set smartindent
set tabstop=4
set expandtab "spaces instead of tabs set expandtab "spaces instead of tabs
set tabstop=4 softtabstop=4 shiftwidth=4
autocmd FileType c,cpp,nix,yaml setlocal tabstop=2 softtabstop=2 shiftwidth=2
set backspace=indent,eol,start set backspace=indent,eol,start
set number "line numbers set number "line numbers
set history=1000 set history=1000

21
.zshrc2
View File

@ -16,6 +16,7 @@ export GPG_TTY=$(tty)
export LESS_TERMCAP_md=$'\E[01;33m' export LESS_TERMCAP_md=$'\E[01;33m'
# env for dfs # env for dfs
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
export DFS_OS_TYPE="$("$DOTFILES/tools/common.sh" get_os_type)"
# antigen # antigen
if [[ "$DFS_NO_WALL" == "1" ]]; then if [[ "$DFS_NO_WALL" == "1" ]]; then
@ -66,7 +67,15 @@ ANTIGEN_PLUGINS+=(
"extract" "extract"
"fzf" "fzf"
"git" "git"
"magic-enter"
"per-directory-history"
"pip"
"podman"
"python"
"ripgrep" "ripgrep"
"rsync"
"systemd"
"timer"
"tmux" "tmux"
"ufw" "ufw"
"z" "z"
@ -102,6 +111,10 @@ 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" == "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 2001:da8::666'
@ -110,9 +123,11 @@ 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))"'
alias "ls"='ls --color=tty' alias "ls"='ls --color=tty'
alias "l"='ls -lAGh --time-style="+%y-%m-%d %H:%M"' alias "l"='ls -lAGh --time-style="+%y-%m-%d %H:%M"'
if [[ -x $(command -v trash) ]]; then alias "jc"='journalctl'
alias "rm"="echo use the full path i.e. '/bin/rm'\; consider using trash" alias "jce"='jc -e'
fi alias "jceu"='jc -eu'
alias "jcf"='jc -f'
alias "jcfu"='jc -fu'
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 $@)" }

View File

@ -202,10 +202,11 @@ 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 if [[ -z "$(crontab -l 2>/dev/null || true)" ]]; then
echo -n | crontab - echo "$CRON_JOB" | crontab -
elif !( crontab -l | grep -qxF "${CRON_JOB}"); then
( crontab -l; echo "$CRON_JOB" ) | crontab -
fi fi
( 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 ..."
fi fi
@ -330,7 +331,7 @@ for i in ${GOT_OPTS[@]}; do
-a|--auto ) INSTALL_DEP=1 ;; -a|--auto ) INSTALL_DEP=1 ;;
-H|--hist|--history ) store_hist=1 ;; -H|--hist|--history ) store_hist=1 ;;
-x ) store_config=1 ;; -x ) store_config=1 ;;
--no-ssh ) unset HOME_SYMLINKS_SRC[0]; unset HOME_SYMLINKS_DST[0] ;; --no-auth-info ) HOME_SYMLINKS_SRC=(); HOME_SYMLINKS_DST=() ;;
* ) fmt_fatal "unknown option \"$i\"" ;; * ) fmt_fatal "unknown option \"$i\"" ;;
esac esac
done done

56
riot-config.sh Normal file
View File

@ -0,0 +1,56 @@
#!/bin/false
# remotes
j.remote() {
remote=ssh.beardic.cn
RET_PORT=${RET_PORT:-24022}
RET_USERNAME=${RET_USERNAME:-root}
RET_TRUST_SERVER=1
}
nasp.remote() {
remote=nasp.fit
RET_PORT=${RET_PORT:-36022}
RET_USERNAME=${RET_USERNAME:-ssh}
RET_TRUST_SERVER=1
}
# domains
.domain() {
RET_USERNAME=${RET_USERNAME:-root}
}
i.domain() {
RET_HOSTNAME=$host.ibd.ink
RET_PORT=${RET_PORT:-12022}
RET_USERNAME=${RET_USERNAME:-root}
RET_TRUST_SERVER=1
}
42.domain() {
RET_HOSTNAME=$host.i.bd.dn42
RET_PORT=${RET_PORT:-12022}
RET_USERNAME=${RET_USERNAME:-root}
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() {
RET_HOSTNAME=$host
RET_PORT=${RET_PORT:-12022}
RET_USERNAME=${RET_USERNAME:-dictxiong}
RET_JUMP_SERVER="ssh@nasp.fit:36022"
RET_TRUST_SERVER=1
}
default.domain() {
i.domain
}

View File

@ -21,5 +21,5 @@ if [[ -z "$IMAGE" ]]; then
fmt_fatal "image not found" fmt_fatal "image not found"
else else
fmt_note "--> ${IMAGE_META[@]}" fmt_note "--> ${IMAGE_META[@]}"
$SUDO docker run ${2:+"--name"} $2 -itd $IMAGE sh $SUDO docker run ${2:+"--name"} $2 -itd --restart=unless-stopped $IMAGE sh
fi fi

View File

@ -4,6 +4,19 @@ 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=""
# config
RIOT_CONFIG_FILES=(
"$DOTFILES/riot-config.sh"
"$HOME/.config/riot-config.sh"
"riot-config.sh"
)
for file in "${RIOT_CONFIG_FILES[@]}"; do
if [[ -f "$file" ]]; then
source "$file"
fi
done
# check if port number valid # check if port number valid
check_port() { check_port() {
@ -29,14 +42,6 @@ get_server_meta() {
RET_JUMP_SERVER="" # optional RET_JUMP_SERVER="" # optional
# body # body
local remote="$1" 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 in the form user@...
if [[ "$remote" == *@* ]]; then if [[ "$remote" == *@* ]]; then
RET_USERNAME=${remote%%@*} RET_USERNAME=${remote%%@*}
@ -49,46 +54,25 @@ get_server_meta() {
remote=${remote%:*} remote=${remote%:*}
check_port $RET_PORT || fmt_fatal invalid port number \"$RET_PORT\" check_port $RET_PORT || fmt_fatal invalid port number \"$RET_PORT\"
fi fi
# presets -- match remote
local remote_func="$remote.remote"
if is_function "$remote_func"; then
"$remote_func"
fi
# presets -- match domain # presets -- match domain
RET_HOSTNAME=${remote}
local domain=${remote##*.} local domain=${remote##*.}
local host=${remote%.*} local host=${remote%.*}
# if there's no dot # if there's no dot
if [[ "$host" == "$domain" && "$host" != "["*"]" ]]; then if [[ "$host" == "$domain" && "$host" != "["*"]" ]]; then
domain="ibd" domain="default"
fi
local domain_func="$domain.domain"
if is_function "$domain_func"; then
"$domain_func"
elif is_function ".domain"; then
".domain"
fi fi
case $domain in
i|ibd )
RET_HOSTNAME=$host.ibd.ink
RET_PORT=${RET_PORT:-12022}
RET_USERNAME=${RET_USERNAME:-root}
RET_TRUST_SERVER=1
;;
nasp )
RET_HOSTNAME=$host
RET_PORT=${RET_PORT:-12022}
RET_USERNAME=${RET_USERNAME:-dictxiong}
RET_JUMP_SERVER="ssh@nasp.ob.ac.cn:36022"
RET_TRUST_SERVER=1
;;
x|proxied )
RET_HOSTNAME=proxy.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
;;
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
;;
* )
test -z "$domain" || fmt_warning "unknown domain: \"$domain\". will try as host name"
RET_HOSTNAME="$remote"
esac
} }
parse_remote() { parse_remote() {
@ -101,7 +85,11 @@ parse_remote() {
USERNAME="" # optional USERNAME="" # optional
SSH_OPTIONS="" # optional SSH_OPTIONS="" # optional
if [[ "$RIOT_TRUST_CLIENT" == "1" ]]; then if [[ "$RIOT_TRUST_CLIENT" == "1" ]]; then
SSH_OPTIONS='-o ControlMaster=auto -o ControlPath=/tmp/sshcm-%C -o PermitLocalCommand=yes' SSH_OPTIONS='-o PermitLocalCommand=yes'
if [[ "$(get_os_type)" != "msys" ]]; then
test "$DFS_DRY_RUN" = "1" || mkdir -p ~/.ssh/master-socket
SSH_OPTIONS="$SSH_OPTIONS -o ControlMaster=auto -o ControlPath=~/.ssh/master-socket/%C"
fi
fi fi
# handle input # handle input
local remote="$1" local remote="$1"
@ -150,7 +138,7 @@ prepare_ssh_cmd() {
else else
local port_param='-p' local port_param='-p'
fi fi
echo "$ssh_bin ${PORT:+$port_param} $PORT $SSH_OPTIONS $SCP_SRC $USERNAME${USERNAME:+@}$SERVER $SCP_DST ${@:2}" echo "$ssh_bin ${PORT:+$port_param} $PORT $SSH_OPTIONS $RIOT_EXTRA_OPTIONS $SCP_SRC $USERNAME${USERNAME:+@}$SERVER $SCP_DST ${@:2}"
} }
# ssh # ssh
@ -178,6 +166,18 @@ run_sshl()
eval_or_echo $cmd eval_or_echo $cmd
} }
# sshd
run_sshd()
{
local port=$(get_free_port)
SSH_OPTIONS="$SSH_OPTIONS -NC -D $port"
local cmd="$(prepare_ssh_cmd ssh)"
fmt_note "-->" $cmd
fmt_note " > please access localhost:$port"
eval_or_echo $cmd
}
# scp # scp
run_scp() { run_scp() {
local src="$1" local src="$1"
@ -214,6 +214,15 @@ router() {
exit exit
fi fi
while [[ "$1" == -* ]]; do
RIOT_EXTRA_OPTIONS="$RIOT_EXTRA_OPTIONS $1"
if [[ "$1" == "-o" ]]; then
RIOT_EXTRA_OPTIONS="$RIOT_EXTRA_OPTIONS $2"
shift
fi
shift
done
IFS=',' read -ra remotes <<< "$1" IFS=',' read -ra remotes <<< "$1"
for remote in "${remotes[@]}"; do for remote in "${remotes[@]}"; do
if [[ -z "$remote" ]]; then if [[ -z "$remote" ]]; then
@ -224,6 +233,9 @@ router() {
ssh|"" ) ssh|"" )
run_ssh ssh "${@:3}" run_ssh ssh "${@:3}"
;; ;;
ping|ping6 )
run_ssh ssh "${@:2}"
;;
zssh ) zssh )
run_ssh zssh run_ssh zssh
;; ;;
@ -234,6 +246,9 @@ router() {
test -n "$3" || fmt_fatal "no target address provided" test -n "$3" || fmt_fatal "no target address provided"
run_sshl "$3" run_sshl "$3"
;; ;;
sshd )
run_sshd
;;
scp ) scp )
test -n "$3" || fmt_fatal "no source path specified" test -n "$3" || fmt_fatal "no source path specified"
test -n "$4" || fmt_fatal "no destination path specified" test -n "$4" || fmt_fatal "no destination path specified"

View File

@ -190,6 +190,7 @@ apost_beacon()
get_os_type() get_os_type()
{ {
test -z "$DFS_OS_TYPE" || { echo "$DFS_OS_TYPE"; return; }
local ans="unknown" local ans="unknown"
case "$(uname -s)" in case "$(uname -s)" in
Darwin*) ans="MacOS";; Darwin*) ans="MacOS";;
@ -198,11 +199,13 @@ get_os_type()
Linux* ) ans="Linux";; Linux* ) ans="Linux";;
*) ans="unknown";; *) ans="unknown";;
esac esac
export DFS_OS_TYPE="$ans"
echo $ans | tr '[:upper:]' '[:lower:]' echo $ans | tr '[:upper:]' '[:lower:]'
} }
get_linux_dist() get_linux_dist()
{ {
test -z "$DFS_LINUX_DIST" || { echo "$DFS_LINUX_DIST"; return; }
local ans="unknown" local ans="unknown"
if [ -f /etc/os-release ]; then if [ -f /etc/os-release ]; then
. /etc/os-release . /etc/os-release
@ -221,6 +224,7 @@ get_linux_dist()
else else
ans="unknown" ans="unknown"
fi fi
export DFS_LINUX_DIST="$ans"
echo $ans | tr '[:upper:]' '[:lower:]' echo $ans | tr '[:upper:]' '[:lower:]'
} }
@ -258,6 +262,10 @@ get_free_port() {
echo $port echo $port
} }
is_function() {
test "$(type -t "$1")" = "function"
}
# 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

@ -103,6 +103,7 @@ update_dns()
ip4="" ip4=""
elif [[ "$DFS_DDNS_IP4" == "auto" ]]; then elif [[ "$DFS_DDNS_IP4" == "auto" ]]; then
ip4="auto" ip4="auto"
api_url="https://api4.beardic.cn"
elif [[ "$DFS_DDNS_IP4" == "api" ]]; then elif [[ "$DFS_DDNS_IP4" == "api" ]]; then
ip4=$(curl $DFS_CURL_OPTIONS -sSL "https://api.ipify.org") ip4=$(curl $DFS_CURL_OPTIONS -sSL "https://api.ipify.org")
elif [[ "$DFS_DDNS_IP4" == "http"* ]]; then elif [[ "$DFS_DDNS_IP4" == "http"* ]]; then

View File

@ -25,7 +25,7 @@ find_so_file()
create_agent() create_agent()
{ {
local IFS="," local IFS=","
ssh-agent -P "${SO_PATHS[*]}" ssh-agent -P "${SO_PATHS[*]},/nix/store/*"
} }
kill_agent() kill_agent()

View File

@ -21,6 +21,9 @@ 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 diff -q ./.eid/authorized_certificates ~/.eid/authorized_certificates
grep -q ".zshrc2" ~/.zshrc grep -q ".zshrc2" ~/.zshrc
if [[ -x $(command -v crontab) ]]; then
crontab -l | grep -qxF "0 * * * * ${DOTFILES}/update.sh"
fi
# check scripts and functions # check scripts and functions
dfs version dfs version
@ -38,8 +41,8 @@ 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 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" 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.ibd.ink:"/tmp/" "./tmp"
scp -P 12022 -o ControlMaster=auto -o ControlPath=/tmp/sshcm-%C -o PermitLocalCommand=yes -o ForwardX11=yes -o ForwardAgent=yes -r another@host.ibd.ink:"/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.ibd.ink:"/tmp/" "./tmp"'
# check alias # check alias
alias p114 alias p114

View File

@ -10,8 +10,9 @@ INSTALL_COMMANDS=(\
[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" \
[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://raw.githubusercontent.com/LemonBench/LemonBench/main/LemonBench.sh | bash -s fast # or full' \
[nix]='sh <(curl -L https://nixos.org/nix/install) #--daemon' \ [nix]='sh <(curl -L https://nixos.org/nix/install) #--daemon' \
[alist]='curl -fsSL "https://alist.nn.ci/v3.sh" | bash -s install' \
) )
install() install()

View File

@ -14,11 +14,11 @@ apt_install()
{ {
apt-get update -y apt-get update -y
# lite # lite
apt-get install -y git zsh bash tmux vim curl inetutils-ping less bsdmainutils DEBIAN_FRONTEND=noninteractive apt-get install -y git zsh bash tmux vim curl iputils-ping less bsdmainutils
# full # full
if [[ -z "$DFS_LITE" || "$DFS_LITE" == "0" ]]; then if [[ -z "$DFS_LITE" || "$DFS_LITE" == "0" ]]; then
apt-get install -y wget dialog net-tools dnsutils netcat traceroute sudo python3 python3-pip cron openssh-client openssh-server htop gcc g++ cmake make zip DEBIAN_FRONTEND=noninteractive apt-get install -y wget dialog net-tools dnsutils netcat traceroute sudo python3 python3-pip cron openssh-client openssh-server htop gcc g++ cmake make zip
for i in {fzf,ripgrep,man-db}; do apt-get install -y $i; done for i in {fzf,ripgrep,man-db}; do DEBIAN_FRONTEND=noninteractive apt-get install -y $i; done
fi fi
} }