50 lines
1.4 KiB
Bash
Executable File
50 lines
1.4 KiB
Bash
Executable File
#!/bin/bash
|
|
# Usage: initContainer <container_id> <software> [db_name]
|
|
#
|
|
# Creates /4server/data/<container_id>/config/container.env
|
|
#
|
|
# <container_id> : new codename (e.g. "banana")
|
|
# <software> : n8n | ODOO_17 | ODOO_18 | ODOO_19
|
|
# [db_name] : optional — postgres DB/user name to use.
|
|
# Defaults to <container_id>.
|
|
# Pass the OLD container_id here when migrating an existing container
|
|
# so the existing postgres database is reused.
|
|
#
|
|
# Examples:
|
|
# New container:
|
|
# initContainer banana ODOO_19
|
|
#
|
|
# Migrating existing container (old container_id kept as DB name):
|
|
# initContainer banana ODOO_19 005-003-91f3922c-8cc2-4950-aa57-808775c341ff
|
|
|
|
CONTAINER_ID="$1"
|
|
SOFTWARE="$2"
|
|
DB_NAME="${3:-$1}"
|
|
|
|
if [[ -z "$CONTAINER_ID" || -z "$SOFTWARE" ]]; then
|
|
echo "Usage: $0 <container_id> <software> [db_name]"
|
|
echo " software: n8n | ODOO_17 | ODOO_18 | ODOO_19"
|
|
exit 1
|
|
fi
|
|
|
|
case "$SOFTWARE" in
|
|
n8n|ODOO_17|ODOO_18|ODOO_19) ;;
|
|
*)
|
|
echo "ERROR: Unknown software type: $SOFTWARE"
|
|
echo " Valid values: n8n | ODOO_17 | ODOO_18 | ODOO_19"
|
|
exit 1
|
|
;;
|
|
esac
|
|
|
|
CONFIG_DIR="/4server/data/$CONTAINER_ID/config"
|
|
mkdir -p "$CONFIG_DIR"
|
|
|
|
cat > "$CONFIG_DIR/container.env" <<EOF
|
|
SOFTWARE=$SOFTWARE
|
|
DB_NAME=$DB_NAME
|
|
EOF
|
|
|
|
echo "Created $CONFIG_DIR/container.env"
|
|
echo " SOFTWARE=$SOFTWARE"
|
|
echo " DB_NAME=$DB_NAME"
|