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() ...@@ -68,29 +68,29 @@ read_group_config()
gw="" ; table="" ; route_via="" gw="" ; table="" ; route_via=""
if [ -f "$dir/gateway" ] ; then if [ -f "$dir/gateway" ] ; then
read -r gw < "$dir/gateway" gw=$(grep -v '^#' "$dir/gateway" | grep -m1 .)
else else
echo "[$(basename "$dir")] No gateway file, skipping" >&2 echo "[$(basename "$dir")] No gateway file, skipping" >&2
return 1 return 1
fi fi
if [ -f "$dir/table" ] ; then if [ -f "$dir/table" ] ; then
read -r table < "$dir/table" table=$(grep -v '^#' "$dir/table" | grep -m1 .)
else else
echo "[$(basename "$dir")] No table file, skipping" >&2 echo "[$(basename "$dir")] No table file, skipping" >&2
return 1 return 1
fi fi
# Build route suffix: single vs multipath # 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 if [ "$gw_count" -le 1 ] ; then
route_via="via $gw table $table" route_via="via $gw table $table"
else else
route_via="table $table" route_via="table $table"
while read -r g ; do local g
[ -n "$g" ] || continue for g in $(grep -v '^#' "$dir/gateway" | grep .) ; do
route_via="$route_via nexthop via $g weight 1" route_via="$route_via nexthop via $g weight 1"
done < "$dir/gateway" done
fi 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