Accepting request 215396 from Base:System
- Make service link a local one - Drop sysvinit support - Add systemd support OBS-URL: https://build.opensuse.org/request/show/215396 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/tgt?expand=0&rev=23
This commit is contained in:
commit
ccd3f6db39
11
tgt.changes
11
tgt.changes
@ -1,3 +1,14 @@
|
||||
-------------------------------------------------------------------
|
||||
Tue Jan 28 15:51:43 UTC 2014 - werner@suse.de
|
||||
|
||||
- Make service link a local one
|
||||
|
||||
-------------------------------------------------------------------
|
||||
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
|
||||
|
||||
|
167
tgt.init
167
tgt.init
@ -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
|
32
tgt.spec
32
tgt.spec
@ -1,7 +1,7 @@
|
||||
#
|
||||
# spec file for package tgt
|
||||
#
|
||||
# Copyright (c) 2013 SUSE LINUX Products GmbH, Nuernberg, Germany.
|
||||
# Copyright (c) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany.
|
||||
#
|
||||
# All modifications and additions to the file contributed by third parties
|
||||
# remain the property of their copyright owners, unless otherwise agreed
|
||||
@ -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 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/*
|
||||
|
15
tgtd.service
Normal file
15
tgtd.service
Normal file
@ -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
|
Loading…
Reference in New Issue
Block a user