2 ###############################################################################
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2012 IPFire Network Development Team #
7 # This program is free software: you can redistribute it and/or modify #
8 # it under the terms of the GNU General Public License as published by #
9 # the Free Software Foundation, either version 3 of the License, or #
10 # (at your option) any later version. #
12 # This program is distributed in the hope that it will be useful, #
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15 # GNU General Public License for more details. #
17 # You should have received a copy of the GNU General Public License #
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
20 ###############################################################################
26 assert isset interface
27 assert device_exists
${interface}
29 local service
=$
(dhclient_proto2service
${proto} ${interface})
30 service_start
${service}
37 local service
=$
(dhclient_proto2service
${proto} ${interface})
38 service_stop
${service}
45 local service
=$
(dhclient_proto2service
${proto} ${interface})
46 service_status
${service}
49 dhclient_proto2service
() {
54 assert isset interface
60 service
="dhclient4@${interface}.service"
63 service
="dhclient6@${interface}.service"
76 dhclient_write_config
() {
81 assert isset interface
84 local hostname
=${HOSTNAME%%.*}
85 local prefix_delegation
="false"
86 local vendor
=$
(distro_get_pretty_name
)
88 while [ $# -gt 0 ]; do
91 hostname
=$
(cli_get_val
${1})
93 --prefix-delegation=*)
94 prefix_delegation
="$(cli_get_bool "${1}")"
97 vendor
=$
(cli_get_val
${1})
100 log WARNING $
"Unknown configuration option passed: ${1}."
106 # Clear configuration file (if any).
107 mkdir
-p $
(dirname ${file}) 2>/dev
/null
112 echo "# This is a dhclient daemon configuration file for ${interface}."
113 echo "# THIS FILE IS AUTOMATICALLY GENERATED AND WILL OVERWRITE"
114 echo "# ANY CUSTOM CHANGES!"
122 echo "send vendor-class-identifier \"${vendor}\";" >>${file}
127 echo "interface \"${interface}\" {"
129 if isset hostname
; then
130 echo " send host-name \"${hostname}\";"
134 # Prefix delegation (IPv6).
135 if enabled prefix_delegation
; then
136 print
" # Prefix delegation"
137 print
" also request dhcp6.ia-pd 1;"
138 print
" send dhcp6.ia-na 1;"