summary refs log tree commit diff
diff options
context:
space:
mode:
-rwxr-xr-xhost/Rory-nginx/services/containers/pluralcontactbotpoc/services/conduit.nix18
1 files changed, 18 insertions, 0 deletions
diff --git a/host/Rory-nginx/services/containers/pluralcontactbotpoc/services/conduit.nix b/host/Rory-nginx/services/containers/pluralcontactbotpoc/services/conduit.nix
index aa64814..d100f4d 100755
--- a/host/Rory-nginx/services/containers/pluralcontactbotpoc/services/conduit.nix
+++ b/host/Rory-nginx/services/containers/pluralcontactbotpoc/services/conduit.nix
@@ -14,6 +14,24 @@
       allow_registration = false;
     };
   };
+
+  systemd.services.matrix-conduit-reg-token = {
+      description = "Random registration token for Conduit.";
+      before = ["conduit.service"]; # So the registration can be used by Conduit.
+
+      script = ''
+        reg_token=`cat /dev/urandom | tr -dc a-zA-Z0-9 | fold -w 256 | head -n 1`
+        mkdir -p /run/systemd/system/conduit.service.d
+        echo $reg_token > /run/conduit-registration-token
+        echo Environment=\"CONDUIT_REGISTRATION_TOKEN=${reg_token}\" > /run/systemd/system/conduit.service.d/override.conf
+        systemctl daemon-reload
+        systemctl try-restart conduit.service'';
+      serviceConfig = {
+        User = "root";
+        Group = "root";
+      };
+    };
+
   system.stateVersion = "22.11"; # DO NOT EDIT!
 }