|
@ -131,6 +131,36 @@ typeof() { |
|
|
' |
|
|
' |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
explode() { |
|
|
|
|
|
local arg="$1" |
|
|
|
|
|
|
|
|
|
|
|
echo "$arg" | sed -e 's/\./, /g' |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
append_routes() { |
|
|
|
|
|
local tuple tuples="$1" |
|
|
|
|
|
local string= |
|
|
|
|
|
|
|
|
|
|
|
local IFS=',' |
|
|
|
|
|
for tuple in $tuples; do |
|
|
|
|
|
local network prefix router save octets compacted |
|
|
|
|
|
|
|
|
|
|
|
save="${tuple% *}" |
|
|
|
|
|
router="${tuple#${save} }" |
|
|
|
|
|
|
|
|
|
|
|
network="${save%/[0-9]*}" |
|
|
|
|
|
prefix="${save##${network}}" |
|
|
|
|
|
prefix="${prefix:1}" |
|
|
|
|
|
|
|
|
|
|
|
octets=$((($prefix + 7) / 8)) |
|
|
|
|
|
compacted="$(echo "$network" | cut -d. -f1-$octets)" |
|
|
|
|
|
|
|
|
|
|
|
string="${string:+, }$(explode "$prefix.$compacted.$router")" |
|
|
|
|
|
done |
|
|
|
|
|
|
|
|
|
|
|
echo " option classless-ipv4-route $string;" |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
append_dhcp_options() { |
|
|
append_dhcp_options() { |
|
|
local tuple="$1" |
|
|
local tuple="$1" |
|
|
|
|
|
|
|
@ -178,6 +208,7 @@ gen_dhcp_subnet() { |
|
|
fi |
|
|
fi |
|
|
echo " option routers $gateway;" |
|
|
echo " option routers $gateway;" |
|
|
echo " option domain-name-servers $DNS;" |
|
|
echo " option domain-name-servers $DNS;" |
|
|
|
|
|
config_list_foreach "$cfg" "routes" append_routes |
|
|
config_list_foreach "$cfg" "dhcp_option" append_dhcp_options |
|
|
config_list_foreach "$cfg" "dhcp_option" append_dhcp_options |
|
|
echo "}" |
|
|
echo "}" |
|
|
} |
|
|
} |
|
@ -264,6 +295,8 @@ general_config() { |
|
|
|
|
|
|
|
|
[ -n "$domain" ] && echo "option domain-name \"$domain\";" |
|
|
[ -n "$domain" ] && echo "option domain-name \"$domain\";" |
|
|
|
|
|
|
|
|
|
|
|
echo -e "\n# additional codes\noption classless-ipv4-route code 121 = array of { unsigned integer 8 };\n" |
|
|
|
|
|
|
|
|
rm -f /tmp/resolv.conf |
|
|
rm -f /tmp/resolv.conf |
|
|
echo "# This file is generated by the DHCPD service" > /tmp/resolv.conf |
|
|
echo "# This file is generated by the DHCPD service" > /tmp/resolv.conf |
|
|
[ -n "$domain" ] && echo "domain $domain" >> /tmp/resolv.conf |
|
|
[ -n "$domain" ] && echo "domain $domain" >> /tmp/resolv.conf |
|
|