mirror of
https://github.com/DictXiong/dotfiles.git
synced 2024-11-24 16:27:02 +08:00
Dict Xiong
9a4c9556f6
* common.sh: export vars in env; zshrc: gdebug * fix error when locale not exists * DFS_COLOR * common.sh: parse args automatically * ci: test common.sh getopts * common.sh: argparser supports spaces * ciot: init * ciot -> diot; remove sibd, sob and snasp * rename diot -> riot * update home0 ssh pubkey; fix ci temperarily * gdebug will record time * gdebug supports empty; --dry-run wip * get.dotfiles.cn * bug fix (Thu Jan 5 20:53:58 CST 2023) * fix ci * fix ci * install.sh: -d will set -x * ci: -asl * getdfs: install for another user using -u <uname> * try fix when su doesnot exist * bug fix (Thu Jan 5 22:58:40 CST 2023) * bug fix (Thu Jan 5 22:59:33 CST 2023) * introduce SUDOE and so debug * ask_for_yn now use stdout to return * getdfs: support multiple users * install.sh: -x to set dfs config; ci * fix ci * bug fix (Fri Jan 6 15:11:24 CST 2023) * auto-detect DFS_NO_WALL * bug fix (Fri Jan 6 15:43:25 CST 2023) * getdfs: ${repo} * bug fix (Fri Jan 6 16:08:41 CST 2023) * getdfs: prompt user Co-authored-by: xiongdian.me <xiongdian.me@bytedance.com>
26 lines
680 B
Bash
Executable File
26 lines
680 B
Bash
Executable File
#!/bin/bash
|
|
|
|
THIS_DIR=$( cd "$( dirname "${BASH_SOURCE[0]:-${(%):-%x}}" )" && pwd )
|
|
source "$THIS_DIR/../tools/common.sh"
|
|
|
|
DOCKER_FORMAT="{{.ID}} {{.Repository}}:{{.Tag}}"
|
|
if [[ -z "$1" || "$1" =~ ^(-h|--help)$ ]]; then
|
|
fmt_info "usage: $0 <image> or -[0-9]*"
|
|
exit
|
|
elif [[ "$1" =~ ^-[0-9]*$ ]]; then
|
|
LAST="${1:1}"
|
|
# the last nth image
|
|
IMAGE_META=($($SUDO docker image ls --format "$DOCKER_FORMAT" | head -n ${LAST:-1} | tail -n 1))
|
|
IMAGE=${IMAGE_META[0]}
|
|
else
|
|
IMAGE_META="$1"
|
|
IMAGE="$1"
|
|
fi
|
|
|
|
if [[ -z "$IMAGE" ]]; then
|
|
fmt_fatal "image not found"
|
|
else
|
|
fmt_note "--> ${IMAGE_META[@]}"
|
|
$SUDO docker run ${2:+"--name"} $2 -itd $IMAGE sh
|
|
fi
|