- Replace `create-odoo-env` and `create-nextcloud-env` with unified `create-env` function - Support multiple environment types: odoo, nextcloud, and upgrade - Update `list-env` to detect and display new environment types - Adjust documentation and help table entries to reflect consolidated command - Maintain existing code style and error handling patterns
46 lines
1.6 KiB
Bash
Executable File
46 lines
1.6 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
create-odoo-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_CONFIG_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"
|
|
} |