#! /bin/bash # # openib-mount @DESCR@ # # Author: Tristan Suerink # # chkconfig: 2345 98 02 # description: @DESCR@ # Source function library. . /etc/init.d/functions start() { /etc/init.d/opensmd stop /etc/init.d/openibd stop sleep 5 /etc/init.d/openibd start sleep 5 # Load Mellanox hardware driver; /etc/init.d/openibd should do this but better safe than sorry. modprobe ib_mthca sleep 5 /etc/init.d/opensmd start sleep 5 echo -n $"Add target:" /usr/sbin/ibsrpdm -d /dev/infiniband/umad1 -c | sed -e "s/\(service_id\)/max_sect=4096,max_cmd_per_lun=4,\1/" > /sys/class/infiniband_srp/srp-mthca0-2/add_target 2>/dev/null& sleep 15 devices=`cd /sys/block; /bin/ls -1d * | grep sd | grep -v sda` if [ "x$devices" == "x" ]; then failure echo /etc/init.d/opensmd stop /etc/init.d/openibd stop echo "No devices detected" exit 1 else success echo fi for device in $devices do /usr/local/sbin/tune-ddn.sh S2A9900 $device done fd=`echo $devices | sed 's/sd/\/dev\/sd/g'` echo -n $"Start software raid:" mdadm --assemble /dev/md0 $fd >/dev/null 2>&1 if [ "x$?" != "x0" ]; then failure echo /etc/init.d/opensmd stop /etc/init.d/openibd stop exit 1 else success echo fi sleep 5 echo -n $"Mounting file system:" mount -a && success #mount -t xfs /dev/md0 /space >/dev/null 2>&1 && success || failure echo } stop() { echo -n $"Unounting file system:" success #umount /space >/dev/null 2>&1 && success || failure echo echo -n $"Stop software raid:" mdadm --stop /dev/md0 >/dev/null 2>&1 && success || failure echo /etc/init.d/opensmd stop /etc/init.d/openibd stop } restart () { stop start } usage () { echo echo "Usage: `basename $0` {start|stop|restart}" echo return 2 } case "$1" in start) start;; stop) stop;; restart) restart;; *) usage;; esac