#!/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/odoo12/$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/odoo12" longport=$((port + 1000)) APP_PORT=$port LONG_PORT=$longport APP_NAME=$shortname tera -e -t "$MIAOU_BASEDIR/templates/apps/odoo12/odoo.conf.j2" -o "$MIAOU_CONFIGDIR/apps/odoo12/$shortname.conf" "$MIAOU_CONFIGDIR/miaou.expanded.yaml" >/dev/null APP_NAME=$shortname tera -t "$MIAOU_BASEDIR/templates/apps/odoo12/odoo.service.j2" --env-only -o "$MIAOU_CONFIGDIR/apps/odoo12/$longname.service" >/dev/null echo "creating templates ... OK" echo "copying files over container <$container> ... " lxc file push --uid 0 --gid 0 "$MIAOU_CONFIGDIR/apps/odoo12/$shortname.conf" "$container/etc/odoo12/$shortname.conf" lxc file push --uid 0 --gid 0 "$MIAOU_CONFIGDIR/apps/odoo12/$longname.service" "$container/etc/systemd/system/$longname.service" echo "copying files over container <$container> ... OK" if ! (db-psql list | grep -q "$longname"); then echo "create empty database <$longname> ... " db-psql create "$longname" echo "create empty database <$longname> ... OK" admin_username=$(cat "$data" | yq '.admin.username') [[ $admin_username == 'null ' ]] && echoerr "odoo12 recipe requires \`data:admin:username\` into miaou.yaml service definition of <$fqdn>" && exit 1 admin_password=$(cat "$data" | yq '.admin.password') [[ $admin_password == 'null ' ]] && echoerr "odoo12 recipe requires \`data:admin:password\` into miaou.yaml service definition of <$fqdn>" && exit 1 cat <