File: srptools-boot.init

package info (click to toggle)
srptools 1.0.2-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 608 kB
  • ctags: 610
  • sloc: ansic: 3,163; sh: 1,528; makefile: 76
file content (82 lines) | stat: -rw-r--r-- 1,449 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/bin/bash
### BEGIN INIT INFO
# Provides:          srptools-boot
# Required-Start:    $remote_fs    
# Required-Stop:     
# Default-Start:     S
# Default-Stop:      
# Short-Description: Onetime Discovery of  SRP scsi targets.
# Description:       Discovers SRP scsi over infiniband targets during boot.
### END INIT INFO

[ -x /usr/sbin/srp_daemon ] || exit 0

IBDIR=/sys/class/infiniband

PORTS=""
RETRIES=""
LOG=""

[ -f /etc/default/srptools ] &&  . /etc/default/srptools

start_daemon () {

if [ "$PORTS" = "NONE" ] ; then
echo "srptools disabled."
exit 0
fi

echo -n "Waiting for fabric to settle..."
sleep 1
echo "done"

if [ "$PORTS" = "ALL" ]  ; then
    for HCA_ID in `/bin/ls -1 ${IBDIR}`
      do
      for PORT in `/bin/ls -1 ${IBDIR}/${HCA_ID}/ports/`
        do
	run_daemon
      done
    done
fi


for ADAPTER in $PORTS ; do
    HCA_ID=`echo $ADAPTER | awk -F: '{print $1}'`
    PORT=`echo $ADAPTER | awk -F:  '{print $2}'`
    run_daemon
done
}


run_daemon() {
# SRP deamon wedges if we start it on a port which is not up

	STATUS=`/usr/sbin/ibstat $HCA_ID $PORT | grep "State:"`

	if [ "$STATUS" = "State: Active" ] ; then
	    echo "Running  srp scan on $HCA_ID $PORT"
# Run in 1 shot mode
/usr/sbin/srp_daemon -o -e -c -n -i ${HCA_ID} -p ${PORT}
	    RETVAL=$?
	fi
}

stop_daemon () {
    echo
}


case "$1" in 

start)
start_daemon
;;
stop)
stop_daemon
;;
restart | reload | force-reload )
stop_daemon
start_daemon
;;
esac