2 # ctdb event script for TGTD based iSCSI
4 [ -n "$CTDB_BASE" ] || \
5 export CTDB_BASE
=$
(cd -P $
(dirname "$0") ; dirname "$PWD")
13 ctdb_start_stop_service
15 is_ctdb_managed_service ||
exit 0
17 [ -z "$CTDB_START_ISCSI_SCRIPTS" ] && {
18 echo "No iscsi start script directory found"
24 # block the iscsi port
25 iptables
-I INPUT
1 -p tcp
--dport 3260 -j DROP
27 # shut down the iscsi service
28 killall
-9 tgtd
>/dev
/null
2>/dev
/null
30 this_node
=$
(ctdb xpnn |
sed -e 's@PNN:@@')
31 if [ -z "$this_node" ] ; then
32 echo "Failed to get node pnn"
36 # start the iscsi daemon
37 tgtd
>/dev
/null
2>/dev
/null
39 ips
=$
(ctdb
-Y ip |
awk -F: -v pnn
=$this_node '$3 == pnn {print $2}')
41 script="${CTDB_START_ISCSI_SCRIPTS}/${ip}.sh"
42 if [ -x "$script" ] ; then
43 echo "Starting iscsi service for public address ${ip}"
48 # remove all iptables rules
49 while iptables
-D INPUT
-p tcp
--dport 3260 -j DROP
>/dev
/null
2>&1 ; do
56 # shutdown iscsi when ctdb goes down
57 killall
-9 tgtd
>/dev
/null
2>/dev
/null
61 ctdb_check_tcp_ports
3260 ||
exit $?
65 ctdb_standard_event_handler
"$@"