Set working directory in systemd service file
By default systemd will execute service with root directory (or home directory for user instance) which might result in
attempts to create files in unexpected place. Let's set it to 'osmocom' subdir of state directory (/var/lib for system instance) instead.
Related: OS#4821
Change-Id: I950d84853c6737276d02b3275127b499ae567c38
diff --git a/contrib/systemd/osmo-gtphub.service b/contrib/systemd/osmo-gtphub.service
index 4881785..1e8f1ae 100644
--- a/contrib/systemd/osmo-gtphub.service
+++ b/contrib/systemd/osmo-gtphub.service
@@ -4,6 +4,8 @@
[Service]
Type=simple
ExecStart=/usr/bin/osmo-gtphub -c /etc/osmocom/osmo-gtphub.cfg
+StateDirectory=osmocom
+WorkingDirectory=%S/osmocom
Restart=always
RestartSec=2
RestartPreventExitStatus=1
diff --git a/contrib/systemd/osmo-sgsn.service b/contrib/systemd/osmo-sgsn.service
index 0991c70..30b3cda 100644
--- a/contrib/systemd/osmo-sgsn.service
+++ b/contrib/systemd/osmo-sgsn.service
@@ -6,6 +6,8 @@
[Service]
Type=simple
+StateDirectory=osmocom
+WorkingDirectory=%S/osmocom
Restart=always
ExecStart=/usr/bin/osmo-sgsn -c /etc/osmocom/osmo-sgsn.cfg
RestartSec=2