Blame tests/p_arpwatch/10_arpwatch_test.sh

Christoph Galuschka 7bc035
#!/bin/sh
Christoph Galuschka 579f4c
# Author: Christoph Galuschka <tigalch@tigalch.org>
Rene Diepstraten 3f096b
#         Rene Diepstraten <rene@renediepstraten.nl>
Christoph Galuschka 7bc035
Rene Diepstraten 3f096b
t_Log "Running $0 - arpwatch on interface with default gateway"
Rene Diepstraten 3f096b
Rene Diepstraten 3f096b
# arpwatch is broken in el7
Rene Diepstraten 3f096b
# See https://bugzilla.redhat.com/show_bug.cgi?id=1044062
Rene Diepstraten 3f096b
[[ $centos_ver -eq 7 ]] && { 
Rene Diepstraten 3f096b
  t_Log "arpwatch is broken on el7. Skipping test." 
Rene Diepstraten 3f096b
  exit
Rene Diepstraten 3f096b
}
Christoph Galuschka 7bc035
Athmane Madjoudj 820d69
# Kill arpwatch instance from previous test
Christoph Galuschka 7b96b9
# killall arpwatch
Athmane Madjoudj 820d69
Christoph Galuschka 7bc035
# getting IP-address of default gateway
Rene Diepstraten 3f096b
defgw=$(ip route | awk '/^default via/ {print $3}')
Alice Kaerast 6c678d
if [ -z $defgw ]
Alice Kaerast 6c678d
  then
Alice Kaerast 6c678d
  t_Log "No default gateway, can't test arpwatch"
Alice Kaerast 6c678d
  exit
Alice Kaerast 6c678d
fi
Christoph Galuschka 7bc035
Christoph Galuschka 7bc035
# setting path to arp.dat
Christoph Galuschka 7bc035
if (t_GetPkgRel basesystem | grep -q el5)
Christoph Galuschka 7bc035
  then
Christoph Galuschka 7bc035
  arpdat='/var/arpwatch/arp.dat'
Christoph Galuschka 7bc035
else
Christoph Galuschka 7bc035
  arpdat='/var/lib/arpwatch/arp.dat'
Christoph Galuschka 7bc035
fi
Christoph Galuschka 7bc035
Christoph Galuschka 7bc035
# beginning and running test
Christoph Galuschka 89571c
arpwatch
Christoph Galuschka 89571c
sleep 4
Christoph Galuschka 89571c
arp -d $defgw
Christoph Galuschka 7b96b9
sleep 4
Christoph Galuschka 7b96b9
ping -q -i 1 -c 5 $defgw
Christoph Galuschka 89571c
killall arpwatch
Christoph Galuschka 89571c
sleep 2
Christoph Galuschka 89571c
grep -q $defgw $arpdat
Christoph Galuschka 89571c
Christoph Galuschka 89571c
t_CheckExitStatus $?
Christoph Galuschka 7bc035
Christoph Galuschka 7bc035
# cleaning up
Christoph Galuschka 7bc035
cat /dev/null > $arpdat
Christoph Galuschka 7bc035