diff --git a/start_docker.sh b/start_docker.sh index b251685..da40b48 100755 --- a/start_docker.sh +++ b/start_docker.sh @@ -18,6 +18,7 @@ Options: -c,--container CONT The name for the container -m,--mount MOUNT The name for the folder (outside the container) to create/mount to the home directory in the container. Mount folders are added here: $mount_prefix + --mount-existing Mount the specified dir even if it already exists --port : OR [:,...] Port mapping(s). May be specified multiple times. -h,--help Print this help message and exit @@ -32,6 +33,7 @@ declare docker_pass="" declare image_name="" declare cont_name="" declare mount_name="" +declare -i mount_existing=0 declare -a port_mappings=() while [[ $# -gt 0 ]]; do @@ -102,6 +104,10 @@ while [[ $# -gt 0 ]]; do mount_name="$2" shift 2 ;; + --mount-existing) + mount_existing=1 + shift 1 + ;; -h) ;& --help) @@ -153,9 +159,9 @@ repo_src=$(git rev-parse --show-superproject-working-tree) repo_tgt=$HOME/$(basename "$repo_src") working_dir=$HOME -if [[ -e $home_src ]]; then +if [[ $mount_existing -eq 0 && -e "$home_src" ]]; then # Don't overwrite existing dir (might be mounted in another container) - echo "Mount dir '$home_src' already exists" + echo "Mount dir '$home_src' already exists (use --mount-existing to mount an existing directory)" print_help_and_exit 1 fi