]>
Commit | Line | Data |
---|---|---|
5b20e43a MT |
1 | #!/bin/bash |
2 | ############################################################################### | |
3 | # # | |
4 | # IPFire.org - A linux based firewall # | |
5 | # Copyright (C) 2009 Michael Tremer & Christian Schmidt # | |
6 | # # | |
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. # | |
11 | # # | |
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. # | |
16 | # # | |
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/>. # | |
19 | # # | |
20 | ############################################################################### | |
21 | ||
22 | . /etc/init/functions | |
23 | . /lib/network/functions | |
24 | ||
25 | while [ "$#" -gt "0" ]; do | |
26 | case "${1}" in | |
27 | --zone=*) | |
28 | zone=${1#--zone=} | |
29 | ;; | |
30 | *) | |
31 | action=${1} | |
32 | break | |
33 | ;; | |
34 | esac | |
35 | shift | |
36 | done | |
37 | ||
38 | if [ -z "${zone}" ] || [ -z "${action}" ]; then | |
39 | log_failure_msg "Wrong number of arguments." | |
40 | exit ${EXIT_ERROR} | |
41 | fi | |
42 | ||
43 | if ! zone_exists ${zone}; then | |
44 | echo "Zone ${zone} does not exist." | |
45 | exit ${EXIT_ERROR} | |
46 | fi | |
47 | ||
48 | case "$action" in | |
49 | start|up|reload) | |
50 | message="Bringing up zone ${zone}..." | |
51 | ||
52 | hooks_run_all pre-up ${CONFIG_ZONES}/${zone} --zone=${zone} | |
53 | ||
54 | if ! zone_is_up ${zone}; then | |
55 | # Create and bring up the zone | |
56 | brctl addbr ${zone} || failed=1 | |
57 | brctl stp ${zone} on || failed=1 | |
58 | brctl setfd ${zone} 0 || failed=1 | |
59 | ip link set ${zone} up || failed=1 | |
60 | (exit ${failed}) | |
61 | evaluate_retval standard | |
62 | fi | |
63 | ||
64 | # First bring up the ports to be able to start something like | |
65 | # a dhcp client that needs a running interface. | |
66 | hooks_run_ports post-up ${CONFIG_ZONES}/${zone} --zone=${zone} | |
67 | hooks_run_zones post-up ${CONFIG_ZONES}/${zone} --zone=${zone} | |
68 | ;; | |
69 | ||
70 | stop|down) | |
71 | message="Bringing down zone ${zone}..." | |
72 | ||
73 | if zone_is_up ${zone}; then | |
74 | hooks_run_zones pre-down ${CONFIG_ZONES}/${zone} --zone=${zone} | |
75 | hooks_run_ports pre-down ${CONFIG_ZONES}/${zone} --zone=${zone} | |
76 | ||
77 | # Bring down the zone and delete it | |
78 | ip link set ${zone} down || failed=1 | |
79 | brctl delbr ${zone} || failed=1 | |
80 | (exit ${failed}) | |
81 | evaluate_retval standard | |
82 | ||
83 | hooks_run_all post-down ${CONFIG_ZONES}/${zone} --zone=${zone} | |
84 | else | |
85 | log_warning_msg ${message} | |
86 | log_warning_msg "Zone ${zone} does not exist." | |
87 | fi | |
88 | ;; | |
89 | ||
90 | *) | |
91 | exit 1 | |
92 | ;; | |
93 | esac |