mirror of
https://gitlab.com/shorewall/code.git
synced 2024-11-07 16:24:01 +01:00
Eradicate the use of 'fgrep'
- Busybox on Leaf Bering does not have fgrep Signed-off-by: Tom Eastep <teastep@shorewall.net>
This commit is contained in:
parent
1666a4639f
commit
66c2fca2b0
@ -559,7 +559,7 @@ show_routing() {
|
||||
ip -$g_family rule list | find_tables | sort -u | while read table; do
|
||||
heading "Table $table:"
|
||||
if [ $g_family -eq 6 ]; then
|
||||
ip -$g_family -o route list table $table | fgrep -v cache | sort_routes
|
||||
ip -$g_family -o route list table $table | grep -vF cache | sort_routes
|
||||
else
|
||||
ip -4 -o route list table $table | sort_routes
|
||||
fi
|
||||
@ -572,7 +572,7 @@ show_routing() {
|
||||
else
|
||||
heading "Routing Table"
|
||||
if [ $g_family -eq 6 ]; then
|
||||
ip -$g_family -o route list | fgrep -v cache | sort_routes
|
||||
ip -$g_family -o route list | grep -vF cache | sort_routes
|
||||
else
|
||||
ip -4 -o route list table $table | sort_routes
|
||||
fi
|
||||
|
@ -605,7 +605,7 @@ find_first_interface_address() # $1 = interface
|
||||
#
|
||||
# get the line of output containing the first IP address
|
||||
#
|
||||
addr=$(${IP:-ip} -f inet6 addr show dev $1 2> /dev/null | fgrep 'inet6 ' | fgrep -v 'scope link' | head -n1)
|
||||
addr=$(${IP:-ip} -f inet6 addr show dev $1 2> /dev/null | grep -F 'inet6 ' | grep -vF 'scope link' | head -n1)
|
||||
#
|
||||
# If there wasn't one, bail out now
|
||||
#
|
||||
@ -634,7 +634,7 @@ find_first_interface_address_if_any() # $1 = interface
|
||||
#
|
||||
# get the line of output containing the first IP address
|
||||
#
|
||||
addr=$(${IP:-ip} -f inet6 addr show dev $1 2> /dev/null | fgrep 'inet6 ' | fgrep -v 'scope link' | head -n1)
|
||||
addr=$(${IP:-ip} -f inet6 addr show dev $1 2> /dev/null | grep -F 'inet6 ' | grep -vF 'scope link' | head -n1)
|
||||
#
|
||||
# Strip off the trailing VLSM mask (or the peer IP in case of a P-t-P link)
|
||||
# along with everything else on the line
|
||||
|
@ -433,7 +433,7 @@ case $HOST in
|
||||
install_local=
|
||||
|
||||
if [ -f ${SBINDIR}/ifup-local -o -f ${SBINDIR}/ifdown-local ]; then
|
||||
if ! fgrep -q Shorewall-based ${SBINDIR}/ifup-local || ! fgrep -q Shorewall-based ${SBINDIR}/ifdown-local; then
|
||||
if ! grep -qF Shorewall-based ${SBINDIR}/ifup-local || ! grep -qF Shorewall-based ${SBINDIR}/ifdown-local; then
|
||||
echo "WARNING: ${SBINDIR}/ifup-local and/or ${SBINDIR}/ifdown-local already exist; up/down events will not be handled"
|
||||
else
|
||||
install_local=Yes
|
||||
@ -527,7 +527,7 @@ if [ -f ${DESTDIR}/etc/ppp ]; then
|
||||
for file in ip-up.local ip-down.local; do
|
||||
FILE=${DESTDIR}/etc/ppp/$file
|
||||
if [ -f $FILE ]; then
|
||||
if fgrep -q Shorewall-based $FILE ; then
|
||||
if grep -qF Shorewall-based $FILE ; then
|
||||
cp -fp ${DESTDIR}${LIBEXECDIR}/shorewall-init/ifupdown $FILE
|
||||
else
|
||||
echo "$FILE already exists -- ppp devices will not be handled"
|
||||
|
@ -153,7 +153,7 @@ if [ -d ${CONFDIR}/ppp ]; then
|
||||
done
|
||||
|
||||
for file in if-up.local if-down.local; do
|
||||
if fgrep -q Shorewall-based ${CONFDIR}/ppp/$FILE; then
|
||||
if grep -qF Shorewall-based ${CONFDIR}/ppp/$FILE; then
|
||||
remove_file ${CONFDIR}/ppp/$FILE
|
||||
fi
|
||||
done
|
||||
|
@ -186,7 +186,7 @@ sub setup_route_marking() {
|
||||
sub copy_table( $$$ ) {
|
||||
my ( $duplicate, $number, $realm ) = @_;
|
||||
|
||||
my $filter = $family == F_IPV6 ? q(fgrep -v ' cache ' | sed 's/ via :: / /' | ) : '';
|
||||
my $filter = $family == F_IPV6 ? q(grep -vF ' cache ' | sed 's/ via :: / /' | ) : '';
|
||||
|
||||
emit '';
|
||||
|
||||
@ -223,7 +223,7 @@ sub copy_table( $$$ ) {
|
||||
sub copy_and_edit_table( $$$$$ ) {
|
||||
my ( $duplicate, $number, $id, $copy, $realm) = @_;
|
||||
|
||||
my $filter = $family == F_IPV6 ? q(fgrep -v ' cache ' | sed 's/ via :: / /' | ) : '';
|
||||
my $filter = $family == F_IPV6 ? q(grep -vF ' cache ' | sed 's/ via :: / /' | ) : '';
|
||||
my %copied;
|
||||
my @copy;
|
||||
my @bup_copy;
|
||||
|
@ -344,7 +344,7 @@ replace_default_route() # $1 = USE_DEFAULT_RT
|
||||
#
|
||||
delete_default_routes() # $1 = table number
|
||||
{
|
||||
$IP -$g_family route ls table $1 | fgrep default | fgrep -v metric | while read route; do
|
||||
$IP -$g_family route ls table $1 | grep -F default | grep -vF metric | while read route; do
|
||||
qt $IP -$g_family route del $route
|
||||
done
|
||||
}
|
||||
@ -377,7 +377,7 @@ restore_default_route() # $1 = USE_DEFAULT_RT
|
||||
#
|
||||
# We didn't restore a default route with metric 0
|
||||
#
|
||||
if $IP -$g_family -o route list 2> /dev/null | fgrep default | fgrep -qv metric; then
|
||||
if $IP -$g_family -o route list 2> /dev/null | grep -F default | grep -qvF metric; then
|
||||
#
|
||||
# But we added a default route with metric 0
|
||||
#
|
||||
@ -916,8 +916,8 @@ add_gateway() # $1 = Delta $2 = Table Number
|
||||
else
|
||||
delta=$1
|
||||
|
||||
if ! echo $route | fgrep -q ' nexthop '; then
|
||||
if echo $route | fgrep -q via; then
|
||||
if ! echo $route | grep -qF ' nexthop '; then
|
||||
if echo $route | grep -qF via; then
|
||||
route=`echo $route | sed 's/via/nexthop via/'`
|
||||
else
|
||||
route="nexthop $route"
|
||||
@ -947,7 +947,7 @@ delete_gateway() # $! = Description of the Gateway $2 = table number $3 = device
|
||||
gateway=$1
|
||||
|
||||
if [ -n "$route" ]; then
|
||||
if echo $route | fgrep -q ' nexthop '; then
|
||||
if echo $route | grep -qF ' nexthop '; then
|
||||
gateway="nexthop $gateway"
|
||||
eval route=\`echo $route \| sed \'s/$gateway/ /\'\`
|
||||
run_ip route replace table $2 $route
|
||||
|
Loading…
Reference in New Issue
Block a user