summaryrefslogtreecommitdiff
path: root/pcr/postsrsd/0001-systemd-populate-SRS_DOMAIN-default-using-postconf.patch
blob: 03b5652eca94edf5bb49ff92f1248532bfa1ce4e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
From 731ef505e2aff8b0a94986f03b4b57b2acce9996 Mon Sep 17 00:00:00 2001
From: Dan Callaghan <dcallagh@redhat.com>
Date: Mon, 7 Mar 2016 13:39:35 +1000
Subject: [PATCH 1/1] systemd: populate SRS_DOMAIN default using postconf

Fixes #48
---
 init/postsrsd.systemd.in | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/init/postsrsd.systemd.in b/init/postsrsd.systemd.in
index dcc5298..ab168ca 100644
--- a/init/postsrsd.systemd.in
+++ b/init/postsrsd.systemd.in
@@ -3,11 +3,21 @@ Description=PostSRSd Daemon
 
 [Service]
 Type=simple
+Restart=always
+
+# Fallback defaults.
 Environment=SRS_DOMAIN=localhost.localdomain
 Environment=SRS_EXCLUDE_DOMAINS=
+
+# Fill in a default value for SRS_DOMAIN using postconf.
+RuntimeDirectory=@PROJECT_NAME@
+ExecStartPre=/bin/sh -c '{ echo -n SRS_DOMAIN= ; postconf -h mydomain ; } >/run/@PROJECT_NAME@/default'
+EnvironmentFile=-/run/@PROJECT_NAME@/default
+
+# Load the real configuration.
 EnvironmentFile=@CONFIG_DIR@/@PROJECT_NAME@
+
 ExecStart=@CMAKE_INSTALL_PREFIX@/sbin/@POSTSRSD@ -f "${SRS_FORWARD_PORT}" -r "${SRS_REVERSE_PORT}" -d "${SRS_DOMAIN}" -s "${SRS_SECRET}" -a "${SRS_SEPARATOR}" -u "${RUN_AS}" -c "${CHROOT}" -X"${SRS_EXCLUDE_DOMAINS}"
-Restart=always
 
 [Install]
 WantedBy=multi-user.target
-- 
2.12.2