]>
Commit | Line | Data |
---|---|---|
e9ea243e MT |
1 | #!/bin/bash |
2 | ||
3 | . /usr/lib/network/functions | |
4 | ||
5 | action="${1}" | |
6 | assert isset action | |
7 | ||
8 | interface="${2}" | |
9 | assert isset interface | |
10 | ||
11 | proto=${3} | |
12 | assert isset proto | |
13 | ||
14 | # Check if the given interface is a zone. | |
15 | assert zone_exists ${interface} | |
16 | ||
17 | case "${action}" in | |
18 | start) | |
7ad5252c MT |
19 | leases_file="" |
20 | ||
e9ea243e MT |
21 | # Create dhclient configuration file. |
22 | case "${proto}" in | |
23 | ipv4) | |
24 | config_file="${RUN_DIR}/dhclient/${interface}/dhclient4.conf" | |
25 | ;; | |
26 | ipv6) | |
27 | config_file="${RUN_DIR}/dhclient/${interface}/dhclient6.conf" | |
7ad5252c | 28 | leases_file="/var/lib/dhclient/dhclient6-${interface}.leases" |
e9ea243e MT |
29 | ;; |
30 | esac | |
31 | assert isset config_file | |
32 | ||
7ad5252c MT |
33 | # Update the dhclient configuration files |
34 | dhclient_write_config "${interface}" \ | |
35 | --config-file="${config_file}" \ | |
36 | --leases-file="${leases_file}" || exit $? | |
e9ea243e MT |
37 | |
38 | exit ${EXIT_OK} | |
39 | ;; | |
40 | ||
41 | stop) | |
42 | case "${proto}" in | |
43 | ipv4) | |
44 | reason="STOP" | |
45 | ;; | |
46 | ipv6) | |
47 | reason="STOP6" | |
48 | ;; | |
49 | esac | |
50 | assert isset reason | |
51 | ||
52 | export interface | |
53 | export reason | |
54 | ||
55 | exec /usr/sbin/dhclient-script | |
56 | ||
57 | log ERROR $"execing dhclient-script has failed." | |
58 | exit ${EXIT_ERROR} | |
59 | ;; | |
60 | ||
61 | *) | |
62 | log ERROR "Unknown action passed: ${action}" | |
63 | exit ${EXIT_ERROR} | |
64 | ;; | |
65 | esac |