From a0b99547acd3ab523af1638455e211e876b5c24d Mon Sep 17 00:00:00 2001 From: Mingli Yu Date: Fri, 10 Aug 2018 15:29:32 +0800 Subject: tgt: add systemd service file Add systemd service file for tgt Signed-off-by: Mingli Yu Signed-off-by: Bruce Ashfield --- meta-openstack/recipes-support/tgt/files/tgtd | 5 ++++ .../recipes-support/tgt/files/tgtd.service | 33 ++++++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 meta-openstack/recipes-support/tgt/files/tgtd create mode 100755 meta-openstack/recipes-support/tgt/files/tgtd.service (limited to 'meta-openstack/recipes-support/tgt/files') diff --git a/meta-openstack/recipes-support/tgt/files/tgtd b/meta-openstack/recipes-support/tgt/files/tgtd new file mode 100644 index 0000000..64df6a3 --- /dev/null +++ b/meta-openstack/recipes-support/tgt/files/tgtd @@ -0,0 +1,5 @@ +# options for tgtd +TGTD_OPTS="" + +# configuration file +TGTD_CONFIG=/etc/tgt/targets.conf diff --git a/meta-openstack/recipes-support/tgt/files/tgtd.service b/meta-openstack/recipes-support/tgt/files/tgtd.service new file mode 100755 index 0000000..afbd4b4 --- /dev/null +++ b/meta-openstack/recipes-support/tgt/files/tgtd.service @@ -0,0 +1,33 @@ +[Unit] +Description=tgtd iSCSI target daemon +After=network.target + +[Service] +EnvironmentFile=@SYSCONFDIR@/sysconfig/tgtd + +ExecStart=@SBINDIR@/tgtd -f $TGTD_OPTS +# see bz 848942. workaround for a race for now. +ExecStartPost=@BASE_BINDIR@/sleep 5 +# Put tgtd into "offline" state until all the targets are configured. +# We don't want initiators to (re)connect and fail the connection +# if it's not ready. +ExecStartPost=@SBINDIR@/tgtadm --op update --mode sys --name State -v offline +# Configure the targets. +ExecStartPost=@SBINDIR@/tgt-admin -e -c $TGTD_CONFIG +# Put tgtd into "ready" state. +ExecStartPost=@SBINDIR@/tgtadm --op update --mode sys --name State -v ready + +# Update configuration for targets. Only targets which +# are not in use will be updated. +ExecReload=@SBINDIR@/tgt-admin --update ALL -c $TGTD_CONFIG + +# NOTE: Shutdown of the iscsi target may cause data corruption +# for initiators that are connected. +ExecStop=@SBINDIR@/tgtadm --op update --mode sys --name State -v offline +# Remove all targets. It only removes targets which are not in use. +ExecStop=@SBINDIR@/tgt-admin --update ALL -c /dev/null +# tgtd will exit if all targets were removed +ExecStop=@SBINDIR@/tgtadm --op delete --mode system + +[Install] +WantedBy=multi-user.target -- cgit v1.2.3-54-g00ecf