3 # CTDB event script for TGTD based iSCSI
5 [ -n "$CTDB_BASE" ] || \
6 export CTDB_BASE
=$
(cd -P $
(dirname "$0") ; dirname "$PWD")
14 ctdb_start_stop_service
16 is_ctdb_managed_service ||
exit 0
18 [ -z "$CTDB_START_ISCSI_SCRIPTS" ] && {
19 echo "No iscsi start script directory found"
25 all_ips
=$
(ctdb
-X ip |
tail -n +2)
27 # Block the iSCSI port. Only block for the address families
28 # we have configured. This copes with, for example, ip6tables
29 # being unavailable on an IPv4-only system.
32 while IFS
='|' read x ip pnn x
; do
34 *:*) have_ipv6
=true
;;
41 iptables
-I INPUT
1 -p tcp
--dport 3260 -j DROP
44 ip6tables
-I INPUT
1 -p tcp
--dport 3260 -j DROP
48 killall
-9 tgtd
>/dev
/null
2>/dev
/null
51 [ -n "$pnn" ] || die
"Failed to get node pnn"
56 # Run a script for each currently hosted public IP address
57 ips
=$
(echo "$all_ips" |
awk -F'|' -v pnn
=$pnn '$3 == pnn {print $2}')
59 script="${CTDB_START_ISCSI_SCRIPTS}/${ip}.sh"
60 if [ -x "$script" ] ; then
61 echo "Starting iSCSI service for public address ${ip}"
66 # Unblock iSCSI port. These can be unconditional (compared to
67 # blocking above), since errors are redirected.
68 while iptables
-D INPUT
-p tcp
--dport 3260 -j DROP
>/dev
/null
2>&1 ; do
71 while ip6tables
-D INPUT
-p tcp
--dport 3260 -j DROP
>/dev
/null
2>&1 ; do
78 # Shutdown iSCSI daemon when ctdb goes down
79 killall
-9 tgtd
>/dev
/null
2>&1
83 ctdb_check_tcp_ports
3260 ||
exit $?
87 ctdb_standard_event_handler
"$@"