#!/bin/bash # check that our repository path is correct [ -e "${VDM_REPO_PATH}" ] || { echo "[error] Repository path (${VDM_REPO_PATH}) does not exist." exit 1 } # check that our projects path is correct [ -e "${VDM_PROJECT_PATH}" ] || { echo "[error] Projects path (${VDM_PROJECT_PATH}) does not exist." exit 1 } # be sure to create the container type path # shellcheck disable=SC2174 mkdir -p -m 700 "${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}" # be sure to .ssh path exist # shellcheck disable=SC2174 mkdir -p -m 700 "${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/.ssh" # check if we have global env file # shellcheck disable=SC1090 # shellcheck disable=SC2015 [ -f "${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/.env" ] && source "${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/.env" || { touch "${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/.env" chmod 600 "${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/.env" } # help message ʕ•ᴥ•ʔ function show_help() { cat < set username of the container example: ${0##*/:-} -u="ubuntu" example: ${0##*/:-} --username="ubuntu" ====================================================== --uid set container user id example: ${0##*/:-} --uid=1000 ====================================================== --gid set container user group id example: ${0##*/:-} --gid=1000 ====================================================== -p|--port set ssh port to use !! do not use 22 !! example: ${0##*/:-} -p=2239 example: ${0##*/:-} --port=2239 ====================================================== --ssh-dir set ssh directory name found in the .ssh dir of this repo for the container keys This directory has separate files for each public key allowed to access the container example: ${0##*/:-} --ssh-dir="teamname" ====================================================== --sudo switch to add the container user to the sudo group of the container example: ${0##*/:-} --sudo ====================================================== -k|--key set key for the docker compose container naming !! no spaces allowed in the key !! example: ${0##*/:-} -k="vdm" example: ${0##*/:-} --key="vdm" ====================================================== -e|--env-key set key for the environment variable naming !! no spaces allowed in the key & must be UPPERCASE !! example: ${0##*/:-} -e="VDM" example: ${0##*/:-} --env-key="VDM" ====================================================== -d|--domain set key website domain !! must be domain.tld !! example: ${0##*/:-} -d="vdm.dev" example: ${0##*/:-} --domain="vdm.dev" ====================================================== -t|--time-zone