diff options
author | Mingli Yu <Mingli.Yu@windriver.com> | 2018-08-10 15:29:32 +0800 |
---|---|---|
committer | Bruce Ashfield <bruce.ashfield@windriver.com> | 2018-08-14 13:03:42 -0400 |
commit | a0b99547acd3ab523af1638455e211e876b5c24d (patch) | |
tree | c04fd47c043bf8e6a490ca63c722057a6007e161 | |
parent | 5b963d1e391dd822a56678194ff914bbcac83012 (diff) | |
download | meta-cloud-services-a0b99547acd3ab523af1638455e211e876b5c24d.tar.gz |
tgt: add systemd service file
Add systemd service file for tgt
Signed-off-by: Mingli Yu <Mingli.Yu@windriver.com>
Signed-off-by: Bruce Ashfield <bruce.ashfield@windriver.com>
-rw-r--r-- | meta-openstack/recipes-support/tgt/files/tgtd | 5 | ||||
-rwxr-xr-x | meta-openstack/recipes-support/tgt/files/tgtd.service | 33 | ||||
-rw-r--r-- | meta-openstack/recipes-support/tgt/tgt_git.bb | 22 |
3 files changed, 58 insertions, 2 deletions
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 @@ | |||
1 | # options for tgtd | ||
2 | TGTD_OPTS="" | ||
3 | |||
4 | # configuration file | ||
5 | 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 @@ | |||
1 | [Unit] | ||
2 | Description=tgtd iSCSI target daemon | ||
3 | After=network.target | ||
4 | |||
5 | [Service] | ||
6 | EnvironmentFile=@SYSCONFDIR@/sysconfig/tgtd | ||
7 | |||
8 | ExecStart=@SBINDIR@/tgtd -f $TGTD_OPTS | ||
9 | # see bz 848942. workaround for a race for now. | ||
10 | ExecStartPost=@BASE_BINDIR@/sleep 5 | ||
11 | # Put tgtd into "offline" state until all the targets are configured. | ||
12 | # We don't want initiators to (re)connect and fail the connection | ||
13 | # if it's not ready. | ||
14 | ExecStartPost=@SBINDIR@/tgtadm --op update --mode sys --name State -v offline | ||
15 | # Configure the targets. | ||
16 | ExecStartPost=@SBINDIR@/tgt-admin -e -c $TGTD_CONFIG | ||
17 | # Put tgtd into "ready" state. | ||
18 | ExecStartPost=@SBINDIR@/tgtadm --op update --mode sys --name State -v ready | ||
19 | |||
20 | # Update configuration for targets. Only targets which | ||
21 | # are not in use will be updated. | ||
22 | ExecReload=@SBINDIR@/tgt-admin --update ALL -c $TGTD_CONFIG | ||
23 | |||
24 | # NOTE: Shutdown of the iscsi target may cause data corruption | ||
25 | # for initiators that are connected. | ||
26 | ExecStop=@SBINDIR@/tgtadm --op update --mode sys --name State -v offline | ||
27 | # Remove all targets. It only removes targets which are not in use. | ||
28 | ExecStop=@SBINDIR@/tgt-admin --update ALL -c /dev/null | ||
29 | # tgtd will exit if all targets were removed | ||
30 | ExecStop=@SBINDIR@/tgtadm --op delete --mode system | ||
31 | |||
32 | [Install] | ||
33 | WantedBy=multi-user.target | ||
diff --git a/meta-openstack/recipes-support/tgt/tgt_git.bb b/meta-openstack/recipes-support/tgt/tgt_git.bb index f4e12da..b94b034 100644 --- a/meta-openstack/recipes-support/tgt/tgt_git.bb +++ b/meta-openstack/recipes-support/tgt/tgt_git.bb | |||
@@ -12,13 +12,19 @@ SRC_URI = "git://github.com/fujita/tgt.git \ | |||
12 | file://0001-usr-Makefile-WARNING-fix.patch \ | 12 | file://0001-usr-Makefile-WARNING-fix.patch \ |
13 | file://usr-Makefile-apply-LDFLAGS-to-all-executables.patch \ | 13 | file://usr-Makefile-apply-LDFLAGS-to-all-executables.patch \ |
14 | " | 14 | " |
15 | SRC_URI += "file://tgtd.init" | 15 | SRC_URI += "file://tgtd.init \ |
16 | file://tgtd.service \ | ||
17 | file://tgtd \ | ||
18 | " | ||
16 | 19 | ||
17 | S = "${WORKDIR}/git" | 20 | S = "${WORKDIR}/git" |
18 | 21 | ||
19 | CONFFILES_${PN} += "${sysconfdir}/tgt/targets.conf" | 22 | CONFFILES_${PN} += "${sysconfdir}/tgt/targets.conf" |
20 | 23 | ||
21 | inherit update-rc.d | 24 | inherit update-rc.d systemd |
25 | |||
26 | SYSTEMD_SERVICE_${PN} = "tgtd.service" | ||
27 | SYSTEMD_AUTO_ENABLE_${PN} = "disable" | ||
22 | 28 | ||
23 | CFLAGS += ' -I. -DUSE_SIGNALFD -DUSE_TIMERFD -D_GNU_SOURCE -DTGT_VERSION=\\"1.0.63\\" -DBSDIR=\\"${libdir}/backing-store\\"' | 29 | CFLAGS += ' -I. -DUSE_SIGNALFD -DUSE_TIMERFD -D_GNU_SOURCE -DTGT_VERSION=\\"1.0.63\\" -DBSDIR=\\"${libdir}/backing-store\\"' |
24 | 30 | ||
@@ -33,9 +39,21 @@ do_install() { | |||
33 | if ${@bb.utils.contains('DISTRO_FEATURES', 'sysvinit', 'true', 'false', d)}; then | 39 | if ${@bb.utils.contains('DISTRO_FEATURES', 'sysvinit', 'true', 'false', d)}; then |
34 | install -d ${D}${sysconfdir}/init.d | 40 | install -d ${D}${sysconfdir}/init.d |
35 | install -m 0755 ${WORKDIR}/tgtd.init ${D}${sysconfdir}/init.d/tgtd | 41 | install -m 0755 ${WORKDIR}/tgtd.init ${D}${sysconfdir}/init.d/tgtd |
42 | elif ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', 'false', d)}; then | ||
43 | install -d ${D}${systemd_unitdir}/system | ||
44 | install -m 0644 ${WORKDIR}/tgtd.service ${D}${systemd_unitdir}/system/tgtd.service | ||
45 | install -d ${D}${sysconfdir}/sysconfig | ||
46 | install -m 0644 ${WORKDIR}/tgtd ${D}${sysconfdir}/sysconfig/tgtd | ||
47 | sed -i -e 's,@SBINDIR@,${sbindir},g' ${D}${systemd_unitdir}/system/tgtd.service | ||
48 | sed -i -e 's,@BASE_BINDIR@,${base_bindir},g' ${D}${systemd_unitdir}/system/tgtd.service | ||
49 | sed -i -e 's,@SYSCONFDIR@,${sysconfdir},g' ${D}${systemd_unitdir}/system/tgtd.service | ||
36 | fi | 50 | fi |
37 | } | 51 | } |
38 | 52 | ||
53 | FILES_${PN} += "${systemd_unitdir}/system/tgtd.service \ | ||
54 | ${sysconfdir}/sysconfig/tgtd \ | ||
55 | " | ||
56 | |||
39 | RDEPENDS_${PN} = " \ | 57 | RDEPENDS_${PN} = " \ |
40 | bash \ | 58 | bash \ |
41 | libaio \ | 59 | libaio \ |