File targetcli.init of Package targetcli-fb

#!/bin/bash
#
# chkconfig:    345 12 88
# description:  Linux LIO kernel target
#
### BEGIN INIT INFO
# Provides:          iscsi-target
# Required-Start:    $syslog $network $remote_fs
# Required-Stop:     $syslog $network $remote_fs
# Default-Start:     3  5
# Default-Stop:      0 1 2 6
# Short-Description: Linux LIO kernel target
# Description:       Manage the LIO generic SCSI target,
#	present in 3.x Linux kernel versions.
### END INIT INFO

TARGETCLI_BIN=/usr/bin/targetcli
DEFCONFIG=/etc/target/saveconfig.json

if [ -r /etc/rc.status ]
then
  source /etc/rc.status
  START="/sbin/startproc"
  STATUS="/sbin/checkproc"
  SUCCESS="echo \$rc_done"
  FAILURE="echo \$rc_failed"
else
  source /etc/rc.d/init.d/functions
  START="daemon"
  STATUS="status"
  SUCCESS="success; echo"
  FAILURE="failure; echo"
fi

[ -r /etc/sysconfig/targetcli ] && source /etc/sysconfig/targetcli

RETVAL=0

case "$1" in
  start)
    echo -n "Starting LIO kernel target: "
    ${TARGETCLI_BIN} restoreconfig ${CONFIG_FILE:-$DEFCONFIG} > /dev/null 2>&1
    RETVAL=$?
    ;;
  stop)
    echo -n "Stopping LIO kernel target: "
    ${TARGETCLI_BIN} clearconfig confirm=True > /dev/null 2>&1
    RETVAL=$?
    ;;
  restart)
    $0 stop
    $0 start
    unset RETVAL
    ;;
  reload)
    echo -n "Reloading configuration of LIO kernel target: "
    ${TARGETCLI_BIN} restoreconfig ${CONFIG_FILE:-$DEFCONFIG} clear_existing > /dev/null 2>&1
    RETVAL=$?
    ;;
  status)
    echo -n "Status of LIO kernel target: "
    ${TARGETCLI_BIN} status > /dev/null 2>&1
    RETVAL=$?
    ;;
  save)
    echo -n "Saving configuration of LIO kernel target: "
    ${TARGETCLI_BIN} saveconfig ${CONFIG_FILE:-$DEFCONFIG} > /dev/null 2>&1
    RETVAL=$?
    ;;
  *)
    echo "Usage: $0 {start|stop|status|restart|reload|save}"
    exit 1
    ;;
esac
[ -z ${RETVAL} ] && exit
[ ${RETVAL} -eq 0 ] && eval "${SUCCESS}" || eval "${FAILURE}"
exit ${RETVAL}
openSUSE Build Service is sponsored by