summary refs log tree commit diff
path: root/contrib/docker/rob/rootfs/etc
diff options
context:
space:
mode:
authorkaiyou <pierre@jaury.eu>2018-02-04 15:08:19 +0100
committerkaiyou <pierre@jaury.eu>2018-02-04 15:08:19 +0100
commit53965334da04ca6d126829a4c4cf395e5bdfc1c6 (patch)
tree4ea61a47abbce010a1276412577109f5090e3da7 /contrib/docker/rob/rootfs/etc
parentReuse environment variables of the postgres container (diff)
parentdocker: s/matrix-org/matrixdotorg/g (diff)
downloadsynapse-53965334da04ca6d126829a4c4cf395e5bdfc1c6.tar.xz
Merge remote-tracking branch 'origin/rob/docker' into feat-dockerfile
Diffstat (limited to 'contrib/docker/rob/rootfs/etc')
-rwxr-xr-xcontrib/docker/rob/rootfs/etc/service/synapse/finish17
-rwxr-xr-xcontrib/docker/rob/rootfs/etc/service/synapse/run75
2 files changed, 92 insertions, 0 deletions
diff --git a/contrib/docker/rob/rootfs/etc/service/synapse/finish b/contrib/docker/rob/rootfs/etc/service/synapse/finish
new file mode 100755
index 0000000000..2aace581a1
--- /dev/null
+++ b/contrib/docker/rob/rootfs/etc/service/synapse/finish
@@ -0,0 +1,17 @@
+#!/bin/bash
+#
+# Copyright 2017 Vector Creations Ltd
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+kill -TERM 1
diff --git a/contrib/docker/rob/rootfs/etc/service/synapse/run b/contrib/docker/rob/rootfs/etc/service/synapse/run
new file mode 100755
index 0000000000..dd797d3ef9
--- /dev/null
+++ b/contrib/docker/rob/rootfs/etc/service/synapse/run
@@ -0,0 +1,75 @@
+#!/bin/bash
+#
+# Copyright 2017 Vector Creations Ltd
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+set -e
+
+: ${CONFIG_PATH:="/synapse/config"}
+: ${POSTGRES_DATABASE:="synapse"}
+: ${POSTGRES_HOST:="postgres"}
+: ${POSTGRES_USER:="postgres"}
+: ${REPORT_STATS:="yes"}
+: ${SERVER_NAME:="localhost"}
+
+DATABASE_CONFIG_PATH="${CONFIG_PATH}/database.yaml"
+HOMESERVER_CONFIG_PATH="${CONFIG_PATH}/homeserver.yaml"
+SYNAPSE_COMMAND="python -m synapse.app.homeserver"
+
+. /synapse/bin/activate
+cd /synapse
+
+if [[ -n "${GENERATE_CONFIG}" ]]; then
+    ${SYNAPSE_COMMAND} \
+        --server-name ${SERVER_NAME} \
+        --config-path ${HOMESERVER_CONFIG_PATH} \
+        --generate-config \
+        --report-stats=${REPORT_STATS}
+
+    if [[ -f "${DATABASE_CONFIG_PATH}" ]]; then
+        echo "Config file '${DATABASE_CONFIG_PATH}' already exists. Remove it if you want it to be generated."
+    else
+        echo "Generating ${DATABASE_CONFIG_PATH}..."
+        if [[ -n "${POSTGRES_PASSWORD}" ]]; then
+            (cat > ${DATABASE_CONFIG_PATH}) <<EOF
+database:
+  name: psycopg2
+  args:
+    host: ${POSTGRES_HOST}
+    user: ${POSTGRES_USER}
+    password: ${POSTGRES_PASSWORD}
+    database: ${POSTGRES_DATABASE}
+    cp_min: 5
+    cp_max: 10
+EOF
+        else
+            (cat > ${DATABASE_CONFIG_PATH}) <<EOF
+database:
+  name: "sqlite3"
+  args:
+    database: "/synapse/data/homeserver.db"
+EOF
+        fi
+        cat ${DATABASE_CONFIG_PATH} | grep -v password
+    fi
+
+    exit 0
+fi
+
+COMMAND="${SYNAPSE_COMMAND} --config-path ${HOMESERVER_CONFIG_PATH}"
+if [[ -r "${DATABASE_CONFIG_PATH}" ]]; then
+    COMMAND="${COMMAND} --config-path ${DATABASE_CONFIG_PATH}"
+fi
+
+exec ${COMMAND}