Add a variable CTDB_CHECK_SWAP_IS_NOT_USED="yes"
[metze/ctdb/wip.git] / config / events.d / 70.iscsi
1 #!/bin/sh
2 # ctdb event script for TGTD based iSCSI
3
4 . $CTDB_BASE/functions
5
6 service_name="iscsi"
7
8 ctdb_start_stop_service
9
10 [ -z "$CTDB_START_ISCSI_SCRIPTS" ] && {
11         echo "No iscsi start script directory found"
12         exit 0
13 }
14
15 case "$1" in 
16     recovered)
17         # block the iscsi port
18         iptables -I INPUT 1 -p tcp --dport 3260 -j DROP
19         
20         # shut down the iscsi service
21         killall -9 tgtd >/dev/null 2>/dev/null
22
23         THIS_NODE=`ctdb status | grep "THIS NODE" | sed -e "s/pnn://" -e "s/ .*//"`
24         [ -z $THIS_NODE ] && {
25                 echo "70.iscsi: Failed to get node pnn"
26                 exit 0
27         }
28
29         # start the iscsi daemon
30         tgtd >/dev/null 2>/dev/null
31
32         for NODE in `ctdb ip | grep -v "Public" | egrep " ${THIS_NODE}$" | sed -e "s/ .*//"`; do
33                 [ -f $CTDB_START_ISCSI_SCRIPTS/${NODE}.sh ] && {
34                         echo Starting iscsi service for public address $NODE
35                         $CTDB_START_ISCSI_SCRIPTS/${NODE}.sh
36                 }
37         done
38
39         # remove all iptables rules
40         while iptables -D INPUT -p tcp --dport 3260 -j DROP 2>/dev/null >/dev/null ;  do
41             :
42         done
43
44         ;;
45
46     shutdown)
47         # shutdown iscsi when ctdb goes down
48         killall -9 tgtd >/dev/null 2>/dev/null
49         ;;
50
51     monitor)
52         ctdb_check_tcp_ports 3260 || exit $?
53         ;;
54
55     *)
56         ctdb_standard_event_handler "$@"
57         ;;
58 esac
59
60 exit 0