mirror of
https://github.com/DictXiong/dotfiles.git
synced 2024-11-24 18:17:01 +08:00
Compare commits
3 Commits
3223ca53fa
...
2fa248fdb0
Author | SHA1 | Date | |
---|---|---|---|
|
2fa248fdb0 | ||
|
76af9fa434 | ||
|
fbb4a6ff76 |
3
.zshrc2
3
.zshrc2
|
@ -112,9 +112,6 @@ 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 "rm"="echo use the full path i.e. '/bin/rm'\; consider using trash"
|
|
||||||
fi
|
|
||||||
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 $@)" }
|
||||||
|
|
||||||
|
|
69
scripts/riot
69
scripts/riot
|
@ -4,6 +4,8 @@ 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_CONFIG_DIR="$THIS_DIR/riot.d"
|
||||||
|
RIOT_EXTRA_OPTIONS=""
|
||||||
|
|
||||||
# check if port number valid
|
# check if port number valid
|
||||||
check_port() {
|
check_port() {
|
||||||
|
@ -29,14 +31,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,45 +43,27 @@ 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_config="$RIOT_CONFIG_DIR/$remote.remote"
|
||||||
|
if [[ -f "$remote_config" ]]; then
|
||||||
|
source "$remote_config"
|
||||||
|
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 root_domain_config="$RIOT_CONFIG_DIR/.domain"
|
||||||
|
if [[ -f "$root_domain_config" ]]; then
|
||||||
|
source "$root_domain_config"
|
||||||
|
fi
|
||||||
|
local domain_config="$RIOT_CONFIG_DIR/$domain.domain"
|
||||||
|
if [[ -n "$$domain" && -f "$domain_config" ]]; then
|
||||||
|
source "$domain_config"
|
||||||
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|ssh )
|
|
||||||
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
|
|
||||||
;;
|
|
||||||
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
|
|
||||||
;;
|
|
||||||
* )
|
|
||||||
RET_HOSTNAME="$remote"
|
|
||||||
esac
|
|
||||||
}
|
}
|
||||||
|
|
||||||
parse_remote() {
|
parse_remote() {
|
||||||
|
@ -149,7 +125,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
|
||||||
|
@ -213,6 +189,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
|
||||||
|
|
1
scripts/riot.d/default.domain
Symbolic link
1
scripts/riot.d/default.domain
Symbolic link
|
@ -0,0 +1 @@
|
||||||
|
./i.domain
|
4
scripts/riot.d/i.domain
Normal file
4
scripts/riot.d/i.domain
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
RET_HOSTNAME=$host.ibd.ink
|
||||||
|
RET_PORT=${RET_PORT:-12022}
|
||||||
|
RET_USERNAME=${RET_USERNAME:-root}
|
||||||
|
RET_TRUST_SERVER=1
|
4
scripts/riot.d/j.remote
Normal file
4
scripts/riot.d/j.remote
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
remote=sir0.ibd.ink
|
||||||
|
RET_PORT=${RET_PORT:-36122}
|
||||||
|
RET_USERNAME=${RET_USERNAME:-root}
|
||||||
|
RET_TRUST_SERVER=1
|
5
scripts/riot.d/nasp.domain
Normal file
5
scripts/riot.d/nasp.domain
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
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
|
6
scripts/riot.d/x.domain
Normal file
6
scripts/riot.d/x.domain
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
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
|
Loading…
Reference in New Issue
Block a user