1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-23 17:34:34 +03:00
samba-mirror/ctdb/config/events.d/11.routing
Martin Schwenke 09a7a7854e ctdb-scripts: Event script indentation and whitespace cleanups
* Re-indent case labels as per new script style

  Other indentation can be tweaked later as code changes, but the
  labels are an obvious bulk change.

* Minor whitespace fixes

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2016-07-21 02:24:25 +02:00

50 lines
1.1 KiB
Bash
Executable File

#!/bin/sh
# Attempt to add a set of static routes.
#
# Do this in "ipreallocated" rather than just "startup" because some
# of the routes might be missing because the corresponding interface
# has not previously had any IPs assigned or IPs were previously
# released and corresponding routes were dropped.
#
# Addition of some routes might fail, errors go to /dev/null.
#
# Routes to add are defined in $CTDB_BASE/static-routes. Syntax is:
#
# IFACE NET/MASK GATEWAY
#
# Example:
#
# bond1 10.3.3.0/24 10.0.0.1
[ -n "$CTDB_BASE" ] || \
CTDB_BASE=$(d=$(dirname "$0") ; cd -P "$d" ; dirname "$PWD")
. "${CTDB_BASE}/functions"
loadconfig
[ -f "${CTDB_BASE}/static-routes" ] || {
exit 0
}
case "$1" in
ipreallocated)
while read iface dest gw; do
ip route add "$dest" via "$gw" dev "$iface" >/dev/null 2>&1
done <"${CTDB_BASE}/static-routes"
;;
updateip)
oiface=$2
niface=$3
while read iface dest gw; do
if [ "$niface" = "$iface" -o "$oiface" = "$iface" ] ; then
ip route add "$dest" via "$gw" dev "$iface" >/dev/null 2>&1
fi
done <"${CTDB_BASE}/static-routes"
;;
esac
exit 0