From cc499784bb931ea824c9dd9af4395f0787597f84 Mon Sep 17 00:00:00 2001 From: pvincent Date: Wed, 9 Oct 2024 17:08:08 +0400 Subject: [PATCH] discourse OK --- recipes/discourse/crud.sh | 26 +++++++++++++++++++++----- scripts/miaou | 1 + templates/apps/discourse/forum.yml.j2 | 2 -- 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/recipes/discourse/crud.sh b/recipes/discourse/crud.sh index 00e2274..cc2b904 100755 --- a/recipes/discourse/crud.sh +++ b/recipes/discourse/crud.sh @@ -1,14 +1,14 @@ #!/bin/bash function check_service_running() { - lxc exec "$container" -- bash -c "docker ps --format {{.Names}} | grep $1" + lxc exec "$container" -- bash -c "docker ps --format '{{.Names}},{{.Ports}}' | grep $1 | grep $2" } function _read() { disable_trace check_db_postgres_exists "$longname" check_container "$container" - check_service_running "$shortname" + check_service_running "$longname" "$port" enable_trace return 0 } @@ -21,9 +21,25 @@ function _create() { APP_DOMAIN=$domain APP_SUBDOMAIN=$subdomain APP_FQDN=$fqdn APP_PORT=$port APP_NAME=$longname tera -e --env-key env -t "$MIAOU_BASEDIR/templates/apps/discourse/forum.yml.j2" -o "$MIAOU_CONFIGDIR/apps/discourse/$longname.yml" "$MIAOU_CONFIGDIR/miaou.expanded.yaml" echo "creating templates ... OK" - #TODO: - 1. copy template to container - 1. rebuild container + echo "copying files to container <$container> ... " + lxc file push --uid 0 --gid 0 "$MIAOU_CONFIGDIR/apps/discourse/$longname.yml" "$container/var/discourse/containers/$longname.yml" + 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 "build docker container $longname ..." + lxc exec "$container" -- bash </dev/null; then echoinfo "CREATE RECIPE" + # echo "$command -c" eval "$command -c" echoinfo "CREATE RECIPE: OK" diff --git a/templates/apps/discourse/forum.yml.j2 b/templates/apps/discourse/forum.yml.j2 index 68794de..27a5bc8 100644 --- a/templates/apps/discourse/forum.yml.j2 +++ b/templates/apps/discourse/forum.yml.j2 @@ -20,8 +20,6 @@ env: LANGUAGE: en_US.UTF-8 # DISCOURSE_DEFAULT_LOCALE: en - ## Uncomment if you want the container to be started with the same - ## hostname (-h option) as specified above (default "$hostname-$config") DOCKER_USE_HOSTNAME: true DISCOURSE_SMTP_ADDRESS: {{ services[env.APP_DOMAIN][env.APP_SUBDOMAIN].data.discourse.smtp.server }}