#!/usr/bin/env bash create-env() { if [[ -z "$1" ]]; then echo "\$1 is empty."; exit; fi if [[ -z "$2" ]]; then echo "\$1 is empty."; exit; fi TASK_DOTENV_DIR=${TASK_DOTENV_DIR:="$HOME/.config/taskfile.build"} init-dotenv-dir local env_filepath="$TASK_DOTENV_DIR/.env.$1" if [[ -f "$env_filepath" ]]; then echo "Env file already exists: $env_filepath" exit 1 fi echo "Init env file: $env_filepath" if [[ "$2" == "odoo" ]]; then echo "ODOO_URL=$ODOO_URL" > "$env_filepath" echo "ODOO_DATABASE=$ODOO_DATABASE" >> "$env_filepath" echo "ODOO_USERNAME=$ODOO_USERNAME" >> "$env_filepath" echo "ODOO_PASSWORD=$ODOO_PASSWORD" >> "$env_filepath" fi if [[ "$2" == "nextcloud" ]]; then echo "NEXTCLOUD_URL=$NEXTCLOUD_URL" > "$env_filepath" echo "NEXTCLOUD_USERNAME=$NEXTCLOUD_USERNAME" >> "$env_filepath" echo "NEXTCLOUD_PASSWORD=#NEXTCLOUD_PASSWORD" >> "$env_filepath" fi if [[ "$2" == "upgrade" ]]; then echo "HOST='odoo.example.com'" > "$env_filepath" echo "SERVER='ALIAS.mint-system.com'" >> "$env_filepath" echo "PORT=22" >> "$env_filepath" echo "ODOO_CONTAINER='odoo01'" >> "$env_filepath" echo "ODOO_VERSION='16.0'" >> "$env_filepath" echo "POSTGRES_CONTAINER='postgres01'" >> "$env_filepath" echo "DATABASE='odoo'" >> "$env_filepath" echo "" >> "$env_filepath" echo "TARGET_HOST='upgrade.odoo.example.com'" >> "$env_filepath" echo "TARGET_SERVER='ALIAS.mint-system.com'" >> "$env_filepath" echo "TARGET_PORT=22" >> "$env_filepath" echo "TARGET_ODOO_CONTAINER='odoo02'" >> "$env_filepath" echo "TARGET_ODOO_VERSION='18.0'" >> "$env_filepath" echo "TARGET_POSTGRES_CONTAINER='postgres02'" >> "$env_filepath" echo "TARGET_DATABASE='upgrade'" >> "$env_filepath" fi echo "Edit with: task edit-env $1" }