Commit 38a0e591 authored by Vitaly Lipatov's avatar Vitaly Lipatov

route-update.sh: support comments in gateway and table files

parent f340b0e8
......@@ -68,29 +68,29 @@ read_group_config()
gw="" ; table="" ; route_via=""
if [ -f "$dir/gateway" ] ; then
read -r gw < "$dir/gateway"
gw=$(grep -v '^#' "$dir/gateway" | grep -m1 .)
else
echo "[$(basename "$dir")] No gateway file, skipping" >&2
return 1
fi
if [ -f "$dir/table" ] ; then
read -r table < "$dir/table"
table=$(grep -v '^#' "$dir/table" | grep -m1 .)
else
echo "[$(basename "$dir")] No table file, skipping" >&2
return 1
fi
# Build route suffix: single vs multipath
local gw_count=$(grep -c . "$dir/gateway")
local gw_count=$(grep -v '^#' "$dir/gateway" | grep -c .)
if [ "$gw_count" -le 1 ] ; then
route_via="via $gw table $table"
else
route_via="table $table"
while read -r g ; do
[ -n "$g" ] || continue
local g
for g in $(grep -v '^#' "$dir/gateway" | grep .) ; do
route_via="$route_via nexthop via $g weight 1"
done < "$dir/gateway"
done
fi
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment