65 lines
1.2 KiB
Bash
65 lines
1.2 KiB
Bash
#!/bin/sh
|
|
#
|
|
# /etc/init.d/tgtd
|
|
#
|
|
### BEGIN INIT INFO
|
|
# Provides: tgtd
|
|
# Required-Start: $remote_fs $network
|
|
# Should-Start:
|
|
# Required-Stop: $remote_fs $network
|
|
# Should-Stop:
|
|
# Default-Start: 3 5
|
|
# Default-Stop:
|
|
# Short-Description: generic storage target daemon
|
|
# Description: Starts and stops the generic storage target subsystem
|
|
### END INIT INFO
|
|
|
|
#
|
|
#
|
|
# pidfile: /var/run/tgtd.pid
|
|
|
|
DAEMON=/usr/sbin/tgtd
|
|
PIDFILE=/var/run/tgtd.pid
|
|
|
|
# Source LSB init functions
|
|
. /etc/rc.status
|
|
|
|
rc_reset
|
|
|
|
PATH=/sbin:/bin:/usr/sbin:/usr/bin
|
|
|
|
case "$1" in
|
|
start)
|
|
echo -n "Starting SCSI target service: "
|
|
modprobe crc32c
|
|
modprobe scsi_tgt
|
|
startproc -p $PIDFILE $DAEMON
|
|
rc_status -v
|
|
;;
|
|
stop)
|
|
echo -n "Stopping SCSI target service: "
|
|
tgtadm --op delete >/dev/null 2>/dev/null
|
|
killproc -p $PIDFILE -TERM $DAEMON
|
|
modprobe -r scsi_tgt 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 SCSI target service"
|
|
checkproc -p $PIDFILE $DAEMON
|
|
rc_status -v
|
|
;;
|
|
*)
|
|
echo $"Usage: $0 {start|stop|restart|status}"
|
|
exit 1
|
|
esac
|
|
rc_exit
|