]>
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) | |
19 | # Create dhclient configuration file. | |
20 | case "${proto}" in | |
21 | ipv4) | |
22 | config_file="${RUN_DIR}/dhclient/${interface}/dhclient4.conf" | |
23 | ;; | |
24 | ipv6) | |
25 | config_file="${RUN_DIR}/dhclient/${interface}/dhclient6.conf" | |
26 | ;; | |
27 | esac | |
28 | assert isset config_file | |
29 | ||
30 | dhclient_write_config ${interface} ${config_file} \ | |
31 | --hostname="${HOSTNAME%%.*}" | |
32 | ||
33 | exit ${EXIT_OK} | |
34 | ;; | |
35 | ||
36 | stop) | |
37 | case "${proto}" in | |
38 | ipv4) | |
39 | reason="STOP" | |
40 | ;; | |
41 | ipv6) | |
42 | reason="STOP6" | |
43 | ;; | |
44 | esac | |
45 | assert isset reason | |
46 | ||
47 | export interface | |
48 | export reason | |
49 | ||
50 | exec /usr/sbin/dhclient-script | |
51 | ||
52 | log ERROR $"execing dhclient-script has failed." | |
53 | exit ${EXIT_ERROR} | |
54 | ;; | |
55 | ||
56 | *) | |
57 | log ERROR "Unknown action passed: ${action}" | |
58 | exit ${EXIT_ERROR} | |
59 | ;; | |
60 | esac |