mirror of
https://github.com/DictXiong/dotfiles.git
synced 2024-11-24 10:57:02 +08:00
WIP: piv fix (#28)
* piv logi fix * dogo: $DFS * snasp; doll: $2 for the name * DFS_UPDATE_CHANNEL? * git-branches * ci: git-branches Co-authored-by: xiongdian.me <xiongdian.me@bytedance.com>
This commit is contained in:
parent
3ce5a7ade8
commit
c354f980bb
26
.update.sh
26
.update.sh
|
@ -3,15 +3,10 @@
|
||||||
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}")
|
||||||
source "$THIS_DIR/tools/common.sh"
|
source "$THIS_DIR/tools/common.sh"
|
||||||
DFS_ENABLE_RET=${DFS_ENABLE_RET:-0}
|
|
||||||
|
|
||||||
# get the specified commit id
|
DFS_UPDATED_RET=${DFS_UPDATED_RET:-0}
|
||||||
DFS_COMMIT=$(curl -fsSL https://api.beardic.cn/get-var/dfs-commit-id)
|
DFS_UPDATE_CHANNEL=${DFS_UPDATE_CHANNEL:-"main"}
|
||||||
if [[ ${#DFS_COMMIT} != 40 ]]; then
|
|
||||||
fmt_error "invalid commit id"
|
|
||||||
post_log "ERROR" "$THIS_FILE" "invalid commit id: ${DFS_COMMIT}"
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
# fetch origin
|
# fetch origin
|
||||||
cd $DOTFILES
|
cd $DOTFILES
|
||||||
git fetch --all
|
git fetch --all
|
||||||
|
@ -20,6 +15,19 @@ if [[ -n "$(git status -s)" ]]; then
|
||||||
post_log "ERROR" "$THIS_FILE" "directory not clean"
|
post_log "ERROR" "$THIS_FILE" "directory not clean"
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# get the specified commit id
|
||||||
|
case $DFS_UPDATE_CHANNEL in
|
||||||
|
"main" ) DFS_COMMIT=$(curl -fsSL https://api.beardic.cn/get-var/dfs-commit-id) ;;
|
||||||
|
"latest" ) DFS_COMMIT=$(git for-each-ref --sort=-committerdate refs/heads refs/remotes --format='%(objectname)' | head -n 1) ;;
|
||||||
|
* ) fmt_fatal "invalid update channel: $DFS_UPDATE_CHANNEL" ;;
|
||||||
|
esac
|
||||||
|
if [[ ${#DFS_COMMIT} != 40 ]]; then
|
||||||
|
fmt_error "invalid commit id"
|
||||||
|
post_log "ERROR" "$THIS_FILE" "invalid commit id: ${DFS_COMMIT}"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
# update
|
# update
|
||||||
if [[ "$(git rev-parse HEAD)" == "$DFS_COMMIT" ]]; then
|
if [[ "$(git rev-parse HEAD)" == "$DFS_COMMIT" ]]; then
|
||||||
fmt_info "nothing to do"
|
fmt_info "nothing to do"
|
||||||
|
@ -29,7 +37,7 @@ else
|
||||||
if [[ -z "$DFS_DEV" ]]; then
|
if [[ -z "$DFS_DEV" ]]; then
|
||||||
post_log "INFO" "$THIS_FILE" "will check out to commit $DFS_COMMIT"
|
post_log "INFO" "$THIS_FILE" "will check out to commit $DFS_COMMIT"
|
||||||
git -c advice.detachedHead=false checkout $DFS_COMMIT
|
git -c advice.detachedHead=false checkout $DFS_COMMIT
|
||||||
cp ./.update.sh ./update.sh && chmod +x ./update.sh && exit $DFS_ENABLE_RET
|
cp ./.update.sh ./update.sh && chmod +x ./update.sh && exit $DFS_UPDATED_RET
|
||||||
else
|
else
|
||||||
fmt_warning "won't really checkout in dev mode"
|
fmt_warning "won't really checkout in dev mode"
|
||||||
fi
|
fi
|
||||||
|
|
6
.zshrc2
6
.zshrc2
|
@ -88,23 +88,27 @@ alias "se"='sudo -sE'
|
||||||
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 "git-branches"='git for-each-ref --sort=-committerdate refs/heads refs/remotes --format="%(authordate:short) %(color:red)%(objectname:short) %(color:yellow)%(refname:short)%(color:reset) (%(color:green)%(committerdate:relative)%(color:reset)) %(authorname)"'
|
||||||
sibd() { ssh -p 12022 root@$1${1:+.}ibd.ink }
|
sibd() { ssh -p 12022 root@$1${1:+.}ibd.ink }
|
||||||
sob() { ssh -p 24022 root@$1${1:+.}ob.ac.cn }
|
sob() { ssh -p 24022 root@$1${1:+.}ob.ac.cn }
|
||||||
|
snasp() { ssh -o ProxyJump="ssh@nasp.ob.ac.cn:36022" dictxiong@$1 }
|
||||||
case $(bash "$DOTFILES/tools/common.sh" get_os_type) in
|
case $(bash "$DOTFILES/tools/common.sh" get_os_type) in
|
||||||
macos ) alias l='ls -lAGh -D "%y-%m-%d %H:%M"' ;;
|
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
|
esac
|
||||||
piv-agent()
|
piv-agent()
|
||||||
{
|
{
|
||||||
|
eval $(ssh-agent -k)
|
||||||
# they are: ubuntu, macos, respectively
|
# they are: ubuntu, macos, respectively
|
||||||
local SO_PATHS=( "/usr/lib64/opensc-pkcs11.so" "/usr/local/lib/opensc-pkcs11.so" )
|
local SO_PATHS=( "/usr/lib64/opensc-pkcs11.so" "/usr/local/lib/opensc-pkcs11.so" )
|
||||||
for i in ${SO_PATHS[*]}; do
|
for i in ${SO_PATHS[*]}; do
|
||||||
if [[ -f "$i" ]]; then
|
if [[ -f "$i" ]]; then
|
||||||
|
echo "using: $i"
|
||||||
eval $(ssh-agent -P "$i")
|
eval $(ssh-agent -P "$i")
|
||||||
ssh-add -s "$i"
|
ssh-add -s "$i"
|
||||||
echo "now available keys:"
|
echo "now available keys:"
|
||||||
ssh-add -l
|
ssh-add -l
|
||||||
break
|
return 0
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
echo "opensc-pkcs11.so not found"
|
echo "opensc-pkcs11.so not found"
|
||||||
|
|
|
@ -219,7 +219,7 @@ install_update(){
|
||||||
cp "${DOTFILES}/.update.sh" "${DOTFILES}/update.sh"
|
cp "${DOTFILES}/.update.sh" "${DOTFILES}/update.sh"
|
||||||
chmod +x "${DOTFILES}/update.sh"
|
chmod +x "${DOTFILES}/update.sh"
|
||||||
fmt_note "running update.sh ..."
|
fmt_note "running update.sh ..."
|
||||||
DFS_ENABLE_RET=1 ${DOTFILES}/update.sh
|
DFS_UPDATED_RET=1 ${DOTFILES}/update.sh
|
||||||
if [[ $? == 1 ]]; then
|
if [[ $? == 1 ]]; then
|
||||||
fmt_note "dfs updated. re-running install.sh ..."
|
fmt_note "dfs updated. re-running install.sh ..."
|
||||||
"${DOTFILES}/install.sh" && exit
|
"${DOTFILES}/install.sh" && exit
|
||||||
|
|
|
@ -26,5 +26,5 @@ if [[ -z "$CONTAINER" ]]; then
|
||||||
fmt_fatal "container not found"
|
fmt_fatal "container not found"
|
||||||
else
|
else
|
||||||
echo "--> ${CONTAINER_META[@]}"
|
echo "--> ${CONTAINER_META[@]}"
|
||||||
$SUDO docker exec -it $CONTAINER sh -c 'if [ -x "$(command -v zsh)" ]; then echo "--> zsh"; 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
|
||||||
|
|
|
@ -21,5 +21,5 @@ if [[ -z "$IMAGE" ]]; then
|
||||||
fmt_fatal "image not found"
|
fmt_fatal "image not found"
|
||||||
else
|
else
|
||||||
echo "--> ${IMAGE_META[@]}"
|
echo "--> ${IMAGE_META[@]}"
|
||||||
$SUDO docker run -itd $IMAGE sh
|
$SUDO docker run ${2:+"--name"} $2 -itd $IMAGE sh
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -29,6 +29,7 @@ tools/common.sh get_linux_dist
|
||||||
alias p114
|
alias p114
|
||||||
sibd || which sibd
|
sibd || which sibd
|
||||||
piv-agent || which piv-agent
|
piv-agent || which piv-agent
|
||||||
|
git-branches || which git-branches
|
||||||
|
|
||||||
# check update
|
# check update
|
||||||
DFS_VERSION=`dfs version`
|
DFS_VERSION=`dfs version`
|
||||||
|
|
Loading…
Reference in New Issue
Block a user