mirror of
https://github.com/DictXiong/dotfiles.git
synced 2025-04-24 21:46:52 +08:00
ciot -> diot; remove sibd, sob and snasp
This commit is contained in:
parent
bb8404c6b6
commit
957bcbc0e5
3
.zshrc2
3
.zshrc2
|
@ -108,9 +108,6 @@ 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
|
||||||
sibd() { ssh -p 12022 root@$1${1:+.}ibd.ink }
|
|
||||||
sob() { ssh -p 24022 root@$1${1:+.}ob.ac.cn }
|
|
||||||
snasp() { ssh -o ProxyJump="ssh@nasp.ob.ac.cn:36022" dictxiong@$1 }
|
|
||||||
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 }
|
||||||
piv-agent()
|
piv-agent()
|
||||||
{
|
{
|
||||||
|
|
46
scripts/ciot
46
scripts/ciot
|
@ -1,46 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
# connect to iot services
|
|
||||||
THIS_DIR=$( cd "$( dirname "${BASH_SOURCE[0]:-${(%):-%x}}" )" && pwd )
|
|
||||||
source "$THIS_DIR/../tools/common.sh"
|
|
||||||
|
|
||||||
# proxy server and port
|
|
||||||
SERVER=${SERVER:-bj1.ob.ac.cn}
|
|
||||||
get_server_port()
|
|
||||||
{
|
|
||||||
local tmp
|
|
||||||
tmp=$(sha256sum <<< "$1" | tr -cd "[:digit:]")
|
|
||||||
tmp=${tmp:0:4}
|
|
||||||
echo $((tmp+36000))
|
|
||||||
}
|
|
||||||
|
|
||||||
# ssh
|
|
||||||
SSH_USERNAME=${SSH_USERNAME:-root}
|
|
||||||
_ssh()
|
|
||||||
{
|
|
||||||
ssh -p $(get_server_port "$1") "$SSH_USERNAME@$SERVER"
|
|
||||||
}
|
|
||||||
|
|
||||||
# main
|
|
||||||
print_help()
|
|
||||||
{
|
|
||||||
fmt_info "usage: $0 <command> <service> [options]"
|
|
||||||
echo "available commands: ssh"
|
|
||||||
}
|
|
||||||
|
|
||||||
router()
|
|
||||||
{
|
|
||||||
case $1 in
|
|
||||||
-h|--help)
|
|
||||||
print_help
|
|
||||||
;;
|
|
||||||
ssh )
|
|
||||||
_ssh "$2"
|
|
||||||
;;
|
|
||||||
* )
|
|
||||||
print_help
|
|
||||||
fmt_fatal "unknown command: $1"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
}
|
|
||||||
|
|
||||||
router "${GOT_OPTS[@]}"
|
|
80
scripts/diot
Executable file
80
scripts/diot
Executable file
|
@ -0,0 +1,80 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# connect to iot services
|
||||||
|
THIS_DIR=$( cd "$( dirname "${BASH_SOURCE[0]:-${(%):-%x}}" )" && pwd )
|
||||||
|
source "$THIS_DIR/../tools/common.sh"
|
||||||
|
|
||||||
|
# get target settings
|
||||||
|
# provides:
|
||||||
|
SERVER=""
|
||||||
|
PORT=""
|
||||||
|
SSH_USERNAME=""
|
||||||
|
SSH_OPTIONS=""
|
||||||
|
get_server_meta()
|
||||||
|
{
|
||||||
|
local domain=${1##*.}
|
||||||
|
local host=${1%.*}
|
||||||
|
if [[ "$host" == "$domain" ]]; then
|
||||||
|
domain=""
|
||||||
|
fi
|
||||||
|
case $domain in
|
||||||
|
ibd )
|
||||||
|
SERVER=$host.ibd.ink
|
||||||
|
PORT=12022
|
||||||
|
SSH_USERNAME=root
|
||||||
|
;;
|
||||||
|
ob )
|
||||||
|
SERVER=$host.ob.ac.cn
|
||||||
|
PORT=24022
|
||||||
|
SSH_USERNAME=root
|
||||||
|
;;
|
||||||
|
nasp )
|
||||||
|
SERVER=$host
|
||||||
|
PORT=22
|
||||||
|
SSH_USERNAME=dictxiong
|
||||||
|
SSH_OPTIONS='-o ProxyJump="ssh@nasp.ob.ac.cn:36022"'
|
||||||
|
;;
|
||||||
|
"" )
|
||||||
|
SERVER=bj1.ob.ac.cn
|
||||||
|
local tmp=$(sha256sum <<< "$host" | tr -cd "[:digit:]")
|
||||||
|
tmp=${tmp:0:4}
|
||||||
|
PORT=$((tmp+36000))
|
||||||
|
SSH_USERNAME=root
|
||||||
|
;;
|
||||||
|
* )
|
||||||
|
fmt_fatal "unknown domain: $domain"
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
# ssh
|
||||||
|
_ssh()
|
||||||
|
{
|
||||||
|
get_server_meta "$1"
|
||||||
|
fmt_note "--> ssh to $SERVER:$PORT"
|
||||||
|
eval ssh -p $PORT $SSH_OPTIONS $SSH_USERNAME@$SERVER
|
||||||
|
}
|
||||||
|
|
||||||
|
# main
|
||||||
|
print_help()
|
||||||
|
{
|
||||||
|
fmt_info "usage: $0 <command> <service> [options]"
|
||||||
|
echo "available commands: ssh"
|
||||||
|
}
|
||||||
|
|
||||||
|
router()
|
||||||
|
{
|
||||||
|
test $# -eq 2 || (print_help && fmt_fatal "invalid arguments")
|
||||||
|
case $1 in
|
||||||
|
-h|--help)
|
||||||
|
print_help
|
||||||
|
;;
|
||||||
|
ssh )
|
||||||
|
_ssh "$2"
|
||||||
|
;;
|
||||||
|
* )
|
||||||
|
print_help
|
||||||
|
fmt_fatal "unknown command: $1"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
router "${GOT_OPTS[@]}"
|
|
@ -25,6 +25,6 @@ fi
|
||||||
if [[ -z "$CONTAINER" ]]; then
|
if [[ -z "$CONTAINER" ]]; then
|
||||||
fmt_fatal "container not found"
|
fmt_fatal "container not found"
|
||||||
else
|
else
|
||||||
echo "--> ${CONTAINER_META[@]}"
|
fmt_note "--> ${CONTAINER_META[@]}"
|
||||||
$SUDO docker exec -it $CONTAINER sh -c 'export DFS="bash <(curl dfs.beardic.cn) -a"; if [ -x "$(command -v zsh)" ]; then echo "--> zsh"; unset DFS; zsh; elif [ -x "$(command -v bash)" ]; then echo "--> bash"; bash; else echo "--> sh"; sh; fi'
|
$SUDO docker exec -it $CONTAINER sh -c 'export DFS="bash <(curl dfs.beardic.cn) -a"; if [ -x "$(command -v zsh)" ]; then echo "--> zsh"; unset DFS; zsh; elif [ -x "$(command -v bash)" ]; then echo "--> bash"; bash; else echo "--> sh"; sh; fi'
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -20,6 +20,6 @@ fi
|
||||||
if [[ -z "$IMAGE" ]]; then
|
if [[ -z "$IMAGE" ]]; then
|
||||||
fmt_fatal "image not found"
|
fmt_fatal "image not found"
|
||||||
else
|
else
|
||||||
echo "--> ${IMAGE_META[@]}"
|
fmt_note "--> ${IMAGE_META[@]}"
|
||||||
$SUDO docker run ${2:+"--name"} $2 -itd $IMAGE sh
|
$SUDO docker run ${2:+"--name"} $2 -itd $IMAGE sh
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in New Issue
Block a user