#!/bin/bash function check_database_exists() { db-psql list | grep -q "$longname" } function check_port_used() { # shellcheck disable=SC2034 usedport=$(lxc exec "$container" -- bash -c "grep xmlrpc_port /etc/odoo15/$shortname.conf | cut -d' ' -f3") [[ "$usedport" == "$port" ]] } function check_service_running() { lxc exec "$container" -- bash -c "systemctl is-active --quiet ${longname}.service" } function _read() { disable_trace check_database_exists check_container "$container" check_port_used check_service_running enable_trace return 0 } function _create() { echo "creating templates ... " mkdir -p "$MIAOU_CONFIGDIR/apps/odoo15" longport=$((port + 1000)) APP_PORT=$port LONG_PORT=$longport APP_NAME=$shortname tera -e -t "$MIAOU_DIR/templates/apps/odoo15/odoo.conf.j2" -o "$MIAOU_CONFIGDIR/apps/odoo15/$shortname.conf" "$MIAOU_CONFIGDIR/miaou.expanded.yaml" >/dev/null APP_NAME=$shortname tera -t "$MIAOU_DIR/templates/apps/odoo15/odoo.service.j2" --env-only -o "$MIAOU_CONFIGDIR/apps/odoo15/$longname.service" >/dev/null echo "creating templates ... OK" echo "copying files over container <$container> ... " lxc file push --uid 0 --gid 0 "$MIAOU_CONFIGDIR/apps/odoo15/$shortname.conf" "$container/etc/odoo15/$shortname.conf" lxc file push --uid 0 --gid 0 "$MIAOU_CONFIGDIR/apps/odoo15/$longname.service" "$container/etc/systemd/system/$longname.service" echo "copying files over container <$container> ... OK" echo "create data folder for $shortname" cat < ... " db-psql create "$longname" echo "create empty database <$longname> ... OK" credential_username=$(load_yaml_from_expanded credential.username) credential_password=$(load_yaml_from_expanded credential.password) cat <