summaryrefslogtreecommitdiff
path: root/docker/cgit/docker-init.py
diff options
context:
space:
mode:
Diffstat (limited to 'docker/cgit/docker-init.py')
-rwxr-xr-xdocker/cgit/docker-init.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/docker/cgit/docker-init.py b/docker/cgit/docker-init.py
new file mode 100755
index 0000000..c5b47b8
--- /dev/null
+++ b/docker/cgit/docker-init.py
@@ -0,0 +1,22 @@
+#!/usr/bin/env python3
+
+
+import sys, os
+import re
+
+
+with open("/etc/cgitrc", "r") as file: cgitrc = file.read()
+
+
+for env_name, env_value in os.environ.items():
+ if env_name.startswith('CGIT_'):
+ rc_name = env_name[5:].lower().replace('_', '-')
+ p = re.compile(r"({0}=)([\w\d]+)".format(rc_name))
+
+ if p.search(cgitrc):
+ cgitrc = p.sub(r"\1{0}".format(env_value), cgitrc)
+ else:
+ cgitrc += ("\n" + "{0}={1}".format(rc_name, env_value) + "\n")
+
+
+with open("/etc/cgitrc", "w") as file: file.write(cgitrc)