mirror of
https://github.com/SCST-project/scst.git
synced 2026-09-16 13:04:21 +00:00
Merge scstadmin from trunk. Hence add support for saving and restoring the ALUA state, unify the qla2x00t/iSCSI-SCST and SCST init scripts, compute the SCST handler kernel module list from /etc/scst.conf and add man pages for scstadmin, /etc/scst.conf and /etc/default/scst. (svn merge -r3389:3982 https://scst.svn.sourceforge.net/svnroot/scst/trunk/scstadmin/Makefile Makefile)
git-svn-id: http://svn.code.sf.net/p/scst/svn/branches/2.2.0.x@3983 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
@@ -1,2 +0,0 @@
|
||||
These init scripts are intended for use with non-iscsi configurations. For
|
||||
iscsi, please use one of the init scripts found in iscsi-scst/etc/initd.
|
||||
@@ -1,122 +0,0 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Copyright (C) 2008 Mark Buechler <mark.buechler@gmail.com>
|
||||
# Copyright (C) 2009 Bart Van Assche <bvanassche@acm.org>
|
||||
# This software is made available under the GPLv2 license.
|
||||
#
|
||||
# System startup script for the QLogic 22xx/23xx card target driver.
|
||||
#
|
||||
# Note: on most Linux distributions /bin/sh is a soft link to /bin/bash, while
|
||||
# on a default Ubuntu setup /bin/sh is a soft link to /bin/dash !
|
||||
#
|
||||
# See also:
|
||||
# * http://refspecs.freestandards.org/LSB_3.1.0/LSB-Core-generic/LSB-Core-generic/iniscrptact.html
|
||||
# * http://www.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html
|
||||
#
|
||||
### BEGIN INIT INFO
|
||||
# Provides: qla2x00t
|
||||
# Required-Start: $syslog $local_fs scst
|
||||
# Required-Stop: $syslog $local_fs scst
|
||||
# Default-Start: 2 3 4 5
|
||||
# Default-Stop: 0 1 6
|
||||
# Description: QLogic 22xx/23xx card target driver
|
||||
### END INIT INFO
|
||||
### BEGIN CHKCONFIG INFO
|
||||
# chkconfig: 2345 14 86
|
||||
# description: QLogic 22xx/23xx card target driver
|
||||
### END CHKCONFIG IFO
|
||||
|
||||
PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/sbin:/usr/local/bin
|
||||
|
||||
# Modules to load/unload.
|
||||
KERNEL_MODULES="qla2x00tgt"
|
||||
|
||||
# Return values according to LSB for all commands but status:
|
||||
# 0 - success
|
||||
# 1 - generic or unspecified error
|
||||
# 2 - invalid or excess argument(s)
|
||||
# 3 - unimplemented feature (e.g. "reload")
|
||||
# 4 - insufficient privilege
|
||||
# 5 - program is not installed
|
||||
# 6 - program is not configured
|
||||
# 7 - program is not running
|
||||
#
|
||||
|
||||
. /lib/lsb/init-functions
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
## Start the service.
|
||||
echo -n "Loading and configuring the QLogic target driver"
|
||||
|
||||
for module in ${KERNEL_MODULES}; do
|
||||
if ! modprobe "${module}"; then
|
||||
log_failure_msg
|
||||
exit 5
|
||||
fi
|
||||
done
|
||||
;;
|
||||
stop)
|
||||
## Stop the service.
|
||||
echo -n "Stopping the QLogic target driver"
|
||||
|
||||
reverse_list=""
|
||||
for module in ${KERNEL_MODULES}; do
|
||||
reverse_list="${module} ${reverse_list}"
|
||||
done
|
||||
for module in ${reverse_list}; do
|
||||
if [ -e "/sys/module/${module}" ] && ! rmmod "${module}"; then
|
||||
log_failure_msg FAILED
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
log_success_msg
|
||||
;;
|
||||
restart)
|
||||
## Stop and restart the service if the service is already running,
|
||||
## otherwise start the service.
|
||||
$0 stop
|
||||
$0 start
|
||||
;;
|
||||
try-restart)
|
||||
## Restart the service if the service is already running.
|
||||
$0 status >/dev/null && $0 restart
|
||||
;;
|
||||
reload)
|
||||
## Cause the configuration of the service to be reloaded without
|
||||
## actually stopping and restarting the service.
|
||||
echo -n "Reloading QLogic target driver configuration"
|
||||
log_success_msg
|
||||
;;
|
||||
force-reload)
|
||||
## Cause the configuration to be reloaded if the service supports this,
|
||||
## otherwise restart the service if it is running.
|
||||
echo -n "Reloading QLogic target driver configuration"
|
||||
log_success_msg
|
||||
;;
|
||||
status)
|
||||
## Print the current status of the service.
|
||||
echo -n "QLogic target driver status: "
|
||||
|
||||
# Status has a slightly different meaning for the status command:
|
||||
# 0 - service running
|
||||
# 1 - service dead, but /var/run/ pid file exists
|
||||
# 2 - service dead, but /var/lock/ lock file exists
|
||||
# 3 - service not running
|
||||
|
||||
for module in ${KERNEL_MODULES}; do
|
||||
if [ ! -e "/sys/module/${module}" ]; then
|
||||
echo "Not loaded"
|
||||
exit 3
|
||||
fi
|
||||
done
|
||||
echo "OK"
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload}"
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
|
||||
exit 0
|
||||
@@ -1,104 +0,0 @@
|
||||
#!/sbin/runscript
|
||||
#
|
||||
# Copyright (C) 2008 Mark Buechler <mark.buechler@gmail.com>
|
||||
# Copyright (C) 2009 Bart Van Assche <bvanassche@acm.org>
|
||||
# Copyright (C) 2010 Scott Bowe <scottb@sentania.net>
|
||||
# This software is made available under the GPLv2 license.
|
||||
#
|
||||
# System startup script for the QLogic 22xx/23xx card target driver.
|
||||
#
|
||||
# Customized for Gentoo Linux by Scott Bowe
|
||||
#
|
||||
# Note: on most Linux distributions /bin/sh is a soft link to /bin/bash, while
|
||||
# on a default Ubuntu setup /bin/sh is a soft link to /bin/dash !
|
||||
#
|
||||
|
||||
opts="${opts} try-restart "
|
||||
depend() {
|
||||
use logger localmount
|
||||
before scst
|
||||
}
|
||||
PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/sbin:/usr/local/bin
|
||||
|
||||
# Modules to load/unload.
|
||||
KERNEL_MODULES="qla2x00tgt"
|
||||
MODPROBE="/sbin/modprobe"
|
||||
RMMOD="/sbin/rmmod"
|
||||
|
||||
# Return values according to LSB for all commands but status:
|
||||
# 0 - success
|
||||
# 1 - generic or unspecified error
|
||||
# 2 - invalid or excess argument(s)
|
||||
# 3 - unimplemented feature (e.g. "reload")
|
||||
# 4 - insufficient privilege
|
||||
# 5 - program is not installed
|
||||
# 6 - program is not configured
|
||||
# 7 - program is not running
|
||||
#
|
||||
start(){
|
||||
## Start the service.
|
||||
ebegin "Loading and configuring the QLogic target driver"
|
||||
eindent
|
||||
ret=0
|
||||
for module in ${KERNEL_MODULES}; do
|
||||
einfo "Loading ${module}"
|
||||
if ! modprobe "${module}"; then
|
||||
ret=5
|
||||
eend $ret "Failed to load target driver"
|
||||
return $ret
|
||||
fi
|
||||
done
|
||||
einfo "Qlogic target driver loaded!!!"
|
||||
eend $?
|
||||
return $?
|
||||
}
|
||||
|
||||
stop() {
|
||||
## Stop the service.
|
||||
ebegin "Stopping the QLogic target driver"
|
||||
eindent
|
||||
reverse_list=""
|
||||
for module in ${KERNEL_MODULES}; do
|
||||
reverse_list="${module} ${reverse_list}"
|
||||
done
|
||||
for module in ${reverse_list}; do
|
||||
einfo "Unloading module"
|
||||
if [ -e "/sys/module/${module}" ] && ! rmmod "${module}"; then
|
||||
$eend $? "Failed to unload the target driver"
|
||||
return $?
|
||||
fi
|
||||
done
|
||||
einfo "Qlogic target driver unloaded!!!"
|
||||
eend $?
|
||||
return $?
|
||||
}
|
||||
|
||||
restart() {
|
||||
## Stop and restart the service if the service is already running,
|
||||
## otherwise start the service.
|
||||
stop
|
||||
start
|
||||
}
|
||||
|
||||
try-restart() {
|
||||
## Restart the service if the service is already running.
|
||||
status >/dev/null 2>&1 && restart
|
||||
}
|
||||
|
||||
status() {
|
||||
einfo "Qlogic target status: "
|
||||
eindent
|
||||
|
||||
for module in ${SCST_MODULES}; do
|
||||
if [ ! -e "/sys/module/${module}" ]; then
|
||||
einfo "${module} not loaded"
|
||||
ret=3
|
||||
eend $ret
|
||||
return $ret
|
||||
fi
|
||||
done
|
||||
ret=0
|
||||
ebegin "Qlogic target loaded OK"
|
||||
eend $ret
|
||||
return $ret
|
||||
}
|
||||
+304
-93
@@ -1,43 +1,46 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# A script that generates the /etc/init.d/scst script. On systems that support
|
||||
# the LSB an LSB compliant init script is generated. On Gentoo systems a Gentoo
|
||||
# init script is generated. And on Slackware the LSB init script is used with
|
||||
# replacements for the used LSB functions.
|
||||
|
||||
if [ -e /etc/gentoo-release ]; then
|
||||
echo "#!/sbin/runscript"
|
||||
else
|
||||
echo "#!/bin/sh"
|
||||
fi
|
||||
|
||||
cat <<"EOF"
|
||||
#
|
||||
# Copyright (C) 2008 Mark Buechler <mark.buechler@gmail.com>
|
||||
# Copyright (C) 2009 Bart Van Assche <bvanassche@acm.org>
|
||||
# Copyright (C) 2009-2011 Bart Van Assche <bvanassche@acm.org>
|
||||
# This software is made available under the GPLv2 license.
|
||||
#
|
||||
# System startup script for the SCST core functionality.
|
||||
#
|
||||
# Note: on most Linux distributions /bin/sh is a soft link to /bin/bash, while
|
||||
# on a default Ubuntu setup /bin/sh is a soft link to /bin/dash !
|
||||
# System startup script for SCST.
|
||||
#
|
||||
# See also:
|
||||
# * http://refspecs.freestandards.org/LSB_3.1.0/LSB-Core-generic/LSB-Core-generic/iniscrptact.html
|
||||
# * http://refspecs.freestandards.org/LSB_4.1.0/LSB-Core-generic/LSB-Core-generic/iniscrptact.html
|
||||
# * http://www.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html
|
||||
#
|
||||
EOF
|
||||
|
||||
if [ ! -e /etc/gentoo-release ]; then
|
||||
cat <<"EOF"
|
||||
### BEGIN INIT INFO
|
||||
# Provides: scst
|
||||
# Required-Start: $syslog $local_fs
|
||||
# Required-Stop: $syslog $local_fs
|
||||
# Required-Start: $syslog $local_fs $network
|
||||
# Required-Stop: $syslog $local_fs $network
|
||||
# Default-Start: 2 3 4 5
|
||||
# Default-Stop: 0 1 6
|
||||
# Description: SCST core
|
||||
# Description: SCST - A Generic SCSI Target Subsystem
|
||||
### END INIT INFO
|
||||
### BEGIN CHKCONFIG INFO
|
||||
# chkconfig: 2345 13 87
|
||||
# description: SCST core
|
||||
### END CHKCONFIG IFO
|
||||
# description: SCST - A Generic SCSI Target Subsystem
|
||||
### END CHKCONFIG INFO
|
||||
|
||||
PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/sbin:/usr/local/bin
|
||||
SCST_CFG=/etc/scst.conf
|
||||
|
||||
# Modules to load/unload.
|
||||
#
|
||||
# !!! DON'T ADD HERE TARGET DRIVERS, WHICH IMMEDIATELLY START ACCEPTING
|
||||
# !!! NEW CONNECTIONS, BECAUSE AT THIS POINT ACCESS CONTROL HASN'T CONFIGURED
|
||||
# !!! YET!
|
||||
#
|
||||
SCST_MODULES="scst scst_disk scst_vdisk"
|
||||
|
||||
# Return values according to LSB for all commands but status:
|
||||
# Return values according to LSB for all commands except status:
|
||||
# 0 - success
|
||||
# 1 - generic or unspecified error
|
||||
# 2 - invalid or excess argument(s)
|
||||
@@ -48,99 +51,276 @@ SCST_MODULES="scst scst_disk scst_vdisk"
|
||||
# 7 - program is not running
|
||||
#
|
||||
|
||||
if [ -e /lib/lsb/init-functions ]; then
|
||||
# Debian, RHEL / Fedora, SLES / openSUSE.
|
||||
. /lib/lsb/init-functions
|
||||
else
|
||||
# Slackware.
|
||||
log_success_msg() {
|
||||
echo "$@"
|
||||
}
|
||||
log_failure_msg() {
|
||||
echo "$@"
|
||||
}
|
||||
fi
|
||||
|
||||
PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/sbin:/usr/local/bin
|
||||
SCST_DFLT=/etc/default/scst
|
||||
|
||||
[ -x "$(which scstadmin)" ] || exit 5
|
||||
|
||||
. /lib/lsb/init-functions
|
||||
if [ -f $SCST_DFLT ]; then
|
||||
. $SCST_DFLT
|
||||
fi
|
||||
EOF
|
||||
fi
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
## Start the service.
|
||||
echo -n "Loading and configuring the mid-level SCSI target SCST"
|
||||
cat <<"EOF"
|
||||
|
||||
for module in ${SCST_MODULES}; do
|
||||
if ! modprobe "${module}"; then
|
||||
log_failure_msg
|
||||
exit 5
|
||||
SCST_CFG=/etc/scst.conf
|
||||
|
||||
if [ ! -e /lib/lsb/init-functions ]; then
|
||||
# Slackware / Gentoo.
|
||||
start_daemon() {
|
||||
"$@" >/dev/null 2>&1 &
|
||||
}
|
||||
killproc() {
|
||||
local exe="`basename "$1"`"
|
||||
killall $exe
|
||||
rm -f "/var/run/$exe.pid"
|
||||
}
|
||||
fi
|
||||
|
||||
# Whether or not there is a "TARGET_DRIVER iscsi" section in scst.conf.
|
||||
using_iscsi() {
|
||||
for m in $SCST_MODULES; do
|
||||
if [ $m = "iscsi_scst" ]; then
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
# Parse scst.conf and assign the list of associated kernel modules to
|
||||
# SCST_MODULES.
|
||||
parse_scst_conf() {
|
||||
SCST_MODULES="scst"
|
||||
SCST_OPT_MODULES=""
|
||||
SCST_DAEMONS=""
|
||||
if [ ! -e $SCST_CFG ]; then
|
||||
return 0
|
||||
fi
|
||||
local nonblanks="[^ ]\{1,\}"
|
||||
local blanks="[ ]\{1,\}"
|
||||
SCST_MODULES="$SCST_MODULES `sed -n -e 's/^HANDLER'"$blanks"'\('"$nonblanks"'\)'"$blanks"'{$/\1/p' \
|
||||
-e 's/^\[HANDLER'"$blanks"'\('"$nonblanks"'\)\]$/\1/p' $SCST_CFG \
|
||||
| while read h; do
|
||||
case "$h" in
|
||||
dev_cdrom) echo scst_cdrom;;
|
||||
dev_changer) echo scst_changer;;
|
||||
dev_disk*) echo scst_disk;;
|
||||
dev_modisk*) echo scst_modisk;;
|
||||
dev_processor) echo scst_processor;;
|
||||
dev_raid) echo scst_raid;;
|
||||
dev_tape*) echo scst_tape;;
|
||||
dev_user) echo scst_user;;
|
||||
vdisk*|vcdrom) echo scst_vdisk;;
|
||||
*) echo "$h";;
|
||||
esac
|
||||
done | sort -u` \
|
||||
`sed -n 's/^TARGET_DRIVER'"$blanks"'\('"$nonblanks"'\)'"$blanks"'{$/\1/p' $SCST_CFG | while read d; do
|
||||
case "$d" in
|
||||
iscsi) echo iscsi_scst;;
|
||||
qla2x00t) echo qla2x00tgt;;
|
||||
*) echo "$d";;
|
||||
esac
|
||||
done | sort -u` \
|
||||
$SCST_TARGET_MODULES"
|
||||
if using_iscsi; then
|
||||
case "`uname -m`" in
|
||||
x86_64|i686)
|
||||
SCST_OPT_MODULES="crc32c-intel $SCST_OPT_MODULES";;
|
||||
esac
|
||||
SCST_OPT_MODULES="crc32c $SCST_OPT_MODULES"
|
||||
SCST_DAEMONS="/usr/local/sbin/iscsi-scstd $SCST_DAEMONS"
|
||||
fi
|
||||
}
|
||||
|
||||
# Unload SCST. parse_scst_conf must already have been invoked.
|
||||
unload_scst() {
|
||||
for d in $SCST_DAEMONS; do
|
||||
killproc $d
|
||||
done
|
||||
|
||||
reverse_list=""
|
||||
for m in $SCST_MODULES; do
|
||||
reverse_list="$m $reverse_list"
|
||||
done
|
||||
for m in $reverse_list; do
|
||||
refcnt="`cat /sys/module/$m/refcnt 2>/dev/null`"
|
||||
if [ ! -z "$refcnt" ] && [ "$refcnt" -gt 0 ]; then
|
||||
# Apparently it can happen that the iscsi_scst refcnt is only
|
||||
# decremented a short time after killproc finished. If that
|
||||
# occurs, sleep for a short time.
|
||||
sleep 1
|
||||
fi
|
||||
if [ -e /sys/module/$m/refcnt ] && ! rmmod $m; then
|
||||
return 1
|
||||
fi
|
||||
done
|
||||
for m in $SCST_OPT_MODULES; do
|
||||
reverse_list="$m $reverse_list"
|
||||
done
|
||||
for m in $reverse_list; do
|
||||
rmmod $m >/dev/null 2>&1
|
||||
done
|
||||
|
||||
# Clear the config in case unloading failed or SCST has been built into the
|
||||
# kernel
|
||||
if [ -e /sys/module/scst ]; then
|
||||
scstadmin -noprompt -force -clear_config >/dev/null 2>&1
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
start_scst() {
|
||||
if [ -e /sys/module/scst -a -e /sys/module/scst/refcnt ]; then
|
||||
echo Already started
|
||||
return 1
|
||||
fi
|
||||
|
||||
parse_scst_conf
|
||||
|
||||
for m in $SCST_OPT_MODULES; do
|
||||
modprobe $m >/dev/null 2>&1
|
||||
done
|
||||
|
||||
for m in $SCST_MODULES; do
|
||||
if [ ! -e /sys/module/$m ]; then
|
||||
if ! modprobe $m; then
|
||||
echo modprobe $m failed.
|
||||
unload_scst
|
||||
return 5
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
for d in $SCST_DAEMONS; do
|
||||
if ! start_daemon $d; then
|
||||
echo "Starting $d failed"
|
||||
unload_scst
|
||||
return 1
|
||||
fi
|
||||
done
|
||||
|
||||
if [ -f $SCST_CFG ]; then
|
||||
if scstadmin -config $SCST_CFG >/dev/null 2>&1; then
|
||||
log_success_msg
|
||||
scstadmin -force -noprompt -clear_config >/dev/null 2>&1
|
||||
tmpout=/tmp/scstadmin-output-$$
|
||||
if scstadmin -config $SCST_CFG >$tmpout 2>&1; then
|
||||
rm -f $tmpout
|
||||
return 0
|
||||
else
|
||||
log_failure_msg
|
||||
exit 1
|
||||
cat $tmpout
|
||||
rm -f $tmpout
|
||||
unload_scst
|
||||
return 1
|
||||
fi
|
||||
else
|
||||
log_success_msg
|
||||
echo "SCST configuration file $SCST_CFG missing"
|
||||
return 0
|
||||
fi
|
||||
;;
|
||||
stop)
|
||||
## Stop the service.
|
||||
echo -n "Stopping the mid-level SCSI target SCST"
|
||||
}
|
||||
|
||||
reverse_list=""
|
||||
for module in ${SCST_MODULES}; do
|
||||
reverse_list="${module} ${reverse_list}"
|
||||
done
|
||||
for module in ${reverse_list}; do
|
||||
if [ -e "/sys/module/${module}" ] && ! rmmod "${module}"; then
|
||||
log_failure_msg FAILED
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
log_success_msg
|
||||
;;
|
||||
restart)
|
||||
## Stop and restart the service if the service is already running,
|
||||
## otherwise start the service.
|
||||
$0 stop
|
||||
$0 start
|
||||
;;
|
||||
try-restart)
|
||||
## Restart the service if the service is already running.
|
||||
$0 status >/dev/null 2>&1 && $0 restart
|
||||
;;
|
||||
reload)
|
||||
## Cause the configuration of the service to be reloaded without
|
||||
## actually stopping and restarting the service.
|
||||
echo -n "Reloading SCST configuration"
|
||||
if scstadmin -config $SCST_CFG >/dev/null 2>&1; then
|
||||
log_success_msg
|
||||
else
|
||||
log_failure_msg
|
||||
exit 1
|
||||
stop_scst() {
|
||||
if ! parse_scst_conf; then
|
||||
return 1
|
||||
fi
|
||||
;;
|
||||
force-reload)
|
||||
## Cause the configuration to be reloaded if the service supports this,
|
||||
## otherwise restart the service if it is running.
|
||||
echo -n "Reloading SCST configuration"
|
||||
if scstadmin -config $SCST_CFG >/dev/null 2>&1; then
|
||||
log_success_msg
|
||||
else
|
||||
$0 restart
|
||||
fi
|
||||
;;
|
||||
status)
|
||||
## Print the current status of the service.
|
||||
echo -n "SCST status: "
|
||||
|
||||
unload_scst
|
||||
}
|
||||
|
||||
scst_status() {
|
||||
# Status has a slightly different meaning for the status command:
|
||||
# 0 - service running
|
||||
# 1 - service dead, but /var/run/ pid file exists
|
||||
# 2 - service dead, but /var/lock/ lock file exists
|
||||
# 3 - service not running
|
||||
|
||||
for module in ${SCST_MODULES}; do
|
||||
if [ ! -e "/sys/module/${module}" ]; then
|
||||
echo "Not loaded"
|
||||
exit 3
|
||||
parse_scst_conf
|
||||
|
||||
for m in $SCST_MODULES; do
|
||||
if [ ! -e /sys/module/$m ]; then
|
||||
echo "$m: not loaded"
|
||||
return 3
|
||||
fi
|
||||
done
|
||||
echo "OK"
|
||||
return 0
|
||||
}
|
||||
|
||||
EOF
|
||||
|
||||
if [ ! -e /etc/gentoo-release ]; then
|
||||
cat <<"EOF"
|
||||
rc=0
|
||||
case "$1" in
|
||||
start)
|
||||
## Start the service.
|
||||
echo -n "Loading and configuring SCST"
|
||||
start_scst
|
||||
rc=$?
|
||||
;;
|
||||
stop)
|
||||
## Stop the service.
|
||||
echo -n "Stopping SCST"
|
||||
stop_scst
|
||||
rc=$?
|
||||
;;
|
||||
restart)
|
||||
## Stop and restart the service if the service is already running,
|
||||
## otherwise start the service.
|
||||
echo -n "Restarting SCST"
|
||||
stop_scst && start_scst
|
||||
rc=$?
|
||||
;;
|
||||
try-restart)
|
||||
## Restart the service if the service is already running.
|
||||
echo -n "Trying to restart SCST"
|
||||
scst_status >/dev/null 2>&1 && stop_scst && start_scst
|
||||
rc=$?
|
||||
;;
|
||||
reload)
|
||||
## Cause the configuration of the service to be reloaded without
|
||||
## actually stopping and restarting the service.
|
||||
echo -n "Reloading SCST configuration"
|
||||
if scstadmin -config $SCST_CFG >/dev/null 2>&1; then
|
||||
rc=0
|
||||
else
|
||||
rc=1
|
||||
fi
|
||||
;;
|
||||
force-reload)
|
||||
## Cause the configuration to be reloaded if the service supports this,
|
||||
## otherwise restart the service if it is running.
|
||||
echo -n "Reloading SCST configuration"
|
||||
if scstadmin -config $SCST_CFG >/dev/null 2>&1; then
|
||||
rc=0
|
||||
else
|
||||
stop_scst && start_scst
|
||||
rc=$?
|
||||
fi
|
||||
;;
|
||||
status)
|
||||
## Print the current status of the service.
|
||||
echo -n "SCST status: "
|
||||
scst_status
|
||||
rc=$?
|
||||
if [ $rc = 0 ]; then
|
||||
echo "OK"
|
||||
else
|
||||
echo "Not running"
|
||||
fi
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload}"
|
||||
@@ -148,4 +328,35 @@ case "$1" in
|
||||
;;
|
||||
esac
|
||||
|
||||
exit 0
|
||||
if [ $rc = 0 ]; then
|
||||
log_success_msg
|
||||
else
|
||||
log_failure_msg
|
||||
fi
|
||||
|
||||
exit $rc
|
||||
EOF
|
||||
else
|
||||
cat <<"EOF"
|
||||
depend() {
|
||||
need localmount
|
||||
need net
|
||||
}
|
||||
|
||||
checkconfig() {
|
||||
true
|
||||
}
|
||||
|
||||
start() {
|
||||
ebegin "Starting SCST"
|
||||
start_scst
|
||||
eend $?
|
||||
}
|
||||
|
||||
stop() {
|
||||
ebegin "Stopping SCST"
|
||||
stop_scst
|
||||
eend $?
|
||||
}
|
||||
EOF
|
||||
fi
|
||||
|
||||
@@ -1,176 +0,0 @@
|
||||
#!/sbin/runscript
|
||||
#
|
||||
# Copyright (C) 2008 Mark Buechler <mark.buechler@gmail.com>
|
||||
# Copyright (C) 2009 Bart Van Assche <bvanassche@acm.org>
|
||||
# Copyright (C) 2010 Scott Bowe <scottb@sentania.net>
|
||||
# This software is made available under the GPLv2 license.
|
||||
#
|
||||
# System startup script for the SCST core functionality.
|
||||
#
|
||||
# Customized for gentoo linux by Scott Bowe.
|
||||
#
|
||||
# Note: on most Linux distributions /bin/sh is a soft link to /bin/bash, while
|
||||
# on a default Ubuntu setup /bin/sh is a soft link to /bin/dash !
|
||||
|
||||
opts="${opts} try-restart reload force-reload"
|
||||
depend() {
|
||||
use logger
|
||||
}
|
||||
|
||||
PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/sbin:/usr/local/bin
|
||||
|
||||
DEFAULTFILE="/etc/conf.d/scst"
|
||||
SCST_CFG=/etc/scst.conf
|
||||
MODPROBE="/sbin/modprobe"
|
||||
RMMOD="/sbin/rmmod"
|
||||
|
||||
if [ -f $DEFAULTFILE ]; then
|
||||
. $DEFAULTFILE
|
||||
fi
|
||||
|
||||
# Modules to load/unload.
|
||||
#
|
||||
# !!! DON'T ADD HERE TARGET DRIVERS, WHICH IMMEDIATELLY START ACCEPTING
|
||||
# !!! NEW CONNECTIONS, BECAUSE AT THIS POINT ACCESS CONTROL HASN'T CONFIGURED
|
||||
# !!! YET!
|
||||
#
|
||||
SCST_MODULES="scst scst_disk scst_vdisk"
|
||||
|
||||
# Return values according to LSB for all commands but status:
|
||||
# 0 - success
|
||||
# 1 - generic or unspecified error
|
||||
# 2 - invalid or excess argument(s)
|
||||
# 3 - unimplemented feature (e.g. "reload")
|
||||
# 4 - insufficient privilege
|
||||
# 5 - program is not installed
|
||||
# 6 - program is not configured
|
||||
# 7 - program is not running
|
||||
#
|
||||
|
||||
checkconfig() {
|
||||
if [ ! -f $SCST_CFG ] ; then
|
||||
eerror "Please create $SCST_CFG"
|
||||
return 1
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
checkinstall() {
|
||||
if [ ! -x `which scstadmin` ] ; then
|
||||
eerror "scstadmin is not intalled"
|
||||
return 1
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
start() {
|
||||
ebegin "Loading and configuring the mid-level SCSI target SCST"
|
||||
eindent
|
||||
checkconfig
|
||||
checkinstall || return $?
|
||||
ret=0
|
||||
for module in ${SCST_MODULES}; do
|
||||
einfo "Loading SCST module ${module}..."
|
||||
if ! modprobe "${module}"; then
|
||||
eerror "${module} failed to load"
|
||||
eend $? "Failed to load SCST"
|
||||
return $?
|
||||
fi
|
||||
done
|
||||
einfo "Configuring SCST..."
|
||||
eindent
|
||||
if [ -f $SCST_CFG ]; then
|
||||
if scstadmin -config $SCST_CFG >/dev/null 2>&1; then
|
||||
einfo "SCST config was loaded"
|
||||
else
|
||||
eend $? "SCST config could not be loaded"
|
||||
return $?
|
||||
fi
|
||||
else
|
||||
einfo "SCST configuration file $SCST_CFG missing, skipping"
|
||||
return 0
|
||||
fi
|
||||
eoutdent
|
||||
eoutdent
|
||||
einfo "SCST loaded!!!"
|
||||
eend $?
|
||||
}
|
||||
|
||||
stop() {
|
||||
## Stop the service.
|
||||
ebegin "Stopping the mid-level SCSI target SCST"
|
||||
eindent
|
||||
reverse_list=""
|
||||
for module in ${SCST_MODULES}; do
|
||||
reverse_list="${module} ${reverse_list}"
|
||||
done
|
||||
for module in ${reverse_list}; do
|
||||
einfo "Unloading ${module}"
|
||||
if [ -e "/sys/module/${module}" ] && ! rmmod "${module}"; then
|
||||
eindent
|
||||
eend $? "Failed to unload ${module}"
|
||||
return $?
|
||||
fi
|
||||
done
|
||||
eoutdent
|
||||
einfo "SCST unloaded!!!"
|
||||
eend $?
|
||||
}
|
||||
|
||||
restart() {
|
||||
## Stop and restart the service if the service is already running,
|
||||
## otherwise start the service.
|
||||
stop
|
||||
sleep 3
|
||||
start
|
||||
}
|
||||
|
||||
try-restart() {
|
||||
## Restart the service if the service is already running.
|
||||
status >/dev/null 2>&1 && restart
|
||||
}
|
||||
|
||||
reload() {
|
||||
## Cause the configuration of the service to be reloaded without
|
||||
## actually stopping and restarting the service.
|
||||
einfo "Reloading SCST configuration"
|
||||
eindent
|
||||
if scstadmin -config $SCST_CFG >/dev/null 2>&1; then
|
||||
ret=0
|
||||
ebegin "SCST config reloaded"
|
||||
else
|
||||
eend $? "SCST config could not be releaded"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
force-reload() {
|
||||
## Cause the configuration to be reloaded if the service supports this,
|
||||
## otherwise restart the service if it is running.
|
||||
einfo "Reloading SCST configuration"
|
||||
eindent
|
||||
if scstadmin -config $SCST_CFG >/dev/null 2>&1; then
|
||||
ret=0
|
||||
ebegin "SCST config reloaded"
|
||||
else
|
||||
restart
|
||||
fi
|
||||
}
|
||||
|
||||
status() {
|
||||
## Print the current status of the service.
|
||||
einfo "SCST status: "
|
||||
eindent
|
||||
|
||||
for module in ${SCST_MODULES}; do
|
||||
if [ ! -e "/sys/module/${module}" ]; then
|
||||
einfo "${module} not loaded"
|
||||
ret=3
|
||||
eend $ret
|
||||
return $ret
|
||||
fi
|
||||
done
|
||||
ret=0
|
||||
ebegin "SCST modules loaded OK"
|
||||
eend $ret
|
||||
}
|
||||
Reference in New Issue
Block a user