rc.d for iscontrol

pluknet pluknet at gmail.com
Tue May 25 13:22:12 UTC 2010


A friend of mine (ufo at februality.com) mentioned there's still no rc.d
script for iscontrol(8) in FreeBSD base.
He pointed to an existing (and working) rc.d/iscsi (slightly modified
by me) which might be integrated to head.
It's still unclear how to handler for ex. iscsi+zfs setup. In the
existing order iscsi requires NETWORKING,
whilst zfs starts long before NETWORKING, so zfs cannot mount iscsi
attached device.

%%%
#!/bin/sh
#
# $FreeBSD$
#

# PROVIDE: iscsi
# REQUIRE: NETWORKING
# BEFORE: mountcritremote
# KEYWORD: shutdown

. /etc/rc.subr

name="iscsi"
start_cmd="iscsi_start"
stop_cmd="iscsi_stop"
rcvar="iscsi_enable"
required_modules="iscsi_initiator:iscsi"

iscsi_start()
{
        ${iscsi_command} -c ${iscsi_config} -n ${iscsi_nickname}
        if [ -f ${iscsi_fstab} ]; then
                local _devs
                local _xdev
                _devs=`sed -e '/^#/d' < ${iscsi_fstab} | cut -f 1`
                for _xdev in ${_devs}; do
                        local _i
                        _i=10
                        echo "Wait for ${_xdev}"
                        while [ ${_i} -ne 0 ]; do
                                [ -c ${_xdev} ] && break
                                sleep 1
                                _i=$((${_i}-1))
                        done
                done

                echo "mount -a -F ${iscsi_fstab}"
                mount -a -F ${iscsi_fstab}
        fi
}

iscsi_stop()
{
        if [ -f ${iscsi_fstab} ]; then
                echo "umount -a -F ${iscsi_fstab}"
                umount -a -F ${iscsi_fstab}
        fi
        killall -HUP ${iscsi_command}
}

load_rc_config $name

: ${iscsi_enable="NO"}
: ${iscsi_command="iscontrol"}
: ${iscsi_nickname="target0"}
: ${iscsi_config="/etc/iscsi.conf"}
: ${iscsi_fstab="/etc/iscsi.fstab"}

run_rc_command "$1"
%%%

-- 
wbr,
pluknet


More information about the freebsd-rc mailing list