Browse Source

discourse OK

main
pvincent 1 month ago
parent
commit
cc499784bb
  1. 26
      recipes/discourse/crud.sh
  2. 1
      scripts/miaou
  3. 2
      templates/apps/discourse/forum.yml.j2

26
recipes/discourse/crud.sh

@ -1,14 +1,14 @@
#!/bin/bash #!/bin/bash
function check_service_running() { 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() { function _read() {
disable_trace disable_trace
check_db_postgres_exists "$longname" check_db_postgres_exists "$longname"
check_container "$container" check_container "$container"
check_service_running "$shortname"
check_service_running "$longname" "$port"
enable_trace enable_trace
return 0 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" 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" 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 <<EOF
set -Eeuo pipefail
cd /var/discourse
./launcher rebuild $longname
EOF
echo "initialize discourse $longname ... OK"
} }
function _update() { function _update() {

1
scripts/miaou

@ -501,6 +501,7 @@ function build_services() {
[[ "$data" != "null" ]] && command+=" --data \"$data\"" [[ "$data" != "null" ]] && command+=" --data \"$data\""
if ! eval "$command -r" >/dev/null; then if ! eval "$command -r" >/dev/null; then
echoinfo "CREATE RECIPE" echoinfo "CREATE RECIPE"
# echo "$command -c" # echo "$command -c"
eval "$command -c" eval "$command -c"
echoinfo "CREATE RECIPE: OK" echoinfo "CREATE RECIPE: OK"

2
templates/apps/discourse/forum.yml.j2

@ -20,8 +20,6 @@ env:
LANGUAGE: en_US.UTF-8 LANGUAGE: en_US.UTF-8
# DISCOURSE_DEFAULT_LOCALE: en # 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 DOCKER_USE_HOSTNAME: true
DISCOURSE_SMTP_ADDRESS: {{ services[env.APP_DOMAIN][env.APP_SUBDOMAIN].data.discourse.smtp.server }} DISCOURSE_SMTP_ADDRESS: {{ services[env.APP_DOMAIN][env.APP_SUBDOMAIN].data.discourse.smtp.server }}

Loading…
Cancel
Save