From 751f8fd4361bfd88d587417a3136a9e348cf4bb9 Mon Sep 17 00:00:00 2001 From: Daniel Schaefer Date: Mon, 29 Jul 2019 20:03:23 +0200 Subject: [PATCH 1/5] tgtd.service: Fix Documentation URI systemd issues a warning with the space present Signed-off-by: Daniel Schaefer --- scripts/tgtd.service | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/tgtd.service b/scripts/tgtd.service index f31da968..348f1069 100644 --- a/scripts/tgtd.service +++ b/scripts/tgtd.service @@ -1,6 +1,6 @@ [Unit] Description=iSCSI target framework daemon -Documentation=man: tgtd(8) +Documentation=man:tgtd(8) After=network.target # On systems without virtual consoles, don't start any getty. Note From d679a992df19eada17988cbe3e4d8869070acb08 Mon Sep 17 00:00:00 2001 From: Daniel Schaefer Date: Mon, 29 Jul 2019 20:04:24 +0200 Subject: [PATCH 2/5] tgtd.service: Don't fork but notify Let systemd handle the process management. Type=notify so that the ExecStartPost commands are only executed when the daemon is ready. Signed-off-by: Daniel Schaefer --- scripts/tgtd.service | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/tgtd.service b/scripts/tgtd.service index 348f1069..ff96eb11 100644 --- a/scripts/tgtd.service +++ b/scripts/tgtd.service @@ -9,10 +9,10 @@ After=network.target ConditionPathExists=/etc/tgt/targets.conf [Service] -Type=forking +Type=notify Environment=TGTD_CONFIG=/etc/tgt/targets.conf -ExecStart=/usr/sbin/tgtd +ExecStart=/usr/sbin/tgtd --foreground 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} From eb83fc584106e597246ba06ac51a1aa576aef343 Mon Sep 17 00:00:00 2001 From: Daniel Schaefer Date: Mon, 29 Jul 2019 20:45:30 +0200 Subject: [PATCH 3/5] tgtd.service: Run tgt-admin verbose So that it shows all the underlying tgtadm commands it executes. Makes debugging easier. Also expand the arguments to their full form so that it's clearer what each command does. Signed-off-by: Daniel Schaefer --- scripts/tgtd.service | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/scripts/tgtd.service b/scripts/tgtd.service index ff96eb11..353371cf 100644 --- a/scripts/tgtd.service +++ b/scripts/tgtd.service @@ -13,15 +13,15 @@ Type=notify Environment=TGTD_CONFIG=/etc/tgt/targets.conf ExecStart=/usr/sbin/tgtd --foreground -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} +ExecStartPost=/usr/sbin/tgtadm --op update --mode sys --name State --value offline +ExecStartPost=/usr/sbin/tgtadm --op update --mode sys --name State --value ready +ExecStartPost=/usr/sbin/tgt-admin --verbose --execute --conf ${TGTD_CONFIG} -ExecReload=/usr/sbin/tgt-admin --update ALL -f -c ${TGTD_CONFIG} +ExecReload=/usr/sbin/tgt-admin --verbose --update ALL --force --conf ${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 update --mode sys --name State --value offline +ExecStop=/usr/sbin/tgt-admin --verbose --offline ALL +ExecStop=/usr/sbin/tgt-admin --verbose --update ALL --force --conf /dev/null ExecStop=/usr/sbin/tgtadm --op delete --mode system # Exit code: 107 tgtd not running From 16a544dc7d38857ba2a079f8cac643bc7c74fe13 Mon Sep 17 00:00:00 2001 From: Daniel Schaefer Date: Mon, 29 Jul 2019 20:50:12 +0200 Subject: [PATCH 4/5] tgtd.service: Remove getty comment getty does not seem to be related to this service. Signed-off-by: Daniel Schaefer --- scripts/tgtd.service | 3 --- 1 file changed, 3 deletions(-) diff --git a/scripts/tgtd.service b/scripts/tgtd.service index 353371cf..f713ecb7 100644 --- a/scripts/tgtd.service +++ b/scripts/tgtd.service @@ -3,9 +3,6 @@ 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 serial-getty@.service, not this -# unit. ConditionPathExists=/etc/tgt/targets.conf [Service] From bbb40d0898648d4fdef3f96c1a153b51c8e63fa3 Mon Sep 17 00:00:00 2001 From: Daniel Schaefer Date: Mon, 29 Jul 2019 20:50:45 +0200 Subject: [PATCH 5/5] tgtd.service: Kill tgtd after targets were deleted Otherwise the daemon will keep running. Signed-off-by: Daniel Schaefer --- scripts/tgtd.service | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/tgtd.service b/scripts/tgtd.service index f713ecb7..1c187d65 100644 --- a/scripts/tgtd.service +++ b/scripts/tgtd.service @@ -20,9 +20,9 @@ ExecStop=/usr/sbin/tgtadm --op update --mode sys --name State --value offline ExecStop=/usr/sbin/tgt-admin --verbose --offline ALL ExecStop=/usr/sbin/tgt-admin --verbose --update ALL --force --conf /dev/null ExecStop=/usr/sbin/tgtadm --op delete --mode system +ExecStop=/usr/sbin/kill -9 $MAINPID -# Exit code: 107 tgtd not running - +# ExecStop exit code: 107 tgtd not running [Install] WantedBy=multi-user.target