laforge submitted this change.

View Change

Approvals: Jenkins Builder: Verified pespin: Looks good to me, but someone else must approve laforge: Looks good to me, approved
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: I4b7bcd441e5da81c4c5267715675041171a1ce1e
---
M contrib/systemd/lc15bts-mgr.service
M contrib/systemd/oc2gbts-mgr.service
M contrib/systemd/osmo-bts-lc15.service
M contrib/systemd/osmo-bts-oc2g.service
M contrib/systemd/osmo-bts-sysmo.service
M contrib/systemd/osmo-bts-trx.service
M contrib/systemd/osmo-bts-virtual.service
M contrib/systemd/sysmobts-mgr.service
8 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/contrib/systemd/lc15bts-mgr.service b/contrib/systemd/lc15bts-mgr.service
index bf788e6..fbdb774 100644
--- a/contrib/systemd/lc15bts-mgr.service
+++ b/contrib/systemd/lc15bts-mgr.service
@@ -7,6 +7,8 @@
Type=simple
NotifyAccess=all
WatchdogSec=21780s
+StateDirectory=osmocom
+WorkingDirectory=%S/osmocom
Restart=always
RestartSec=2

diff --git a/contrib/systemd/oc2gbts-mgr.service b/contrib/systemd/oc2gbts-mgr.service
index ed915b3..78fbcce 100644
--- a/contrib/systemd/oc2gbts-mgr.service
+++ b/contrib/systemd/oc2gbts-mgr.service
@@ -7,6 +7,8 @@
Type=simple
NotifyAccess=all
WatchdogSec=21780s
+StateDirectory=osmocom
+WorkingDirectory=%S/osmocom
Restart=always
RestartSec=2

diff --git a/contrib/systemd/osmo-bts-lc15.service b/contrib/systemd/osmo-bts-lc15.service
index 7c51110..0266c9a 100644
--- a/contrib/systemd/osmo-bts-lc15.service
+++ b/contrib/systemd/osmo-bts-lc15.service
@@ -4,6 +4,8 @@
[Service]
Type=simple
ExecStart=/usr/bin/osmo-bts-lc15 -t 2 -s -c /etc/osmocom/osmo-bts-lc15.cfg -M
+StateDirectory=osmocom
+WorkingDirectory=%S/osmocom
RuntimeDirectory=osmo-bts
Restart=always
RestartSec=2
diff --git a/contrib/systemd/osmo-bts-oc2g.service b/contrib/systemd/osmo-bts-oc2g.service
index 860aeb1..b0b1f7e 100644
--- a/contrib/systemd/osmo-bts-oc2g.service
+++ b/contrib/systemd/osmo-bts-oc2g.service
@@ -4,6 +4,8 @@
[Service]
Type=simple
ExecStart=/usr/bin/osmo-bts-oc2g -s -c /etc/osmocom/osmo-bts-oc2g.cfg -M
+StateDirectory=osmocom
+WorkingDirectory=%S/osmocom
RuntimeDirectory=osmo-bts
Restart=always
RestartSec=2
diff --git a/contrib/systemd/osmo-bts-sysmo.service b/contrib/systemd/osmo-bts-sysmo.service
index 9255817..f297cfc 100644
--- a/contrib/systemd/osmo-bts-sysmo.service
+++ b/contrib/systemd/osmo-bts-sysmo.service
@@ -7,6 +7,8 @@
ExecStart=/usr/bin/osmo-bts-sysmo -s -c /etc/osmocom/osmo-bts-sysmo.cfg -M
ExecStopPost=/bin/sh -c 'echo 0 > /sys/class/leds/activity_led/brightness'
ExecStopPost=/bin/sh -c 'cat /lib/firmware/sysmobts-v?.bit > /dev/fpgadl_par0 ; sleep 3s; cat /lib/firmware/sysmobts-v?.out > /dev/dspdl_dm644x_0; sleep 1s'
+StateDirectory=osmocom
+WorkingDirectory=%S/osmocom
Restart=always
RestartSec=2
RestartPreventExitStatus=1
diff --git a/contrib/systemd/osmo-bts-trx.service b/contrib/systemd/osmo-bts-trx.service
index 97c2b07..e73e793 100644
--- a/contrib/systemd/osmo-bts-trx.service
+++ b/contrib/systemd/osmo-bts-trx.service
@@ -4,6 +4,8 @@
[Service]
Type=simple
ExecStart=/usr/bin/osmo-bts-trx -s -c /etc/osmocom/osmo-bts-trx.cfg
+StateDirectory=osmocom
+WorkingDirectory=%S/osmocom
Restart=always
RestartSec=2

diff --git a/contrib/systemd/osmo-bts-virtual.service b/contrib/systemd/osmo-bts-virtual.service
index 1633266..877181b 100644
--- a/contrib/systemd/osmo-bts-virtual.service
+++ b/contrib/systemd/osmo-bts-virtual.service
@@ -4,6 +4,8 @@
[Service]
Type=simple
ExecStart=/usr/bin/osmo-bts-virtual -s -c /etc/osmocom/osmo-bts-virtual.cfg
+StateDirectory=osmocom
+WorkingDirectory=%S/osmocom
Restart=always
RestartSec=2

diff --git a/contrib/systemd/sysmobts-mgr.service b/contrib/systemd/sysmobts-mgr.service
index 4346991..c9cbaba 100644
--- a/contrib/systemd/sysmobts-mgr.service
+++ b/contrib/systemd/sysmobts-mgr.service
@@ -4,6 +4,8 @@
[Service]
Type=simple
ExecStart=/usr/bin/sysmobts-mgr -ns -c /etc/osmocom/sysmobts-mgr.cfg
+StateDirectory=osmocom
+WorkingDirectory=%S/osmocom
Restart=always
RestartSec=2


To view, visit change 29302. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Change-Id: I4b7bcd441e5da81c4c5267715675041171a1ce1e
Gerrit-Change-Number: 29302
Gerrit-PatchSet: 1
Gerrit-Owner: msuraev <msuraev@sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge@osmocom.org>
Gerrit-Reviewer: pespin <pespin@sysmocom.de>
Gerrit-MessageType: merged