From 307670464efcad3b1d98d79d490f4c346b909637 Mon Sep 17 00:00:00 2001
From: Robin Sonnabend <robin@fsmpi.rwth-aachen.de>
Date: Fri, 20 Nov 2020 01:39:10 +0100
Subject: [PATCH] Add etherpad-api-proxy and update protokollsystem

---
 uwsgi-python/handlers/main.yml                |  3 ++
 .../templates/apps/etherpad-api-proxy.j2      | 10 +++++++
 .../templates/apps/protokollsystem.j2         |  4 ++-
 uwsgi-python/vars/etherpad-api-proxy.yml      | 30 +++++++++++++++++++
 4 files changed, 46 insertions(+), 1 deletion(-)
 create mode 100644 uwsgi-python/templates/apps/etherpad-api-proxy.j2
 create mode 100644 uwsgi-python/vars/etherpad-api-proxy.yml

diff --git a/uwsgi-python/handlers/main.yml b/uwsgi-python/handlers/main.yml
index 6943805..28c6b49 100644
--- a/uwsgi-python/handlers/main.yml
+++ b/uwsgi-python/handlers/main.yml
@@ -125,3 +125,6 @@
 
 - name: restart uwsgi instance darlehen
   service: name="uwsgi@darlehen" state=restarted
+
+- name: restart uwsgi instance etherpad-api-proxy
+  service: name="uwsgi@etherpad-api-proxy" state=restarted
diff --git a/uwsgi-python/templates/apps/etherpad-api-proxy.j2 b/uwsgi-python/templates/apps/etherpad-api-proxy.j2
new file mode 100644
index 0000000..50688b0
--- /dev/null
+++ b/uwsgi-python/templates/apps/etherpad-api-proxy.j2
@@ -0,0 +1,10 @@
+[upstream]
+url = "{{etherpad_api_proxy_upstream_url}}"
+api_key = "{{etherpad_api_proxy_upstream_api_key}}"
+
+{% for account in etherpad_api_proxy_accounts %}
+[[api_keys]]
+orga = "{{account.name}}"
+api_key = "{{account.api_key}}"
+
+{% endfor %}
diff --git a/uwsgi-python/templates/apps/protokollsystem.j2 b/uwsgi-python/templates/apps/protokollsystem.j2
index 4f57292..63a9cbc 100644
--- a/uwsgi-python/templates/apps/protokollsystem.j2
+++ b/uwsgi-python/templates/apps/protokollsystem.j2
@@ -55,11 +55,13 @@ PRINTING_PRINTERS = {
 
 ETHERPAD_ACTIVE = {{ protokolle_etherpad }}
 ETHERPAD_URL = "{{ protokolle_etherpad_url }}"
+ETHERPAD_API_URL = "{{ protokolle_etherpad_api_url }}"
+ETHERPAD_APIKEY = "{{ protokolle_etherpad_apikey }}"
 EMPTY_ETHERPAD = """Welcome to Etherpad!
 
 This pad text is synchronized as you type, so that everyone viewing this page sees the same text. This allows you to collaborate seamlessly on documents!
 
-Get involved with Etherpad at http://etherpad.org
+Get involved with Etherpad at https://etherpad.org
 
 """
 
diff --git a/uwsgi-python/vars/etherpad-api-proxy.yml b/uwsgi-python/vars/etherpad-api-proxy.yml
new file mode 100644
index 0000000..feb8a97
--- /dev/null
+++ b/uwsgi-python/vars/etherpad-api-proxy.yml
@@ -0,0 +1,30 @@
+---
+
+app_name: etherpad-api-proxy
+app_user: etherpad-api-proxy
+app_group: etherpad-api-proxy
+app_home: /var/www/etherpad-api-proxy
+app_path: /var/www/etherpad-api-proxy
+app_python_version: 3
+app_venv: /var/www/etherpad-api-proxy/venv/
+app_program: proxy.py
+app_callable: app
+app_command: ""
+app_mountpoint: /
+app_service_env: []
+app_mules: 0
+app_enable_threads: false
+app_uwsgi_options: []
+
+app_db_name: ''
+app_db_type: ''
+
+app_additional_software: []
+
+app_deploy_key: ''
+app_git_url: 'https://git.fsmpi.rwth-aachen.de/infra/etherpad-api-proxy.git'
+app_git_version: HEAD
+
+app_requirements_file: requirements.txt
+app_config_file: 'config.toml'
+app_secret_config: false
-- 
GitLab