From 3b73777bc0a249344fb10b79f94dc19f2639391370c702f0e19cd6da402e4070 Mon Sep 17 00:00:00 2001 From: "Dr. Werner Fink" Date: Tue, 5 Nov 2013 11:15:58 +0000 Subject: [PATCH] Accepting request 204993 from home:posophe:branches:Base:System made required changes OBS-URL: https://build.opensuse.org/request/show/204993 OBS-URL: https://build.opensuse.org/package/show/Base:System/tgt?expand=0&rev=19 --- tgt.changes | 6 ++ tgt.init | 167 --------------------------------------------------- tgt.spec | 30 +++++---- tgtd.service | 15 +++++ 4 files changed, 35 insertions(+), 183 deletions(-) delete mode 100644 tgt.init create mode 100644 tgtd.service diff --git a/tgt.changes b/tgt.changes index e6a12c4..9d22144 100644 --- a/tgt.changes +++ b/tgt.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Wed Oct 23 16:24:11 UTC 2013 - p.drouand@gmail.com + +- Drop sysvinit support +- Add systemd support + ------------------------------------------------------------------- Sat Jul 13 14:25:21 UTC 2013 - dmueller@suse.com diff --git a/tgt.init b/tgt.init deleted file mode 100644 index da0d018..0000000 --- a/tgt.init +++ /dev/null @@ -1,167 +0,0 @@ -#!/bin/sh -# -# /etc/init.d/tgtd -# -### BEGIN INIT INFO -# Provides: tgtd -# Required-Start: $remote_fs $network -# Should-Start: -# Required-Stop: $remote_fs $network -# Should-Stop: -# Default-Start: 3 5 -# Default-Stop: -# Short-Description: generic storage target daemon -# Description: Starts and stops the generic storage target subsystem -### END INIT INFO - -# -# - -DAEMON=/usr/sbin/tgtd -TGTD_CONFIG=/etc/tgt/targets.conf - -# Source LSB init functions -. /etc/rc.status - -rc_reset - -PATH=/sbin:/bin:/usr/sbin:/usr/bin - -start() -{ - echo "Starting target framework daemon" - # Start tgtd first. - tgtd &>/dev/null - RETVAL=$? - if [ "$RETVAL" -ne 0 ] ; then - rc_failed -v - else - # 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. - tgtadm --op update --mode sys --name State -v offline - # Configure the targets. - tgt-admin -e -c $TGTD_CONFIG - # Put tgtd into "ready" state. - tgtadm --op update --mode sys --name State -v ready - rc_failed 0 - fi - rc_status -v -} - -stop() -{ - if [ "$RUNLEVEL" == 0 -o "$RUNLEVEL" == 6 ] ; then - forcedstop - fi - echo "Stopping target framework daemon" - # Remove all targets. It only removes targets which are not in use. - tgt-admin --update ALL -c /dev/null &>/dev/null - # tgtd will exit if all targets were removed - tgtadm --op delete --mode system &>/dev/null - RETVAL=$? - if [ "$RETVAL" -eq 107 ] ; then - rc_failed 7 - [ "$TASK" != "restart" ] && exit 1 - elif [ "$RETVAL" -ne 0 ] ; then - echo -n "(Some initiators are still connected)" - rc_failed 1 - fi - rc_status -v -} - -forcedstop() -{ - # NOTE: Forced shutdown of the iscsi target may cause data corruption - # for initiators that are connected. - echo "Force-stopping target framework daemon" - # Offline everything first. May be needed if we're rebooting, but - # expect the initiators to reconnect cleanly when we boot again - # (i.e. we don't want them to reconnect to a tgtd which is still - # working, but the target is gone). - tgtadm --op update --mode sys --name State -v offline &>/dev/null - RETVAL=$? - if [ "$RETVAL" -eq 107 ] ; then - rc_failed 7 - [ "$TASK" != "restart" ] && exit 1 - else - tgt-admin --offline ALL - # Remove all targets, even if they are still in use. - tgt-admin --update ALL -c /dev/null -f - # It will shut down tgtd only after all targets were removed. - tgtadm --op delete --mode system - RETVAL=$? - if [ "$RETVAL" -ne 0 ] ; then - rc_failed 1 - fi - fi -} - -reload() -{ - echo "Updating target framework daemon configuration" - # Update configuration for targets. Only targets which - # are not in use will be updated. - tgt-admin --update ALL -c $TGTD_CONFIG &>/dev/null - RETVAL=$? - if [ "$RETVAL" -eq 107 ] ; then - rc_failed 7 - fi -} - -forcedreload() -{ - echo "Force-updating target framework daemon configuration" - # Update configuration for targets, even those in use. - tgt-admin --update ALL -f -c $TGTD_CONFIG &>/dev/null - RETVAL=$? - if [ "$RETVAL" -eq 107 ] ; then - rc_failed 7 - fi -} - -case "$1" in - start) - echo -n "Starting SCSI target service: " - start - rc_status -v - ;; - stop) - echo -n "Stopping SCSI target service: " - stop - if [ $RETVAL != "0" ]; then - rc_failed - else - modprobe -r scsi_tgt 2>/dev/null - modprobe -r crc32c 2>/dev/null - rc_failed 0 - fi - rc_status -v - ;; - forcedstop) - forcedstop - rc_status -v - ;; - forcereload) - forcedreload - rc_status -v - ;; - restart|reload) - TASK=$1 - stop - RETVAL=$? - if [ $RETVAL -eq 0 ] ; then - start - fi - rc_status -v - ;; - status) - echo -n "Checking for SCSI target service" - checkproc $DAEMON - rc_status -v - ;; - *) - echo $"Usage: $0 {start|stop|restart|reload|forcedreload|forcedstop|status}" - exit 1 -esac -rc_exit diff --git a/tgt.spec b/tgt.spec index 8a50886..676ad5b 100644 --- a/tgt.spec +++ b/tgt.spec @@ -22,24 +22,25 @@ BuildRequires: libaio-devel BuildRequires: libxslt BuildRequires: openssl-devel BuildRequires: perl-Config-General +BuildRequires: pkgconfig(systemd) Obsoletes: iscsitarget Requires: perl-Config-General Url: http://stgt.berlios.de -PreReq: %fillup_prereq %insserv_prereq +Requires(pre): %fillup_prereq Version: 1.0.28 Release: 0 Summary: Generic Linux target framework (tgt) License: GPL-2.0 Group: System/Daemons Source: %{name}-%{version}.tar.bz2 -Source1: %{name}.init +Source1: %{name}d.service Source3: %{name}.services Patch1: %{name}-git-update Patch2: %{name}-fix-build # PATCH-FIX-UPSTREAM tgt-mgmt-fixed-m-system-o-delete-handling.patch [bnc#767438] - lduncan@suse.com Patch3: %{name}-mgmt-fixed-m-system-o-delete-handling.patch Patch4: setup-tgt-conf-d.patch -BuildRoot: %{_tmppath}/%{name}-%{version}-build +%{?systemd_requires} %description Linux target framework (tgt) aims to simplify various SCSI target @@ -72,32 +73,29 @@ Authors: %{__make} OPTFLAGS="${RPM_OPT_FLAGS}" %{backends} %install -%{__make} DESTDIR=${RPM_BUILD_ROOT} docdir=%_docdir/%{name} install -install -vD -m 755 %{S:1} ${RPM_BUILD_ROOT}/etc/init.d/tgtd -ln -sf /etc/init.d/tgtd ${RPM_BUILD_ROOT}/usr/sbin/rctgtd -install -vD %{S:3} ${RPM_BUILD_ROOT}/etc/sysconfig/SuSEfirewall2.d/services/tgt - -%clean -rm -rf ${RPM_BUILD_ROOT} -rm -f filelist +%{__make} DESTDIR=%{buildroot} docdir=%_docdir/%{name} install +install -vD -m 755 %{S:1} %{buildroot}/%{_unitdir}/%{name}d.service +install -vD %{S:3} %{buildroot}/etc/sysconfig/SuSEfirewall2.d/services/tgt +ln -sf /sbin/service %{buildroot}/usr/sbin/rc%{name} %post -%{fillup_and_insserv tgtd} +%{fillup_only} +%service_add_post %{name}d.service %preun -%stop_on_removal +%service_del_preun %{name}d.service %postun -%{insserv_cleanup} +%service_del_postun %{name}d.service %files %defattr(-,root,root) -/usr/sbin/* -/etc/init.d/tgtd +%{_sbindir}/* %dir /etc/tgt %dir /etc/tgt/conf.d %config %attr(0644,root,root) /etc/tgt/targets.conf %config %attr(0644,root,root) /etc/sysconfig/SuSEfirewall2.d/services/tgt +%{_unitdir}/%{name}d.service %doc README doc/README.iscsi doc/README.iser doc/README.lu_configuration %doc doc/README.mmc doc/README.passthrough doc/README.sbcjukebox doc/README.ssc %doc %{_mandir}/man8/* diff --git a/tgtd.service b/tgtd.service new file mode 100644 index 0000000..e0dd841 --- /dev/null +++ b/tgtd.service @@ -0,0 +1,15 @@ +[Unit] +Description=tgt admin +After=network.target + +[Service] +Type=forking +User=root +ExecStart=/usr/sbin/tgtd +ExecStartPost=/usr/sbin/tgtadm --op update --mode sys --name State -v offline ; /usr/sbin/tgt-admin -e -c /etc/tgt/targets.conf ; /usr/sbin/tgtadm --op update --mode sys --name State -v ready +ExecStopPre=/usr/sbin/tgt-admin --update ALL -c /dev/null +ExecStop=-/usr/sbin/tgtadm --op delete --mode system + + +[Install] +WantedBy=multi-user.target