A set of startup scripts for Gentoo customized by Scott R. Bowe <scottb@sentania...
authorvlnb <vlnb@d57e44dd-8a1f-0410-8b47-8ef2f437770f>
Thu, 25 Feb 2010 14:14:23 +0000 (14:14 +0000)
committervlnb <vlnb@d57e44dd-8a1f-0410-8b47-8ef2f437770f>
Thu, 25 Feb 2010 14:14:23 +0000 (14:14 +0000)
git-svn-id: https://scst.svn.sourceforge.net/svnroot/scst/trunk@1521 d57e44dd-8a1f-0410-8b47-8ef2f437770f

iscsi-scst/etc/initd/initd.gentoo
scstadmin/init.d/qla2x00t.gentoo [new file with mode: 0755]
scstadmin/init.d/scst.gentoo [new file with mode: 0755]

index 65053db..6f6fddb 100644 (file)
@@ -1,7 +1,11 @@
 #!/sbin/runscript
 #
-# Start the iSCSI-SCST Target.
+# System startup script for the SCST iSCSI 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 !
 
 PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin
 MEM_SIZE=1048576
@@ -9,6 +13,7 @@ MEM_SIZE=1048576
 depend()
 {
         use net
+        need scst
 }
 
 configure_memsize()
diff --git a/scstadmin/init.d/qla2x00t.gentoo b/scstadmin/init.d/qla2x00t.gentoo
new file mode 100755 (executable)
index 0000000..bbf36fc
--- /dev/null
@@ -0,0 +1,104 @@
+#!/sbin/runscript
+#
+# Copyright (C) 2008 Mark Buechler <mark.buechler@gmail.com>
+# Copyright (C) 2009 Bart Van Assche <bart.vanassche@gmail.com>
+# 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
+}
diff --git a/scstadmin/init.d/scst.gentoo b/scstadmin/init.d/scst.gentoo
new file mode 100755 (executable)
index 0000000..3efaa13
--- /dev/null
@@ -0,0 +1,172 @@
+#!/sbin/runscript
+#
+# Copyright (C) 2008 Mark Buechler <mark.buechler@gmail.com>
+# Copyright (C) 2009 Bart Van Assche <bart.vanassche@gmail.com>
+# 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"
+               eerror "Do touch $SCST_CFG, and run scstadmin"
+               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 || return $?
+       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 scstadmin -config $SCST_CFG >/dev/null 2>&1; then
+               einfo "SCST config was loaded"
+       else
+               eend $? "SCST config could not be loaded"
+               return $?
+        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
+}