diff --git a/README.md b/README.md index c71e28d..8546baa 100644 --- a/README.md +++ b/README.md @@ -16,8 +16,7 @@ ansible-pull \ * Launches a new LXD container called **newodoocontainer**, that uses a LXD profile to download and setup Odoo v14. * Creates a DNS alias for **externo.agofer.net** or **externo2.agofer.net** - (see role variables in `local.yml` file), called - **.agofer.net**. + (see role variables in `local.yml` file), called **_newodoocontainer_.agofer.net**. * Registers this container in the existing Nginx Proxy container. * Requests an SSL certificate to _Let's Encrypt_ for the new domain, storing the certificates in the Nginx Proxy container. diff --git a/launch-odoo14-container.sh b/launch-odoo14-container.sh new file mode 100644 index 0000000..c5c3f27 --- /dev/null +++ b/launch-odoo14-container.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env bash +#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# Uses ansible-pull from a Python venv to create a LXD container +#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +usage () +{ + echo "Uses ansible-pull from a Python venv to create a LXD container" + echo " Usage: $1 " +} + +is_in () { + [[ $2 =~ (^|[[:space:]])$1($|[[:space:]]) ]] && return 1 || return 0 +} + +CONTAINER="$1" + +# Need a container name: +if [ -z "$CONTAINER" ]; then + usage "$0" + exit 1 +fi + +# Container cannot exist already: +ALLCONTAINERS=$(lxc ls -c n --format csv) + +is_in "$CONTAINER" "${ALLCONTAINERS}" +container_exists=$? + +if [[ ${container_exists} -eq 0 ]]; then + printf 'ERROR: %s\n' "A container with that name exists already" >&2 + exit 2 +fi + +echo "Would have launched container" +