ctdb-tests: Avoid ShellCheck warnings
[Samba.git] / ctdb / tests / UNIT / eventscripts / scripts / 10.interface.sh
blob579f3ee7a9b4c98eb1606b2ac4292914fd631fe8
1 setup()
3 setup_public_addresses
6 _tcp_connections()
8 _count="$1"
9 _sip="$2"
10 _sport="$3"
11 _cip_base="$4"
12 _cport_base="$5"
14 _cip_prefix="${_cip_base%.*}"
15 _cip_suffix="${_cip_base##*.}"
17 for _i in $(seq 1 "$_count"); do
18 _cip_last=$((_cip_suffix + _i))
19 _cip="${_cip_prefix}.${_cip_last}"
20 _cport=$((_cport_base + _i))
21 echo "${_sip}:${_sport} ${_cip}:${_cport}"
22 done
25 setup_tcp_connections()
27 _t="${FAKE_NETWORK_STATE}/tcp-established"
28 export FAKE_NETSTAT_TCP_ESTABLISHED_FILE="$_t"
29 _tcp_connections "$@" >"$FAKE_NETSTAT_TCP_ESTABLISHED_FILE"
32 setup_tcp_connections_unkillable()
34 # These connections are listed by the "ss" stub but are not
35 # killed by the "ctdb killtcp" stub. So killing these
36 # connections will never succeed... and will look like a time
37 # out.
38 _t=$(_tcp_connections "$@" | sed -e 's/ /|/g')
39 export FAKE_NETSTAT_TCP_ESTABLISHED="$_t"
42 # Setup some fake /proc/net/bonding files with just enough info for
43 # the eventscripts.
45 # arg1 is interface name, arg2 is currently active slave (use "None"
46 # if none), arg3 is MII status ("up" or "down").
47 setup_bond()
49 _iface="$1"
50 _slave="${2:-${_iface}_sl_0}"
51 _mii_s="${3:-up}"
52 _mii_subs="${4:-${_mii_s:-up}}"
54 cat <<EOF
55 Setting $_iface to be a bond with active slave $_slave and MII status $_mii_s
56 EOF
58 _t="${FAKE_NETWORK_STATE}/proc-net-bonding"
59 export FAKE_PROC_NET_BONDING="$_t"
60 mkdir -p "$FAKE_PROC_NET_BONDING"
62 cat >"${FAKE_PROC_NET_BONDING}/$_iface" <<EOF
63 Bonding Mode: IEEE 802.3ad Dynamic link aggregation
64 Currently Active Slave: $_slave
65 # Status of the bond
66 MII Status: $_mii_s
67 # Status of 1st pretend adapter
68 MII Status: $_mii_subs
69 # Status of 2nd pretend adapter
70 MII Status: $_mii_subs
71 EOF