added bashly and awscli as docker based command lines via function/alias

trantor
David Kebler 2021-01-17 09:50:47 -08:00
parent 3fa17d2726
commit 470ba6f55c
3 changed files with 45 additions and 1 deletions

39
all/app/awscli Normal file
View File

@ -0,0 +1,39 @@
#!/bin/bash
command -v docker >/dev/null 2>&1 || exit
aws_docker () {
local cred
local profile
local profile_env
if [[ $1 == "--cred" ]]; then
cred=$2
shift 2
else
cred=${HOME}/.aws
fi
if [[ $1 == "--profile" ]]; then
profile=$2
shift 2
else
profile=${AWS_PROFILE}
fi
[[ ! $(cat $cred/config 2> /dev/null | grep ${profile}]) ]] && echo no profile ${profile} in $cred/config && return
[[ $profile ]] && profile_env="--env AWS_PROFILE=${profile}"
# echo credentials directory $cred
# echo using profile $profile
[[ ! -f $cred/credentials ]] && echo no credentails file at $cred/credentails && return
# echo remaining args: $@
docker run --rm -it -v ${cred}:/root/.aws --env AWS_PAGER="" ${profile_env} -v $(pwd):/aws amazon/aws-cli "$@"
}
aws_docker-update () {
docker pull amazon/aws-cli:latest
}
_alt_=$([[ $(command -v aws >/dev/null 2>&1) ]] || echo d)
alias aws${_alt_}='aws_docker'
alias aws${_alt_}-update='aws_docker_update'
unset _alt_

4
all/app/bashly Normal file
View File

@ -0,0 +1,4 @@
command -v docker >/dev/null 2>&1 || exit
alias bashly='docker run --rm -it --volume "$PWD:/app" dannyben/bashly'
alias bashly-update='docker pull dannyben/bashly:latest'

View File

@ -1,9 +1,10 @@
#!/bin/bash #!/bin/bash
# if docker loaded only
command -v docker >/dev/null 2>&1 || return command -v docker >/dev/null 2>&1 || return
#docker - add users to docker group to avoid needing sudo #docker - add users to docker group to avoid needing sudo
# run a command on a container # run a command on a container
# if [ $(which docker)]; then
alias dkcr="docker run" alias dkcr="docker run"
# start a container # start a container