From 6c1aaf998151306bc3ffc83f254c10de0538820b Mon Sep 17 00:00:00 2001 From: Chris Leech Date: Jan 22 2013 23:16:38 +0000 Subject: switch to using system unit files instead of initrd script new nm dispatcher script that uses systemctl use systemctl in iscsi.conf to start iscsid on demand --- diff --git a/0060-use-systemctl-to-start-iscsid.patch b/0060-use-systemctl-to-start-iscsid.patch new file mode 100644 index 0000000..dc62c32 --- /dev/null +++ b/0060-use-systemctl-to-start-iscsid.patch @@ -0,0 +1,25 @@ +From c3d2b8f3de5b6161845304cf46982d2c5a9918b6 Mon Sep 17 00:00:00 2001 +From: Chris Leech +Date: Tue, 22 Jan 2013 15:04:14 -0800 +Subject: use systemctl to start iscsid + +--- + etc/iscsid.conf | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/etc/iscsid.conf b/etc/iscsid.conf +index ac1d231..5851fa5 100644 +--- a/etc/iscsid.conf ++++ b/etc/iscsid.conf +@@ -17,7 +17,7 @@ + # maintainers. + # + # Default for Fedora and RHEL. (uncomment to activate). +-iscsid.startup = /etc/rc.d/init.d/iscsid force-start ++iscsid.startup = /bin/systemctl start iscsid.service + # + # Default for upstream open-iscsi scripts (uncomment to activate). + # iscsid.startup = /sbin/iscsid +-- +1.7.11.7 + diff --git a/04-iscsi b/04-iscsi index 58aa798..e4a1c30 100755 --- a/04-iscsi +++ b/04-iscsi @@ -1,17 +1,7 @@ #!/bin/sh -export LC_ALL=C +case "$2" in + up|down|vpn-up|vpn-down) + /bin/systemctl try-restart iscsi.service || : + ;; -if [ "$2" = "down" ]; then - if ! /sbin/ip route ls | grep -q ^default && - [ -f /var/lock/subsys/iscsi ]; then - /etc/rc.d/init.d/iscsi stop - fi -fi - -if [ "$2" = "up" ]; then - if /sbin/ip -o route show dev "$1" | grep -q '^default' && - /sbin/chkconfig iscsi; then - /etc/rc.d/init.d/iscsi start - fi -fi diff --git a/iscsi-initiator-utils.spec b/iscsi-initiator-utils.spec index 2c11880..cd8a866 100644 --- a/iscsi-initiator-utils.spec +++ b/iscsi-initiator-utils.spec @@ -10,8 +10,6 @@ Version: 6.%{open_iscsi_version}.%{open_iscsi_build} Release: 1%{?dist} Source0: http://www.open-iscsi.org/bits/open-iscsi-%{open_iscsi_version}-%{open_iscsi_build}.tar.gz Source1: iscsiuio-%{iscsiuio_version}.tar.gz -Source2: iscsid.init -Source3: iscsidevs.init Source4: 04-iscsi # upstream patches, post last tagged version @@ -40,6 +38,7 @@ Patch56: 0056-remove-the-offload-boot-supported-ifdef.patch Patch57: 0057-iscsid-iscsiuio-ipc-interface.patch Patch58: 0058-iscsiuio-IPC-newroot-command.patch Patch59: 0059-iscsiuio-systemd-unit-files.patch +Patch60: 0060-use-systemctl-to-start-iscsid.patch # iscsiuio patches Patch71: 0071-iscsiuio-0.7.4.3.patch Patch72: 0072-iscsiuio-0.7.6.1.patch @@ -58,9 +57,9 @@ URL: http://www.open-iscsi.org Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildRequires: openssl-devel flex bison python-devel doxygen glibc-static # For dir ownership -Requires: initscripts -Requires(post): chkconfig -Requires(preun): chkconfig /sbin/service +Requires(post): systemd +Requires(preun): systemd +Requires(postun): systemd %description The iscsi package provides the server daemon for the iSCSI protocol, @@ -106,6 +105,7 @@ mv iscsiuio-%{iscsiuio_version} iscsiuio %patch57 -p1 %patch58 -p1 %patch59 -p1 +%patch60 -p1 # iscsiuio patches cd iscsiuio %patch71 -p1 @@ -147,7 +147,6 @@ popd rm -rf $RPM_BUILD_ROOT mkdir -p $RPM_BUILD_ROOT/sbin mkdir -p ${RPM_BUILD_ROOT}%{_mandir}/man8 -mkdir -p $RPM_BUILD_ROOT/etc/rc.d/init.d mkdir -p $RPM_BUILD_ROOT/etc/iscsi mkdir -p $RPM_BUILD_ROOT/etc/logrotate.d mkdir -p $RPM_BUILD_ROOT/etc/NetworkManager/dispatcher.d @@ -175,8 +174,11 @@ install -p -m 644 iscsiuio/docs/iscsiuio.8 $RPM_BUILD_ROOT/%{_mandir}/man8 install -p -m 644 iscsiuio/iscsiuiolog $RPM_BUILD_ROOT%{_sysconfdir}/logrotate.d install -p -m 755 iscsiuio/src/unix/iscsiuio $RPM_BUILD_ROOT/sbin -install -p -m 755 %{SOURCE2} $RPM_BUILD_ROOT%{_initrddir}/iscsid -install -p -m 755 %{SOURCE3} $RPM_BUILD_ROOT%{_initrddir}/iscsi +install -p -D -m 644 etc/systemd/iscsi.service $RPM_BUILD_ROOT%{_unitdir}/iscsi.service +install -p -D -m 644 etc/systemd/iscsid.service $RPM_BUILD_ROOT%{_unitdir}/iscsid.service +install -p -D -m 644 etc/systemd/iscsid.socket $RPM_BUILD_ROOT%{_unitdir}/iscsid.socket +install -p -D -m 644 etc/systemd/iscsiuio.service $RPM_BUILD_ROOT%{_unitdir}/iscsiuio.service +install -p -D -m 644 etc/systemd/iscsiuio.socket $RPM_BUILD_ROOT%{_unitdir}/iscsiuio.socket install -p -m 755 %{SOURCE4} $RPM_BUILD_ROOT/etc/NetworkManager/dispatcher.d install -p -m 755 libiscsi/libiscsi.so.0 $RPM_BUILD_ROOT%{_libdir} @@ -199,9 +201,10 @@ if [ "$1" -eq "1" ]; then if [ ! -f %{_sysconfdir}/iscsi/initiatorname.iscsi ]; then echo "InitiatorName=`/sbin/iscsi-iname`" > %{_sysconfdir}/iscsi/initiatorname.iscsi fi - /sbin/chkconfig --add iscsid - /sbin/chkconfig --add iscsi fi + +%systemd_post iscsi.service iscsid.service iscsiuio.service + # To make sure iscsid autostart works when upgrading from a version which # did not have this in its config file if ! grep -q 'iscsid\.startup' %{_sysconfdir}/iscsi/iscsid.conf; then @@ -211,18 +214,24 @@ if ! grep -q 'iscsid\.startup' %{_sysconfdir}/iscsi/iscsid.conf; then fi %postun -p /sbin/ldconfig +%systemd_postun %preun -if [ "$1" = "0" ]; then - # stop iscsi - /sbin/service iscsi stop > /dev/null 2>&1 - # delete service - /sbin/chkconfig --del iscsi - # stop iscsid - /sbin/service iscsid stop > /dev/null 2>&1 - # delete service - /sbin/chkconfig --del iscsid -fi +%systemd_preun iscsi.service iscsid.service iscsiuio.service + +%triggerun -- iscsi-initiator-utils < 6.2.0.873-1 +# Save the current service runlevel info +# User must manually run systemd-sysv-convert --apply iscsid +# and systemd-sysv-convert --apply iscsi +# to migrate them to systemd targets +/usr/bin/systemd-sysv-convert --save iscsi >/dev/null 2>&1 ||: +/usr/bin/systemd-sysv-convert --save iscsid >/dev/null 2>&1 ||: + +# Run these because the SysV package being removed won't do them +/sbin/chkconfig --del iscsid >/dev/null 2>&1 || : +/sbin/chkconfig --del iscsi >/dev/null 2>&1 || : +/bin/systemctl try-restart iscsid.service >/dev/null 2>&1 || : +/bin/systemctl try-restart iscsi.service >/dev/null 1>&1 || : %files %defattr(-,root,root) @@ -236,8 +245,11 @@ fi %dir %{_var}/lib/iscsi/send_targets %ghost %{_var}/lock/iscsi %ghost %{_var}/lock/iscsi/lock -%{_initrddir}/iscsi -%{_initrddir}/iscsid +%{_unitdir}/iscsi.service +%{_unitdir}/iscsid.service +%{_unitdir}/iscsid.socket +%{_unitdir}/iscsiuio.service +%{_unitdir}/iscsiuio.socket %{_sysconfdir}/NetworkManager/dispatcher.d/04-iscsi %dir %{_sysconfdir}/iscsi %attr(0600,root,root) %config(noreplace) %{_sysconfdir}/iscsi/iscsid.conf @@ -254,6 +266,10 @@ fi %{_includedir}/libiscsi.h %changelog +* Tue Jan 22 2013 Chris Leech - 6.2.0.873-1 +- rebase to new upstream code +- systemd conversion + * Thu Jul 19 2012 Fedora Release Engineering - 6.2.0.872-19 - Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild diff --git a/iscsid.init b/iscsid.init deleted file mode 100755 index 92912f2..0000000 --- a/iscsid.init +++ /dev/null @@ -1,183 +0,0 @@ -#!/bin/sh -# -# iscsid iSCSI daemon -# -# chkconfig: 345 7 89 -# description: Starts and stops the iSCSI daemon. -# -# processname: iscsid -# pidfile: /var/run/iscsid.pid -# config: /etc/iscsi/iscsid.conf - -### BEGIN INIT INFO -# Provides: iscsid -# Default-Start: 3 4 5 -# Default-Stop: 0 1 2 6 -# Short-Description: Starts and stops login iSCSI daemon. -# Description: iscsid provides the iSCSI session and connection state machine -# for software iscsi/iser (iscsi_tcp/ib_iser) and partialy -# offloaded hardware (bnx2i). -### END INIT INFO - -# Source function library. -. /etc/rc.d/init.d/functions - -exec=/sbin/iscsid -prog=iscsid -config=/etc/iscsi/iscsid.conf -lockfile=/var/lock/subsys/$prog -iscsi_lockfile=/var/lock/subsys/iscsi - -# FIXME this has a false positive for root on nfs -root_is_iscsi() { - rootopts=$(awk '{ if ($1 !~ /^[ \t]*#/ && $2 == "/") { print $4; }}' /etc/mtab) - [[ "$rootopts" =~ "_netdev" ]] -} - -start_iscsid() { - echo -n $"Starting $prog: " - modprobe -q iscsi_tcp - modprobe -q ib_iser - modprobe -q cxgb3i - modprobe -q cxgb4i - modprobe -q bnx2i - modprobe -q be2iscsi - daemon iscsiuio - daemon $prog - retval=$? - echo - touch $lockfile -} - -force_start() { - start_iscsid - # a force start could imply the iscsi service is started due to how it - # lazy starts. We need to touch the lock file so it is shutdown later - touch $iscsi_lockfile -} - -use_discoveryd() { - grep -qrs "discovery.sendtargets.use_discoveryd = Yes" /var/lib/iscsi/send_targets - if [ $? -eq 0 ] ; then - return 0 - fi - - grep -qrs "discovery.isns.use_discoveryd = Yes" /var/lib/iscsi/isns - if [ $? -eq 0 ] ; then - return 0 - fi - - return 1 -} - -start() { - [ -x $exec ] || exit 5 - [ -f $config ] || exit 6 - - start_iscsid - return $? -} - -stop() { - if use_discoveryd ; then - iscsiadm -k 0 2>/dev/null - fi - - declare -a iparams=( $(iscsiadm -m session 2>/dev/null | egrep "tcp|iser|bnx2i|cxgb3i|cxgb4i|be2iscsi") ) - if [[ -n "${iparams[*]}" ]]; then - # We have active sessions, so don't stop iscsid!! - echo -n $"Not stopping $prog: iscsi sessions still active" - warning $"Not stopping $prog: iscsi sessions still active" - echo - return 0 - fi - - echo -n $"Stopping $prog: " - - iscsiadm -k 0 2>/dev/null - echo - - killproc iscsiuio - rm -f /var/run/iscsiuio.pid - - # only remove the iscsi drivers when offload is used - rmmod bnx2i 2>/dev/null - rmmod cnic 2>/dev/null - - rmmod cxgb3i 2>/dev/null - rmmod cxgb4i 2>/dev/null - - # a bug in kobject netlink code will cause this to oops - # modprobe -r be2iscsi 2>/dev/null - - modprobe -r ib_iser 2>/dev/null - modprobe -r iscsi_tcp 2>/dev/null - - rm -f $lockfile - return 0 -} - -rh_status_q() { - rh_status >/dev/null 2>&1 -} - -restart() { - rh_status_q - use_force_start=$? - - stop - # if iscsid was running then make sure it starts up - if [ "$use_force_start" -eq 0 ] ; then - start_iscsid - else - start - fi -} - -reload() { - return 3 -} - -force_reload() { - restart -} - -rh_status() { - status $prog -} - -case "$1" in - start) - rh_status_q && exit 0 - $1 - ;; - force-start) - force_start - ;; - stop) - rh_status_q || exit 0 - $1 - ;; - restart) - $1 - ;; - reload) - rh_status_q || exit 7 - $1 - ;; - force-reload) - force_reload - ;; - status) - rh_status - ;; - condrestart|try-restart) - rh_status_q || exit 0 - restart - ;; - *) - echo $"Usage: $0 -{start|stop|status|restart|condrestart|try-restart|reload|force-reload}" - exit 2 -esac -exit $? diff --git a/iscsidevs.init b/iscsidevs.init deleted file mode 100755 index 60498c4..0000000 --- a/iscsidevs.init +++ /dev/null @@ -1,169 +0,0 @@ -#!/bin/sh -# -# iscsi: log into iSCSI targets -# -# chkconfig: 345 13 89 -# description: Logs into iSCSI targets needed at system startup - -### BEGIN INIT INFO -# Provides: iscsi -# Required-Start: iscsid network -# Should-Start: tgtd -# Required-Stop: iscsid -# Should-Stop: tgtd -# Default-Start: 3 4 5 -# Default-Stop: 0 1 2 6 -# Short-Description: Starts and stops login and scanning of iSCSI devices. -# Description: iscsi provides the iSCSI state machine for software iscsi/iser -# and partial offloaded hardware. iscsi logs into and scans -# for iSCSI devices, and shuts them down when stopped. -### END INIT INFO - -# Source function library. -. /etc/rc.d/init.d/functions - -exec="/sbin/iscsiadm" -prog="iscsi" -config="/etc/iscsi/initiatorname.iscsi" -lockfile=/var/lock/subsys/$prog -iscsid_lockfile=/var/lock/subsys/${prog}_iscsid - -start() { - [ -x $exec ] || exit 5 - [ -f $config ] || exit 6 - - # if the network isn't up yet exit cleanly, NetworkManager will call us - # again when the network is up - [ ! -f /var/lock/subsys/network ] && ! nm-online -x >/dev/null 2>&1 && exit 3 - - # this script is normally called from startup so log into - # nodes marked node.startup=automatic - echo -n $"Starting $prog: " - $exec -m node --loginall=automatic 2>&1 > /dev/null | grep iscsiadm - # Ignore return code, because this command attempts to log into - # multiple sessions and some sessions could get logged into and - # some could be down temporarily. - success $"Starting $prog" - touch $lockfile - echo - return 0 -} - -iscsi_sessions_running() { - declare -a iparams=( $(iscsiadm -m session 2>/dev/null | egrep "tcp|iser|bnx2i|be2iscsi|cxgb3i|cxgb4i") ) - if [[ -z "${iparams[*]}" ]]; then - # no sessions - return 2 - fi - - return 0 -} - -cleanup_successful_stop() { - success $"Stopping $prog" - rm -f $lockfile - echo -} - -stop() { - # Don't turn off iscsi if root is possibly on a iscsi disk. - rootopts=$(awk '{ if ($1 !~ /^[ \t]*#/ && $2 == "/") { print $4; }}' /etc/mtab) - if [[ "$rootopts" =~ "_netdev" ]] ; then - echo $"Can not shutdown iSCSI. Root is on a iSCSI disk." - - # Just clean up lock file if this is a system shutdown/reboot. - if [ "$RUNLEVEL" = "6" -o "$RUNLEVEL" = "0" -o "$RUNLEVEL" = "1" ]; then - rm -f $lockfile - fi - - exit 1 - fi - - echo -n $"Stopping $prog: " - - if ! iscsi_sessions_running ; then - cleanup_successful_stop - return 0 - fi - - if [ "$RUNLEVEL" = "6" -o "$RUNLEVEL" = "0" -o "$RUNLEVEL" = "1" ]; then - $exec -m node --logoutall=all 2>&1 > /dev/null - else - $exec -m node --logoutall=automatic 2>&1 > /dev/null - fi - - ret=$? - # ignore ISCSI_ERR_NO_OBJS_FOUND/21 - if [[ "$ret" -ne 0 && "$ret" -ne 21 ]]; then - failure $"Stopping $prog" - echo - return 1 - fi - - cleanup_successful_stop - return 0 -} - -restart() { - stop - start -} - -reload() { - return 3 -} - -force_reload() { - restart -} - -rh_status() { - [ -f $lockfile ] || { echo $"$prog is stopped" ; return 3 ; } - - declare -a iparams=( $(iscsiadm -m session 2>/dev/null | egrep "tcp|iser|bnx2i|be2iscsi|cxgb3i|cxgb4i") ) - if [[ -z "${iparams[*]}" ]]; then - # no sessions - echo $"No active sessions" - return 2 - fi - - iscsiadm -m session -P 3 - return 0 -} - -rh_status_q() { - rh_status >/dev/null 2>&1 -} - - -case "$1" in - start) - rh_status_q && exit 0 - $1 - ;; - stop) - $1 - ;; - restart) - $1 - ;; - reload) - rh_status_q || exit 7 - $1 - ;; - force-reload) - force_reload - ;; - status) - rh_status - ;; - condrestart|try-restart) - rh_status_q || exit 0 - restart - ;; - *) - echo $"Usage: $0 -{start|stop|status|restart|condrestart|try-restart|reload|force-reload}" - exit 2 -esac -exit $?