aboutsummaryrefslogtreecommitdiff
path: root/etc/local.d/radvd.hook
blob: 8137d0bca7dd10994ea6bfde6099548cd23c9c8c (plain) (blame)
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
#!/bin/sh
# Brutally simply hook for dhcpcd assuming you only have a single interface with
# delegated prefixes, which is the case for most home routers.

# This writes out a radvd conf for the interface and prefix in question and
# blindly restarts the daemon.

write_radvd() {

if [ -z "$new_delegated_dhcp6_prefix" ] ; then
	echo "Cannot continue without delegated prefix"
	exit 1;
fi

conf="interface $interface {
	AdvSendAdvert on;"

for prefix in $new_delegated_dhcp6_prefix ; do
conf="$conf
	prefix $prefix
	{
		AdvOnLink on;
		AdvAutonomous on;
		AdvRouterAddr on;
	};
"
done

conf="$conf
};"

echo "$conf" > /etc/radvd.conf

/etc/init.d/radvd restart
}

case "$reason" in
DELEGATED6)
write_radvd
;;
esac