File iscsitarget.init of Package iscsitarget

#!/bin/sh
#
# /etc/init.d/iscsitarget
#
### BEGIN INIT INFO
# Provides:          iscsitarget
# Required-Start:    $remote_fs $network
# Should-Start:
# Required-Stop:     $remote_fs $network
# Should-Stop:
# Default-Start:     3 5
# Default-Stop:      
# Short-Description: Starts and stops the iSCSI target daemon
# Description:
# Script to start and stop the iSCSI target daemon
### END INIT INFO

#
#
# pidfile: /var/run/ietd.pid
# config:  /etc/ietd.conf

DAEMON=/usr/sbin/ietd
PIDFILE=/var/run/iscsi_trgt.pid
CONFIG=/etc/ietd.conf

# Source LSB init functions
. /etc/rc.status

rc_reset

PATH=/sbin:/bin:/usr/sbin:/usr/bin
MEM_SIZE=1048576

configure_memsize()
{
    if [ -e /proc/sys/net/core/wmem_max ]; then
        echo ${MEM_SIZE} > /proc/sys/net/core/wmem_max
    fi

    if [ -e /proc/sys/net/core/rmem_max ]; then
        echo ${MEM_SIZE} > /proc/sys/net/core/rmem_max
    fi

    if [ -e /proc/sys/net/core/wmem_default ]; then
        echo ${MEM_SIZE} > /proc/sys/net/core/wmem_default
    fi

    if [ -e /proc/sys/net/core/rmem_default ]; then
        echo ${MEM_SIZE} > /proc/sys/net/core/rmem_default
    fi

    if [ -e /proc/sys/net/ipv4/tcp_mem ]; then
        echo "${MEM_SIZE} ${MEM_SIZE} ${MEM_SIZE}" > /proc/sys/net/ipv4/tcp_mem
    fi

    if [ -e  /proc/sys/net/ipv4/tcp_rmem ]; then
        echo "${MEM_SIZE} ${MEM_SIZE} ${MEM_SIZE}" > /proc/sys/net/ipv4/tcp_rmem
    fi

    if [ -e /proc/sys/net/ipv4/tcp_wmem ]; then
        echo "${MEM_SIZE} ${MEM_SIZE} ${MEM_SIZE}" > /proc/sys/net/ipv4/tcp_wmem
    fi
}

case "$1" in
  start)
	echo -n "Starting iSCSI target service: "
	configure_memsize
	modprobe -q crc32c
	modprobe iscsi_trgt
	startproc -p $PIDFILE $DAEMON
	rc_status -v
        ;;
  stop)
	echo -n "Stopping iSCSI target service: "
	ietadm --op delete >/dev/null 2>/dev/null
	killproc -p $PIDFILE -TERM $DAEMON
	modprobe -r iscsi_trgt 2>/dev/null
	RETVAL=$?
	modprobe -r crc32c 2>/dev/null
	if [ $RETVAL != "0" ]; then
		rc_failed
	fi
	rc_status -v
        ;;
  restart|reload)
        $0 stop
        $0 start
        ;;
  status)
	echo -n "Checking for iSCSI target service"
	checkproc -p $PIDFILE $DAEMON
	rc_status -v
        ;;
  *)
        echo $"Usage: $0 {start|stop|restart|status}"
        exit 1
esac
rc_exit
openSUSE Build Service is sponsored by