dogo/doll

dogo supports zsh/bash/sh; doll is introduced to launch a new docker
container; update $SUDO in command.sh
This commit is contained in:
Dict Xiong 2022-11-13 01:10:55 +08:00
parent 995899f3a3
commit 6937ba8447
3 changed files with 13 additions and 3 deletions

View File

@ -4,7 +4,7 @@ THIS_DIR=$( cd "$( dirname "${BASH_SOURCE[0]:-${(%):-%x}}" )" && pwd )
source "$THIS_DIR/../tools/common.sh"
if [[ -z "$1" || "$1" =~ "-h|--help" ]]; then
fmt_info "usage: dogo <container>"
fmt_info "usage: $0 <container>"
else
$SUDO docker exec -it $1 zsh
$SUDO docker exec -it $1 sh -c 'if [ -x "$(command -v zsh)" ]; then zsh; elif [ -x "$(command -v bash)" ]; then echo "-->bash"; bash; else echo "-->sh"; sh; fi'
fi

10
scripts/doll Executable file
View File

@ -0,0 +1,10 @@
#!/bin/bash
THIS_DIR=$( cd "$( dirname "${BASH_SOURCE[0]:-${(%):-%x}}" )" && pwd )
source "$THIS_DIR/../tools/common.sh"
if [[ -z "$1" || "$1" =~ "-h|--help" ]]; then
fmt_info "usage: $0 <image>"
else
$SUDO docker run -itd $1 sh
fi

View File

@ -4,7 +4,7 @@ THIS_DIR_COMMON_SH=$( cd "$( dirname "${BASH_SOURCE[0]:-${(%):-%x}}" )" && pwd )
export DOTFILES=$( cd "$THIS_DIR_COMMON_SH/.." && pwd )
SUDO=''
if (( $EUID != 0 )); then
if [[ "$EUID" != "0" && -x $(command -v sudo) ]]; then
SUDO='sudo'
fi