summaryrefslogtreecommitdiff
path: root/recipes/zeroconf/files/debian-zeroconf
blob: c3705d278892dbc70d6cca33eb1d943d364ffeb2 (plain)
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
44
45
46
47
48
49
50
51
#!/bin/sh

if [ ! -x /usr/sbin/zeroconf ]; then
    exit 0
fi

# IPv4 link-local addresses (zeroconf) are
# only applicable on the 'inet' address family
[ "X$ADDRFAM" != "Xinet" ] && exit 0

# However there are some methods where it doesn't
# make any sense to configure an IPv4LL address

# not on loopback
[ "X$METHOD" = "Xloopback" ] && exit 0

# not on ppp or wvdial either
[ "X$METHOD" = "Xppp" ] && exit 0
[ "X$METHOD" = "Xwvdial" ] && exit 0

# The administrator may have blacklisted interfaces
# or only want zeroconf in a fallback situation
[ -f /etc/default/zeroconf ] &&
    . /etc/default/zeroconf

[ -n "$DISABLE" ] && exit 0

for BLACK in $IFBLACKLIST; do
    case $IFACE in
	$BLACK)
	exit 0
	;;
    esac
done

# should we only allocate an address if we do not already have one?
if [ -n "$FALLBACK" ]; then
    /bin/ip addr show $IFACE scope global | grep -q "inet"
    IP=$?
    if [ $IP -eq 0 ]; then
        /bin/ip route add 169.254.0.0/16 dev $IFACE
        exit 0
    fi
fi

# otherwise, run if we aren't already going
if [ ! -r /var/run/zeroconf.$IFACE.pid ]; then
	/usr/sbin/zeroconf -i $IFACE
fi

exit 0