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="iscsictl"
rcvar=$name
command="/sbin/${name}"
pidfile="/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=bacula /opt/bacula
mount -o rw,log NAME=video /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
Attachment:
signature.asc
Description: OpenPGP digital signature