Skip to content

Instantly share code, notes, and snippets.

@jdutton
Created September 14, 2012 16:15
Show Gist options
  • Save jdutton/3722959 to your computer and use it in GitHub Desktop.
Save jdutton/3722959 to your computer and use it in GitHub Desktop.
Demo script to set arp notify after restoration of network link
#!/bin/bash
#
# This script ensures that the correct sysctl is configured on the
# installed guest. This is needed to fix case 20602.
# Reboot the guest regardless of whether we take any action here.
GARP_ENABLE="net.ipv4.conf.default.arp_notify = 1"
SYSCTL_FILE="/etc/sysctl.conf"
if [ -e $SYSCTL_FILE ]
then
grep -q "$GARP_ENABLE" $SYSCTL_FILE
if [ $? != 0 ]
then
echo stuffing $GARP_ENABLE into $SYSCTL_FILE
echo >> $SYSCTL_FILE
echo "# Configure to send gARP after migration" >> $SYSCTL_FILE
echo "$GARP_ENABLE" >> $SYSCTL_FILE
else
echo $GARP_ENABLE already found in $SYSCTL_FILE
sysctl -a | grep -q "$GARP_ENABLE"
if [ $? != 0 ]
then
echo sysctl is not working - "$GARP_ENABLE" not found
fi
fi
else
echo system does not have $SYSCTL_FILE -- nothing to do
fi
echo rebooting now
shutdown -r now
@jdutton
Copy link
Author

jdutton commented Sep 14, 2012

The reboot should really prompt the user first and allow him to decline to reboot now.

@chazmo-xx
Copy link

I'm going to modify this to take a --reboot argument (which automated test will supply) so that it operates as expected when run by test. In interactive (default) mode, it'll prompt every step of the way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment