diff --git a/recipes/discourse/crud.sh b/recipes/discourse/crud.sh index 0c0fb71..e05b926 100755 --- a/recipes/discourse/crud.sh +++ b/recipes/discourse/crud.sh @@ -31,8 +31,20 @@ function _create() { admin_password=$(load_yaml_from_expanded services[\""$domain"\"][\""$subdomain"\"].data.admin.password) redis_password=$(load_yaml_from_expanded credential.redis) + redis_host=$(lxc list ct1 -c4 -f csv | cut -d' ' -f1) + + echo -n "count redis databases..." + redis_database=$(lxc exec ct1 -- bash -c "redis-cli -h $redis_host -a $redis_password INFO keyspace | tail -n1 | grep db | cut -d: -f1") + redis_database=${redis_database#db} + if [[ "$redis_database" =~ ^[0-9]+$ ]]; then + redis_database=$((redis_database + 1)) + else + redis_database=0 + fi + PREFIX='' echo $redis_database + mkdir -p "$MIAOU_CONFIGDIR/apps/discourse" - APP_REDIS_PASSWORD=$redis_password 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" >/dev/null + APP_REDIS_DB=$redis_database APP_REDIS_PASSWORD=$redis_password 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" >/dev/null echo "creating templates ... OK" echo "copying files to container <$container> ... " diff --git a/templates/apps/discourse/forum.yml.j2 b/templates/apps/discourse/forum.yml.j2 index 22c8a5e..cc4b689 100644 --- a/templates/apps/discourse/forum.yml.j2 +++ b/templates/apps/discourse/forum.yml.j2 @@ -37,6 +37,7 @@ env: DISCOURSE_REDIS_HOST: ct1.lxd DISCOURSE_REDIS_PASSWORD: {{ env.APP_REDIS_PASSWORD }} + DISCOURSE_REDIS_DB: {{ env.APP_REDIS_DB }} volumes: - volume: