* [LARTC] Little script to save and restore ip rules
@ 2003-10-06 15:48 Lee Lists
0 siblings, 0 replies; only message in thread
From: Lee Lists @ 2003-10-06 15:48 UTC (permalink / raw)
To: lartc
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/
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2003-10-06 15:48 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-10-06 15:48 [LARTC] Little script to save and restore ip rules Lee Lists
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.