Skip to content

Instantly share code, notes, and snippets.

@2510
Created May 28, 2016
Embed
What would you like to do?
FreeBSD rc.script for activating ZFS pool over iSCSI
#!/bin/sh
# PROVIDE: iscsi-zfs
# REQUIRE: iscsid iscsictl mountcritlocal var
# BEFORE: xtreemfs-osd
. /etc/rc.subr
name="iscsi-zfs"
start_cmd="iscsi_zfs_start"
stop_cmd="iscsi_zfs_stop"
rcvar="iscsi_zfs_enable"
iscsi_zfs_enable=${iscsi_zfs_enable:-"NO"}
iscsi_zfs_wait_iqn=${iscsi_zfs_wait_iqn:-""}
iscsi_zfs_wait_pool=${iscsi_zfs_wait_pool:-""}
iscsi_zfs_wait_retry=${iscsi_zfs_wait_retry:-"30"}
iscsi_zfs_start()
{
retry=0
while [ "$retry" -lt "${iscsi_zfs_wait_retry}" ]
do
if iscsictl | fgrep "${iscsi_zfs_wait_iqn}" | fgrep "Connected: " >/dev/null; then
break
fi
retry=`expr ${retry} + 1`
sleep 1
done
while [ "$retry" -lt "${iscsi_zfs_wait_retry}" ]
do
if zpool status "${iscsi_zfs_wait_pool}" >/dev/null 2>&1; then
break
fi
retry=`expr ${retry} + 1`
sleep 1
done
while [ "$retry" -lt "${iscsi_zfs_wait_retry}" ]
do
zfs mount -a
if mount | fgrep "${iscsi_zfs_wait_pool}" >/dev/null 2>&1; then
break
fi
retry=`expr ${retry} + 1`
sleep 1
done
}
load_rc_config $name
run_rc_command "$1"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment