1
0
This repository has been archived on 2025-01-10. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
Anderson Luiz Alves 04a0df296c reapply
2018-11-21 19:33:35 -02:00

105 lines
3.3 KiB
Bash
Executable File

#!/bin/sh
# /etc/bewan/scripts/dhcp6-script
# called when DHCPv6 client gets an IA, a PD or some options from server
# Environnement variables:
# IFNAME: interface name
# DHCPDNS: DNS servers
# DHCPSRV: DHCP server
. /etc/bewan/scripts/globals
. /etc/bewan/lib/base
[ ! -f "$INTFD/$IFNAME/wanid" ] && exit 0
local WANID=`cat $INTFD/$IFNAME/wanid`
do_dhcp6_up_down() {
# Alacn, 2018-01-28
base_log "$SCRIPTD/dhcp6-script $IFNAME $REASON dns ${new_domain_name_servers:-} dhcp ${DHCPSRV:-} iana ${new_ianas:-} iapd ${new_iapds:-}" debug
case "$REASON" in
REQUEST)
#base_log "$SCRIPTD/dhcp6-script $IFNAME $REASON dns ${new_domain_name_servers:-} dhcp ${DHCPSRV:-}" debug
# Alacn, 2018-01-28: all empty? skip
[ -z "${new_domain_name_servers:-}" ] && [ -z "${new_ianas:-}" ] && [ -z "${new_iapds:-}" ] && return
# Take wan-up-down mutex
base_enter_critical 'wan-up-down'
# Get config parameters after taking lock
base_call_initd 'setparam'
# Ok, so if new_ianas is not set, we might have one in previous dhcp6-env
local new_ianas="${new_ianas:-}"
[ -z "$new_ianas" ] && [ -f $WAND/$WANID/ip6/dhcp6-env ] && {
eval `grep ^new_ianas= $WAND/$WANID/ip6/dhcp6-env`
[ -n "$new_ianas" ] && export new_ianas
}
# Ok, so if new_iapds is not set, we might have one in previous dhcp6-env
local new_iapds="${new_iapds:-}"
[ -z "$new_iapds" ] && [ -f $WAND/$WANID/ip6/dhcp6-env ] && {
eval `grep ^new_iapds= $WAND/$WANID/ip6/dhcp6-env`
[ -n "$new_iapds" ] && export new_iapds
}
# Right now, we only handle one na and one pd, but we could do something else here
local na; local dna=""
for na in $new_ianas; do
dna=${na##*,}
[ "$dna" = '::' ] && dna= && continue
break
done
local IANA="$dna"; export IANA
local pd; local dprefix=""
for pd in $new_iapds; do
dprefix=${pd##*,}
[ "$dprefix" = '::/0' ] && dprefix= && continue
break
done
local DPREFIX="$dprefix"; export DPREFIX
local DHCPDNS="${new_domain_name_servers:-}"; export DHCPDNS
# This script will be loaded by ip-up6
env | sed "s/=/='/g" | sed "s/$/'/g" > $WAND/$WANID/ip6/dhcp6-env
# call scripts
local script; for script in `find /etc/bewan/dhcp6-up.d -follow -type f 2>/dev/null| sort`; do
. $script $@
done
[ ! -f $RCRUNNING ] && base_call_initd 'inittab'
# Release wan-up-down mutex
base_exit_critical 'wan-up-down'
;;
RELEASE)
#base_log "$SCRIPTD/dhcp6-script $IFNAME $REASON dns ${new_domain_name_servers:-} dhcp ${DHCPSRV:-}" debug
if [ -f $WAND/$WANID/ip6/dhcp6-env ]; then
# Take wan-up-down mutex
base_enter_critical 'wan-up-down'
# Get config parameters after taking lock
base_call_initd 'setparam'
# call scripts
local script; for script in `find /etc/bewan/dhcp6-down.d -follow -type f 2>/dev/null| sort`; do
. $script $@
done
[ ! -f $RCRUNNING ] && base_call_initd 'inittab'
rm -f $WAND/$WANID/ip6/dhcp6-env
# Release wan-up-down mutex
base_exit_critical 'wan-up-down'
fi
;;
*)
return
;;
esac
}
do_dhcp6_up_down