#!/bin/bash function check_database_exists() { db-psql list | grep -q "$longname" } function check_port_used() { # shellcheck disable=SC2034 usedport=$(lxc exec "$container" -- cat /etc/nginx/sites-enabled/"$longname".conf | grep listen | cut -d ' ' -f2) [[ "$usedport" == "$port" ]] } function check_directory_exists() { lxc exec "$container" -- test -d /var/www/"$longname" } function check_service_running() { lxc exec "$container" -- bash -c "systemctl is-active --quiet nginx.service" } function _read() { disable_trace check_database_exists check_container "$container" check_port_used check_directory_exists check_service_running enable_trace return 0 } function _create() { PREFIX="recipe:dolibarr:create" : $PREFIX echo "create a Dolibarr instance for $shortname" lxc exec "$container" -- bash </dev/null echo "copying configuration files onto container <$container>... " lxc file push --uid 0 --gid 0 "$MIAOU_CONFIGDIR/apps/dolibarr/$shortname/host.conf" "$container/etc/nginx/sites-available/$longname.conf" 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" else echo "database already exists!" fi echo "enable host config..." lxc exec "$container" -- bash <