File: vzifup-post.in

package info (click to toggle)
vzctl 3.0.30.2-4
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 3,056 kB
  • sloc: ansic: 17,282; sh: 14,549; makefile: 528
file content (43 lines) | stat: -rwxr-xr-x 977 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/bin/bash
# Copyright (C) 2008-2011, Parallels, Inc. All rights reserved.
#
# Update ARP table for all containers on interface up

[ ! -f /proc/vz/veip ] && exit 0

usage()
{
	echo "Usage: $(basename $0) DEVICE" 1>&2
	exit 1
}

# Supplied interface name
DEV=$1
[ -z "${DEV}" ] && usage

test -f @PKGLIBDIR@/scripts/vps-functions || exit 1
test -f @PKGCONFDIR@/vz.conf || exit 1
. @PKGLIBDIR@/scripts/vps-functions
. @PKGCONFDIR@/vz.conf

update_arp()
{
	local veip
	for veip in $(awk '!/^Version/ { print $1 }' /proc/vz/veip); do
		[ "$NEIGHBOUR_DEVS" = 'detect' ] && vzdelrouting "${veip}"
		vzarp add ${veip}
		[ "$NEIGHBOUR_DEVS" = 'detect' ] && vzaddrouting "${veip}"
	done
}

# Get possible interface names
vzgetnetdev
[ -z "${NETDEVICES}" ] && exit 0

# Check if a device name given is in the list returned by vzgetnetdev
# Indeed we do not want to add arp entries for e.g. 'lo'
echo "${NETDEVICES}" | grep -qw "${DEV}" || exit 0

NETDEVICES="${DEV}"
update_arp
exit 0