[odrs-web] Using {ENV:FOO} does not work with uwsgi



commit b297d0737651464ea1d5dab8d958a227bbf58211
Author: Richard Hughes <richard hughsie com>
Date:   Mon Jul 1 12:32:34 2019 +0100

    Using {ENV:FOO} does not work with uwsgi

 app_data/httpd-pre-init/entrypoint.sh      |  2 ++
 app_data/wsgi-scripts/odrs-apache-setup.py | 24 ++++++++++++++++++++++++
 2 files changed, 26 insertions(+)
---
diff --git a/app_data/httpd-pre-init/entrypoint.sh b/app_data/httpd-pre-init/entrypoint.sh
index 7656ee8..c542d25 100755
--- a/app_data/httpd-pre-init/entrypoint.sh
+++ b/app_data/httpd-pre-init/entrypoint.sh
@@ -1,3 +1,5 @@
 #!/bin/sh
 
+python36 /opt/app-root/src/app_data/wsgi-scripts/odrs-apache-setup.py 
${HTTPD_CONFIGURATION_PATH}/odrs.gnome.org.conf
+
 while true; do python36 /opt/app-root/src/cron.py ratings /opt/app-root/src/odrs/static/ratings.json ; sleep 
43200 ; done &
diff --git a/app_data/wsgi-scripts/odrs-apache-setup.py b/app_data/wsgi-scripts/odrs-apache-setup.py
new file mode 100644
index 0000000..2446e13
--- /dev/null
+++ b/app_data/wsgi-scripts/odrs-apache-setup.py
@@ -0,0 +1,24 @@
+#!/usr/bin/python3
+# -*- coding: utf-8 -*-
+#
+# Copyright (C) 2019 Richard Hughes <richard hughsie com>
+#
+# SPDX-License-Identifier: GPL-3.0+
+
+import sys
+import os
+
+def subst_inplace(fn):
+    with open(fn, 'r') as f:
+        blob = f.read()
+    for key in ['SQLALCHEMY_DATABASE_URI',
+                'ODRS_REVIEWS_SECRET']:
+        search = '%%{ENV:%s}' % format(key)
+        blob = blob.replace(search, os.environ.get(key, 'INVALID'))
+    with open(fn, 'w') as f:
+        f.write(blob)
+
+if __name__ == '__main__':
+    for argv in sys.argv[1:]:
+        print('Processing', argv)
+        subst_inplace(argv)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]