/etc/rc.d/iscsictl script

BERTRAND Joël <[email protected]> Sun, 26 Jul 2026 10:35:39 +0200
Newsgroups gmane.os.netbsd.general
Message-ID <[email protected]>
This is an OpenPGP/MIME signed message (RFC 4880 and 3156)
--nnMvmpFLl044c0KxQ9eYH6d4MicSYmfo7
Content-Type: multipart/mixed; boundary="YYfUbFXy7Ntn7DadLawIbmpskLD3eynUK"

--YYfUbFXy7Ntn7DadLawIbmpskLD3eynUK
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

	Hello,

	One of my NetBSD servers is connecte to two NAS (through iscsi) and I
want to write a robust iscsictl script.

	Today, both NAS has to be activ when server is powered up. If one of
these NAS is rebuilding its RAID volume, my script doesn't mount iscsi
volumes.

	My script :


legendre# cat iscsictl
#!/bin/sh
#
# $NetBSD: squid.sh,v 1.1 2020/01/04 10:57:18 taca Exp $
#
# PROVIDE: iscsictl
# REQUIRE: iscsid
# KEYWORD: shutdown

if [ -f /etc/rc.subr ]; then
        . /etc/rc.subr
fi

name=3D"iscsictl"
rcvar=3D$name
command=3D"/sbin/${name}"
pidfile=3D"/var/run/${name}.pid"

case $1 in
start)
        sleep 5
        ${command} add_send_target -a 192.168.12.2:3260
        ${command} add_send_target -a 192.168.12.3:3260
        ${command} refresh_targets
        ${command} list_targets
        ${command} login -P `iscsictl list_targets | \
                awk '/192.168.12.2/ { print $1; }' | tr -d ":"`
        ${command} login -P `iscsictl list_targets | \
                awk '/192.168.12.3/ { print $1; }' | tr -d ":"`
        sleep 1
        mount -o rw,log NAME=3Dbacula /opt/bacula
        mount -o rw,log NAME=3Dvideo /opt/video
        /etc/rc.d/mountd reload
        ;;
stop)
        umount /opt/video
        umount /opt/bacula
#       for i in `iscsictl list_sessions | awk '/^Session/ { print $2; }'=
 \
#                       | tr -d ':'`
#       do
#               ${command} logout -I $i
#       done
        ;;
*)
        echo "Usage: $0 {start|stop}" 1>&2
        exit 64
        ;;
esac
legendre#

	I want to do a loop somewhere to force this script to wait for both
NAS. Is something like

while [ `iscsictl list_targets | grep 3260 | wc -l` -ne 2 ]
do iscsictl refresh_targets; sleep 1; done

enough ?

	Second question. I want to disconnect iscsi devices. But this
disconnection should be done /after/ /etc/rc.d/bacula stop. I haven't
found any option in rcorder to be sure that /etc/rc.d/iscsictl stop is
called /after/ /etc/rc.d/bacula stop.

	Help will be welcome,

	JB


--YYfUbFXy7Ntn7DadLawIbmpskLD3eynUK--

--nnMvmpFLl044c0KxQ9eYH6d4MicSYmfo7
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="signature.asc"

-----BEGIN PGP SIGNATURE-----

iHUEABYKAB0WIQQj8MW8iOsC2RXEznnFW/s/mMLXCAUCamXG3AAKCRDFW/s/mMLX
CPtyAQDx2yBeNoSmw3KBVTxn6kj1Zibf4n/xoQZpzGxbUr5G5gEAvltEWjGPaj8V
qoONd/WLanWU+2L3kPxGoJ3EhnVfJgs=
=y0kF
-----END PGP SIGNATURE-----

--nnMvmpFLl044c0KxQ9eYH6d4MicSYmfo7--