From: Lee Lists <lists@aacom.fr>
To: lartc@vger.kernel.org
Subject: [LARTC] Little script to save and restore ip rules
Date: Mon, 06 Oct 2003 15:48:29 +0000 [thread overview]
Message-ID: <marc-lartc-106545538809711@msgid-missing> (raw)
Hello,
I would like to have some testers for this script which should save and
restore ip rules and associated tables.
Thanks
#!/bin/bash
#
# chkconfig: 2345 85 15
# description: save and restore ip rules settings
# config: /etc/sysconfig/iprules
# source function library
. /etc/rc.d/init.d/functions
CONFIG=/etc/sysconfig/iprules
RETVAL=0
case "$1" in
save)
echo -n "Saving ip rules:"
rm $CONFIG > /dev/null 2>&1
ip ru ls | grep -v "^3276.:" | grep -v "^0:" | sed -e "s/://" -e
"s/from all//" -e "s/^/ip ru add preference /" |
echo $LINE >> $CONFIG
done
ip ru ls | grep -v "lookup local" | grep -v "lookup main" | grep -v
"lookup default" | sed -e "s/^.*lookup //" |
ip ro ls ta $LINE | sed -e "s/$/ ta $LINE/" -e "s/^/ip ro add /"
>> $CONFIG
done
echo
;;
stop)
echo -n "Stopping ip rules:"
ip ru ls | grep -v "lookup local" | grep -v "lookup main" | grep -v
"lookup default" | sed -e "s/^.*lookup //" |
ip ro flush ta $LINE
done
ip ru ls | grep -v "^3276.:" | grep -v "^0:" | sed -e "s/://" -e
"s/from all//" -e "s/^/ip ru del preference /"
/sbin/$LINE
done
rm -f /var/lock/subsys/rules
echo
;;
start)
echo -n "Starting ip rules:"
if [ -f /var/lock/subsys/rules ] ; then
$0 stop
fi
# real start
cat $CONFIG | while read LINE ; do
/sbin/$LINE
done
touch /var/lock/subsys/rules
echo
;;
restart|reload)
$0 stop
$0 start
RETVAL=$?
;;
status)
status gpm
RETVAL=$?
;;
*)
echo "Usage: gpm {start|stop|status|restart|reload}"
exit 1
esac
exit $RETVAL
_______________________________________________
LARTC mailing list / LARTC@mailman.ds9a.nl
http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/
reply other threads:[~2003-10-06 15:48 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=marc-lartc-106545538809711@msgid-missing \
--to=lists@aacom.fr \
--cc=lartc@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.