Files
git.taskfile.build/bin/create-env
T
Janik von Rotz fcc8d8078a feat(task): rename TASK_CONFIG_DIR to TASK_DOTENV_DIR and update related functions
- Replace all instances of `TASK_CONFIG_DIR` with `TASK_DOTENV_DIR` across environment-related scripts
- Update `init-config-dir` function name to `init-dotenv-dir` for consistency
- Adjust documentation and help table entries to reflect the renamed variable and function
- Maintain existing functionality and code style throughout affected scripts
2025-11-27 16:55:59 +01:00

46 lines
1.6 KiB
Bash
Executable File

#!/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
init-config-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=https://$1" > "$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=" > "$env_filepath"
echo "NEXTCLOUD_USERNAME=" >> "$env_filepath"
echo "NEXTCLOUD_PASSWORD=" >> "$env_filepath"
fi
if [[ "$2" == "upgrade" ]]; then
echo "HOST='$1'" > "$env_filepath"
echo "SERVER='ALIAS.mint-system.com'" >> "$env_filepath"
echo "PORT=22" >> "$env_filepath"
echo "" >> "$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_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"
}