Default aws cli directory for commands

This commit is contained in:
Arnie 2018-03-02 10:02:08 +01:00
parent ec252ee502
commit b4f509d90d
2 changed files with 35 additions and 15 deletions

5
aws-cli/.gitignore vendored Normal file
View File

@ -0,0 +1,5 @@
*
!.gitignore
!Dockerfile
!README.md
!run.sh

View File

@ -17,6 +17,12 @@ source ${SCRIPT_PATH}/../common.shinc
AWS_DEFAULT_REGION=eu-central-1 AWS_DEFAULT_REGION=eu-central-1
CUSTOM_ARGS="" CUSTOM_ARGS=""
# This directory will be mounted if no other directory is specified on the command line
DEFAULT_DIRECTORY=${SCRIPT_PATH}
# To enable the default directory mount point, override this setting to 1 in env.shinc
USE_DEFAULT_DIRECTORY=0
CURRENT_DATE="$(date +%Y-%m-%d)" CURRENT_DATE="$(date +%Y-%m-%d)"
platform=$(uname) platform=$(uname)
@ -52,17 +58,22 @@ init() {
cmd() { cmd() {
local localDir local localDir
__msg "Specify a mount point to /mnt/host inside the docker container"
read localDir if [[ ${USE_DEFAULT_DIRECTORY} -eq 1 ]]; then
localDir=${DEFAULT_DIRECTORY}
else
__msg "Specify a mount point to /mnt/host inside the docker container"
if [[ ${localDir} = "" ]]; then read localDir
localDir="$(pwd -P)"
__warn "You have not provided a directory, using current path: ${localDir}" if [[ ${localDir} = "" ]]; then
__msg "Continue? [(y)/n]" localDir="$(pwd -P)"
read CONTINUE __warn "You have not provided a directory, using default directory path: ${localDir}"
if [[ ${CONTINUE} != "" ]] && [[ ${CONTINUE} != "y" ]] && [[ ${CONTINUE} != "Y" ]]; then __msg "Continue? [(y)/n]"
return 0 read CONTINUE
if [[ ${CONTINUE} != "" ]] && [[ ${CONTINUE} != "y" ]] && [[ ${CONTINUE} != "Y" ]]; then
return 0
fi
fi fi
fi fi
@ -242,12 +253,16 @@ exec() {
local source_dir="$1" local source_dir="$1"
if [[ ${source_dir} = "" ]]; then if [[ ${source_dir} = "" ]]; then
source_dir=$(pwd -P) if [[ ${USE_DEFAULT_DIRECTORY} -eq 1 ]]; then
__warn "You have not provided a directory, using current path: ${source_dir}" source_dir=${DEFAULT_DIRECTORY}
__msg "Continue? [(y)/n]" else
read CONTINUE source_dir=$(pwd -P)
if [[ ${CONTINUE} != "" ]] && [[ ${CONTINUE} != "y" ]] && [[ ${CONTINUE} != "Y" ]]; then __warn "You have not provided a directory, using current path: ${source_dir}"
return 0 __msg "Continue? [(y)/n]"
read CONTINUE
if [[ ${CONTINUE} != "" ]] && [[ ${CONTINUE} != "y" ]] && [[ ${CONTINUE} != "Y" ]]; then
return 0
fi
fi fi
fi fi