]>
Commit | Line | Data |
---|---|---|
8838c71a 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 | ||
2534973b | 22 | DEBUG= |
8838c71a MT |
23 | VERBOSE= |
24 | TMPDIR=$(mktemp -d) | |
25 | ||
26 | BOLD="\\033[1;39m" | |
27 | NORMAL="\\033[0;39m" | |
28 | ERROR="\\033[1;31m" | |
29 | ||
2534973b MT |
30 | function debug() { |
31 | if [ -n "$1" ]; then | |
32 | DEBUG=$1 | |
33 | verbose $1 | |
34 | return | |
35 | else | |
36 | if [ "$DEBUG" = "1" ]; then | |
37 | return 0 | |
38 | else | |
39 | return 1 | |
40 | fi | |
41 | fi | |
42 | ||
43 | } | |
44 | ||
8838c71a MT |
45 | function verbose() { |
46 | if [ -n "$1" ]; then | |
47 | VERBOSE=$1 | |
48 | return | |
49 | else | |
50 | if [ "$VERBOSE" = "1" ]; then | |
51 | return 0 | |
52 | else | |
53 | return 1 | |
54 | fi | |
55 | fi | |
56 | } | |
57 | ||
2534973b MT |
58 | function decho() { |
59 | debug && echo -e "${ERROR}$@${NORMAL}" | |
60 | } | |
61 | ||
8838c71a MT |
62 | function vecho() { |
63 | verbose && echo -e "$@" | |
64 | } | |
65 | ||
66 | function error() { | |
67 | echo -e "${ERROR}ERROR${NORMAL}: $@" >&2 | |
68 | _exit 1 | |
69 | } | |
70 | ||
71 | function ifs() { | |
72 | if [ -n "$1" ]; then | |
73 | IFS_SAVE=$IFS | |
74 | echo $1 | |
75 | else | |
76 | echo $IFS_SAVE | |
77 | fi | |
78 | } | |
79 | ||
80 | function uppercase() { | |
81 | tr [a-z] [A-Z] <<< "$@" | |
82 | } | |
83 | ||
84 | include functions.commands | |
85 | include functions.config | |
86 | include functions.firewall | |
87 | include functions.ip | |
88 | include functions.iptables | |
89 | include functions.macros | |
90 | include functions.zones | |
91 | ||
92 | function _start() { | |
dbfeda6c MT |
93 | local zone |
94 | local policy | |
95 | ||
8838c71a | 96 | firewall_init |
2534973b MT |
97 | zones_local_add |
98 | ||
dbfeda6c MT |
99 | for zone in $(network zone list); do |
100 | zone=$(basename ${zone}) | |
101 | policy=${zone%%[0-9]*} | |
102 | zones_${policy}_add ${zone} | |
103 | done | |
2534973b | 104 | |
8838c71a | 105 | iptables_commit |
b5238f57 MT |
106 | } |
107 | ||
108 | function _stop() { | |
dbfeda6c MT |
109 | iptables_flush |
110 | iptables_commit | |
8838c71a | 111 | } |