[Patch] Added systemd service

Timofey Titovets <[email protected]> Tue, 31 Mar 2015 18:11:28 +0300
Newsgroups org.kernel.vger.stgt
Message-ID <CAGqmi74fGasr4AYqSF=r_SF29A7yho38S8f2jiJpJ6BDkABZ3Q@mail.gmail.com>
This is my simple implementation of systemd service for tgtd.
I've tested it on my server and it working good enough, i think it can
be useful not only in upstream but and for Debian and Ubuntu packages.

Signed-off-by: Timofey Titovets <[email protected]>
---
 scripts/tgtd.service | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)
 create mode 100644 scripts/tgtd.service
diff --git a/scripts/tgtd.service b/scripts/tgtd.service
new file mode 100644
index 0000000..f31da96
--- /dev/null
+++ b/scripts/tgtd.service
@@ -0,0 +1,31 @@
+[Unit]
+Description=iSCSI target framework daemon
+Documentation=man: tgtd(8)
+After=network.target
+
+# On systems without virtual consoles, don't start any getty. Note
+# that serial gettys are covered by [email protected], not this
+# unit.
+ConditionPathExists=/etc/tgt/targets.conf
+
+[Service]
+Type=forking
+Environment=TGTD_CONFIG=/etc/tgt/targets.conf
+
+ExecStart=/usr/sbin/tgtd
+ExecStartPost=/usr/sbin/tgtadm --op update --mode sys --name State -v offline
+ExecStartPost=/usr/sbin/tgtadm --op update --mode sys --name State -v ready
+ExecStartPost=/usr/sbin/tgt-admin -e -c ${TGTD_CONFIG}
+
+ExecReload=/usr/sbin/tgt-admin --update ALL -f -c ${TGTD_CONFIG}
+
+ExecStop=/usr/sbin/tgtadm --op update --mode sys --name State -v offline
+ExecStop=/usr/sbin/tgt-admin --offline ALL
+ExecStop=/usr/sbin/tgt-admin --update ALL -c /dev/null -f
+ExecStop=/usr/sbin/tgtadm  --op delete --mode system
+
+# Exit code: 107 tgtd not running
+
+
+[Install]
+WantedBy=multi-user.target
-- 
2.1.4
0001-Added-systemd-service.patch (text/x-patch, 1.5 KB)
From 1b08df8812b7e8e50a76ebc7ab81d5a4b9b77903 Mon Sep 17 00:00:00 2001
From: Timofey Titovets <[email protected]>
Date: Tue, 31 Mar 2015 18:06:50 +0300
Subject: [PATCH] Added systemd service

Signed-off-by: Timofey Titovets <[email protected]>
---
 scripts/tgtd.service | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)
 create mode 100644 scripts/tgtd.service

diff --git a/scripts/tgtd.service b/scripts/tgtd.service
new file mode 100644
index 0000000..f31da96
--- /dev/null
+++ b/scripts/tgtd.service
@@ -0,0 +1,31 @@
+[Unit]
+Description=iSCSI target framework daemon
+Documentation=man: tgtd(8)
+After=network.target
+
+# On systems without virtual consoles, don't start any getty. Note
+# that serial gettys are covered by [email protected], not this
+# unit.
+ConditionPathExists=/etc/tgt/targets.conf
+
+[Service]
+Type=forking
+Environment=TGTD_CONFIG=/etc/tgt/targets.conf
+
+ExecStart=/usr/sbin/tgtd
+ExecStartPost=/usr/sbin/tgtadm --op update --mode sys --name State -v offline
+ExecStartPost=/usr/sbin/tgtadm --op update --mode sys --name State -v ready
+ExecStartPost=/usr/sbin/tgt-admin -e -c ${TGTD_CONFIG}
+
+ExecReload=/usr/sbin/tgt-admin --update ALL -f -c ${TGTD_CONFIG}
+
+ExecStop=/usr/sbin/tgtadm --op update --mode sys --name State -v offline
+ExecStop=/usr/sbin/tgt-admin --offline ALL
+ExecStop=/usr/sbin/tgt-admin --update ALL -c /dev/null -f
+ExecStop=/usr/sbin/tgtadm  --op delete --mode system
+
+# Exit code: 107 tgtd not running
+
+
+[Install]
+WantedBy=multi-user.target
-- 
2.1.4